K2 IC: refactor and optimize lookup tracking
- encapsulate semantic more into helpers - allow lazy scopes iteration - simplify reporting code in tower resolver - fix some inconsistencies and wrong lookups - remove redundant lookup recordings - remove lookup scopes for non-star imports The commit is a refactoring and doesn't change the behaviour of neither IC nor CRI. Changes in the lookups are mostly due to the previous obviously wrong lookups (see changed test data).
This commit is contained in:
committed by
Space Team
parent
fe4e0e9c2e
commit
a823bfd600
+3
-4
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.getLineAndColumnInPsiFil
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.components.Position
|
||||
import org.jetbrains.kotlin.incremental.components.ScopeKind
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -23,7 +22,7 @@ class IncrementalPassThroughLookupTrackerComponent(
|
||||
private val requiresPosition = lookupTracker.requiresPosition
|
||||
private val sourceToFilePathsCache = ConcurrentHashMap<KtSourceElement, String>()
|
||||
|
||||
override fun recordLookup(name: Name, inScopes: List<String>, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
override fun recordLookup(name: String, inScopes: Iterable<String>, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
// finding file for a source only possible for PSI, here it means
|
||||
// that we allow null for file source only for PSI-only "sources", currently - java ones, ignoring the other cases
|
||||
// TODO: although there are valid use cases for missing fileSource, the ignore may hide some possible bugs; consider stricter implementation
|
||||
@@ -38,11 +37,11 @@ class IncrementalPassThroughLookupTrackerComponent(
|
||||
} else Position.NO_POSITION
|
||||
|
||||
for (scope in inScopes) {
|
||||
lookupTracker.record(path, position, scope, ScopeKind.PACKAGE, name.asString())
|
||||
lookupTracker.record(path, position, scope, ScopeKind.PACKAGE, name)
|
||||
}
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, inScope: String, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
override fun recordLookup(name: String, inScope: String, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
recordLookup(name, SmartList(inScope), source, fileSource)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user