Add location parameter to JetScope::getFunctions

This commit is contained in:
Zalim Bashorov
2015-07-14 22:05:46 +03:00
parent f79155df97
commit 0f92036353
37 changed files with 56 additions and 44 deletions
@@ -50,7 +50,7 @@ class AllUnderImportsScope : JetScope {
return scopes.flatMap { it.getProperties(name) }
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
return scopes.flatMap { it.getFunctions(name) }
}
@@ -734,7 +734,7 @@ public class OverrideResolver {
) {
for (JetType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
all.addAll(supertype.getMemberScope().getFunctions(declared.getName()));
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), Location.NOWHERE));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), Location.NOWHERE));
for (CallableMemberDescriptor fromSuper : all) {
@@ -234,7 +234,7 @@ public class QualifiedExpressionResolver {
}
if (lookupMode == LookupMode.EVERYTHING) {
descriptors.addAll(outerScope.getFunctions(referencedName));
descriptors.addAll(outerScope.getFunctions(referencedName, Location.NOWHERE));
descriptors.addAll(outerScope.getProperties(referencedName, Location.NOWHERE));
VariableDescriptor localVariable = outerScope.getLocalVariable(referencedName);
@@ -33,7 +33,7 @@ class SingleImportScope(private val aliasName: Name, private val descriptors: Co
override fun getProperties(name: Name, location: Location)
= if (name == aliasName) descriptors.filterIsInstance<VariableDescriptor>() else emptyList()
override fun getFunctions(name: Name)
override fun getFunctions(name: Name, location: Location)
= if (name == aliasName) descriptors.filterIsInstance<FunctionDescriptor>() else emptyList()
override fun getContainingDeclaration(): DeclarationDescriptor = throw UnsupportedOperationException()
@@ -49,7 +49,7 @@ object DynamicCallableDescriptors {
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
if (isAugmentedAssignmentConvention(name)) return listOf()
if (call.getCallType() == Call.CallType.INVOKE
&& call.getValueArgumentList() == null && call.getFunctionLiteralArguments().isEmpty()) {
@@ -134,7 +134,7 @@ public class LazyDeclarationResolver {
@Override
public DeclarationDescriptor visitNamedFunction(@NotNull JetNamedFunction function, Void data) {
JetScope scopeForDeclaration = resolutionScopeToResolveDeclaration(function);
scopeForDeclaration.getFunctions(function.getNameAsSafeName());
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), Location.NOWHERE);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
}
@@ -253,7 +253,7 @@ class LazyImportScope(
override fun getLocalVariable(name: Name) = null
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name) }
}
@@ -64,7 +64,7 @@ protected constructor(
override fun getClassifier(name: Name): ClassDescriptor? = classDescriptors(name).firstOrNull()
override fun getFunctions(name: Name): Collection<FunctionDescriptor> = functionDescriptors(name)
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> = functionDescriptors(name)
private fun doGetFunctions(name: Name): Collection<FunctionDescriptor> {
val result = Sets.newLinkedHashSet<FunctionDescriptor>()
@@ -115,7 +115,7 @@ public open class LazyClassMemberScope(
OverrideResolver.resolveUnknownVisibilities(result, trace)
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
// TODO: this should be handled by lazy function descriptors
val functions = super.getFunctions(name)
resolveUnknownVisibilitiesForMembers(functions)
@@ -156,7 +156,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
functionsByName!![name] = functionsByName!![name] + descriptorIndex
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name), workerScope.getFunctions(name))
@@ -270,7 +270,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
return workerScope.getLocalVariable(name)
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name, descriptorLimit), workerScope.getFunctions(name))