Introduce ResolutionScope::definitelyDoesNotContainName
Also add some obvious implementations This method might be used in resolution to filter out inapplicable scopes
This commit is contained in:
@@ -124,4 +124,7 @@ abstract class LexicalScopeStorage(
|
|||||||
} while (rest != null)
|
} while (rest != null)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun definitelyDoesNotContainName(name: Name) =
|
||||||
|
functionsByName?.get(name) == null && variablesAndClassifiersByName?.get(name) == null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ interface LexicalScope : HierarchicalScope {
|
|||||||
override val kind: LexicalScopeKind
|
override val kind: LexicalScopeKind
|
||||||
get() = LexicalScopeKind.EMPTY
|
get() = LexicalScopeKind.EMPTY
|
||||||
|
|
||||||
|
override fun definitelyDoesNotContainName(name: Name) = true
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println("Base lexical scope with owner = $ownerDescriptor and parent = $parent")
|
p.println("Base lexical scope with owner = $ownerDescriptor and parent = $parent")
|
||||||
}
|
}
|
||||||
@@ -123,6 +125,8 @@ interface ImportingScope : HierarchicalScope {
|
|||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println("ImportingScope.Empty")
|
p.println("ImportingScope.Empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun definitelyDoesNotContainName(name: Name) = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,5 +40,7 @@ class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScopeImpl()
|
|||||||
workerScope.printScopeStructure(p)
|
workerScope.printScopeStructure(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun definitelyDoesNotContainName(name: Name) = workerScope.definitelyDoesNotContainName(name)
|
||||||
|
|
||||||
override fun toString() = "Classes from $workerScope"
|
override fun toString() = "Classes from $workerScope"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.scopes
|
package org.jetbrains.kotlin.resolve.scopes
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
@@ -36,4 +39,6 @@ interface ResolutionScope {
|
|||||||
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
||||||
nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER
|
nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER
|
||||||
): Collection<DeclarationDescriptor>
|
): Collection<DeclarationDescriptor>
|
||||||
|
|
||||||
|
fun definitelyDoesNotContainName(name: Name): Boolean = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
|||||||
override fun getFunctionNames() = workerScope.getFunctionNames()
|
override fun getFunctionNames() = workerScope.getFunctionNames()
|
||||||
override fun getVariableNames() = workerScope.getVariableNames()
|
override fun getVariableNames() = workerScope.getVariableNames()
|
||||||
|
|
||||||
|
override fun definitelyDoesNotContainName(name: Name) = workerScope.definitelyDoesNotContainName(name)
|
||||||
|
|
||||||
override fun printScopeStructure(p: Printer) {
|
override fun printScopeStructure(p: Printer) {
|
||||||
p.println(this::class.java.simpleName, " {")
|
p.println(this::class.java.simpleName, " {")
|
||||||
p.pushIndent()
|
p.pushIndent()
|
||||||
|
|||||||
@@ -219,6 +219,11 @@ public class ErrorUtils {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean definitelyDoesNotContainName(@NotNull Name name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ErrorScope{" + debugMessage + '}';
|
return "ErrorScope{" + debugMessage + '}';
|
||||||
@@ -279,6 +284,11 @@ public class ErrorUtils {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean definitelyDoesNotContainName(@NotNull Name name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ThrowingScope{" + debugMessage + '}';
|
return "ThrowingScope{" + debugMessage + '}';
|
||||||
|
|||||||
+1
@@ -106,6 +106,7 @@ class MetadataPackageFragment(
|
|||||||
containerSource = null, components = components, classNames = { emptyList() }
|
containerSource = null, components = components, classNames = { emptyList() }
|
||||||
) {
|
) {
|
||||||
override fun hasClass(name: Name): Boolean = hasTopLevelClass(name)
|
override fun hasClass(name: Name): Boolean = hasTopLevelClass(name)
|
||||||
|
override fun definitelyDoesNotContainName(name: Name) = false
|
||||||
})
|
})
|
||||||
|
|
||||||
return ChainedMemberScope.create("Metadata scope", scopes)
|
return ChainedMemberScope.create("Metadata scope", scopes)
|
||||||
|
|||||||
Reference in New Issue
Block a user