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
@@ -218,7 +218,7 @@ public abstract class LazyJavaMemberScope(
return ResolvedValueParameters(descriptors, synthesizedNames)
}
override fun getFunctions(name: Name) = functions(name)
override fun getFunctions(name: Name, location: Location) = functions(name)
protected open fun getFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
= memberIndex().getMethodNames(nameFilter)
@@ -73,7 +73,7 @@ public class LazyPackageFragmentScopeForJavaPackage(
override fun getClassifier(name: Name): ClassifierDescriptor? = classes(name)
override fun getProperties(name: Name, location: Location) = deserializedPackageScope().getProperties(name)
override fun getFunctions(name: Name) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
override fun getFunctions(name: Name, location: Location) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
kindFilter: DescriptorKindFilter,
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -1018,6 +1019,6 @@ public class KotlinBuiltIns {
@NotNull
public FunctionDescriptor getIdentityEquals() {
return KotlinPackage.first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals")));
return KotlinPackage.first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"), Location.NOWHERE));
}
}
@@ -48,7 +48,7 @@ class FunctionClassScope(
return allDescriptors()
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
return allDescriptors().filterIsInstance<FunctionDescriptor>().filter { it.getName() == name }
}
@@ -204,13 +204,13 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull Location location) {
return functions.invoke(name);
}
@NotNull
private Collection<FunctionDescriptor> computeFunctions(@NotNull Name name) {
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name));
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, Location.NOWHERE));
}
@NotNull
@@ -266,7 +266,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
private Collection<DeclarationDescriptor> computeAllDeclarations() {
Collection<DeclarationDescriptor> result = new HashSet<DeclarationDescriptor>();
for (Name name : enumMemberNames.invoke()) {
result.addAll(getFunctions(name));
result.addAll(getFunctions(name, Location.NOWHERE));
result.addAll(getProperties(name, Location.NOWHERE));
}
return result;
@@ -31,7 +31,7 @@ public abstract class AbstractScopeAdapter : JetScope {
return workerScope.getImplicitReceiversHierarchy()
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
return workerScope.getFunctions(name)
}
@@ -62,7 +62,7 @@ public open class ChainedScope(
override fun getLocalVariable(name: Name): VariableDescriptor?
= getFirstMatch { it.getLocalVariable(name) }
override fun getFunctions(name: Name): Collection<FunctionDescriptor>
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor>
= getFromAllScopes { it.getFunctions(name) }
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
@@ -29,7 +29,7 @@ public class ExplicitImportsScope(private val descriptors: Collection<Declaratio
override fun getProperties(name: Name, location: Location) = descriptors.filter { it.getName() == name }.filterIsInstance<VariableDescriptor>()
override fun getFunctions(name: Name) = descriptors.filter { it.getName() == name }.filterIsInstance<FunctionDescriptor>()
override fun getFunctions(name: Name, location: Location) = descriptors.filter { it.getName() == name }.filterIsInstance<FunctionDescriptor>()
override fun getContainingDeclaration() = throw UnsupportedOperationException()
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: JetScope, private val predicate: (DeclarationDescriptor) -> Boolean) : JetScope {
override fun getFunctions(name: Name) = workerScope.getFunctions(name).filter(predicate)
override fun getFunctions(name: Name, location: Location) = workerScope.getFunctions(name).filter(predicate)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
@@ -33,7 +33,7 @@ public interface JetScope {
public fun getLocalVariable(name: Name): VariableDescriptor?
public fun getFunctions(name: Name): Collection<FunctionDescriptor>
public fun getFunctions(name: Name, location: Location = Location.NOWHERE): Collection<FunctionDescriptor>
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
@@ -30,7 +30,7 @@ public abstract class JetScopeImpl : JetScope {
override fun getPackage(name: Name): PackageViewDescriptor? = null
override fun getFunctions(name: Name): Collection<FunctionDescriptor> = setOf()
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> = setOf()
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = listOf()
@@ -44,7 +44,7 @@ public class StaticScopeForKotlinClass(
override fun getOwnDeclaredDescriptors() = functions
override fun getFunctions(name: Name) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getFunctions(name: Name, location: Location) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getContainingDeclaration() = containingClass
@@ -67,7 +67,7 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
override fun getClassifier(name: Name) = substitute(workerScope.getClassifier(name))
override fun getFunctions(name: Name) = substitute(workerScope.getFunctions(name))
override fun getFunctions(name: Name, location: Location) = substitute(workerScope.getFunctions(name))
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name))
@@ -124,7 +124,7 @@ public class ErrorUtils {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Set<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull Location location) {
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
}
@@ -204,7 +204,7 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull Location location) {
throw new IllegalStateException();
}
@@ -93,7 +93,7 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> = functions(name)
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> = functions(name)
private fun computeProperties(name: Name): Collection<VariableDescriptor> {
val descriptors = computeMembers<PropertyDescriptor>(name, Kind.PROPERTY)