Add location parameter to JetScope::getProperties
This commit is contained in:
@@ -75,6 +75,7 @@ import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
@@ -1074,7 +1075,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert loopRangeType != null;
|
||||
Type asmLoopRangeType = asmType(loopRangeType);
|
||||
|
||||
Collection<VariableDescriptor> incrementProp = loopRangeType.getMemberScope().getProperties(Name.identifier("increment"));
|
||||
Collection<VariableDescriptor> incrementProp =
|
||||
loopRangeType.getMemberScope().getProperties(Name.identifier("increment"), Location.NOWHERE);
|
||||
assert incrementProp.size() == 1 : loopRangeType + " " + incrementProp.size();
|
||||
incrementType = asmType(incrementProp.iterator().next().getType());
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import java.util.ArrayList
|
||||
@@ -45,7 +46,7 @@ class AllUnderImportsScope : JetScope {
|
||||
return scopes.asSequence().map { it.getClassifier(name) }.filterNotNull().singleOrNull()
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> {
|
||||
return scopes.flatMap { it.getProperties(name) }
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage;
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
@@ -735,7 +736,7 @@ public class OverrideResolver {
|
||||
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
|
||||
all.addAll(supertype.getMemberScope().getFunctions(declared.getName()));
|
||||
//noinspection unchecked
|
||||
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName()));
|
||||
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), Location.NOWHERE));
|
||||
for (CallableMemberDescriptor fromSuper : all) {
|
||||
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared).getResult() == OVERRIDABLE) {
|
||||
if (Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSuper, declared)) {
|
||||
|
||||
@@ -235,7 +235,7 @@ public class QualifiedExpressionResolver {
|
||||
|
||||
if (lookupMode == LookupMode.EVERYTHING) {
|
||||
descriptors.addAll(outerScope.getFunctions(referencedName));
|
||||
descriptors.addAll(outerScope.getProperties(referencedName));
|
||||
descriptors.addAll(outerScope.getProperties(referencedName, Location.NOWHERE));
|
||||
|
||||
VariableDescriptor localVariable = outerScope.getLocalVariable(referencedName);
|
||||
if (localVariable != null) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class SingleImportScope(private val aliasName: Name, private val descriptors: Co
|
||||
override fun getPackage(name: Name)
|
||||
= if (name == aliasName) descriptors.filterIsInstance<PackageViewDescriptor>().singleOrNull() else null
|
||||
|
||||
override fun getProperties(name: Name)
|
||||
override fun getProperties(name: Name, location: Location)
|
||||
= if (name == aliasName) descriptors.filterIsInstance<VariableDescriptor>() else emptyList()
|
||||
|
||||
override fun getFunctions(name: Name)
|
||||
@@ -43,4 +43,4 @@ class SingleImportScope(private val aliasName: Name, private val descriptors: Co
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.getSimpleName(), ": ", aliasName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCol
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.types.DynamicType
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
@@ -76,7 +77,7 @@ object DynamicCallableDescriptors {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> {
|
||||
return if (call.getValueArgumentList() == null && call.getValueArguments().isEmpty()) {
|
||||
listOf(createDynamicProperty(owner, name, call))
|
||||
}
|
||||
|
||||
+3
-3
@@ -26,11 +26,11 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.AnnotationResolver;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
import org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -146,7 +146,7 @@ public class LazyDeclarationResolver {
|
||||
// This is a primary constructor parameter
|
||||
ClassDescriptor classDescriptor = getClassDescriptor(jetClass);
|
||||
if (parameter.hasValOrVar()) {
|
||||
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName());
|
||||
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName(), Location.NOWHERE);
|
||||
return getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
|
||||
}
|
||||
else {
|
||||
@@ -189,7 +189,7 @@ public class LazyDeclarationResolver {
|
||||
@Override
|
||||
public DeclarationDescriptor visitProperty(@NotNull JetProperty property, Void data) {
|
||||
JetScope scopeForDeclaration = resolutionScopeToResolveDeclaration(property);
|
||||
scopeForDeclaration.getProperties(property.getNameAsSafeName());
|
||||
scopeForDeclaration.getProperties(property.getNameAsSafeName(), Location.NOWHERE);
|
||||
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver
|
||||
import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.LookupMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
@@ -245,7 +246,7 @@ class LazyImportScope(
|
||||
return importResolver.selectSingleFromImports(name, LookupMode.ONLY_CLASSES_AND_PACKAGES) { scope, name -> scope.getPackage(name) }
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> {
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getProperties(name) }
|
||||
}
|
||||
|
||||
+2
-1
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
@@ -88,7 +89,7 @@ protected constructor(
|
||||
|
||||
protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet<FunctionDescriptor>)
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> = propertyDescriptors(name)
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> = propertyDescriptors(name)
|
||||
|
||||
public fun doGetProperties(name: Name): Collection<VariableDescriptor> {
|
||||
val result = LinkedHashSet<VariableDescriptor>()
|
||||
|
||||
+21
-20
@@ -17,30 +17,31 @@
|
||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
import com.google.common.collect.Lists
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
|
||||
import java.util.*
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetProperty
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.DelegationResolver.generateDelegatedMembers
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.createComponentName
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import java.util.ArrayList
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
public open class LazyClassMemberScope(
|
||||
c: LazyClassContext,
|
||||
@@ -172,7 +173,7 @@ public open class LazyClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> {
|
||||
// TODO: this should be handled by lazy property descriptors
|
||||
val properties = super.getProperties(name)
|
||||
resolveUnknownVisibilitiesForMembers(properties as Collection<CallableMemberDescriptor>)
|
||||
|
||||
+4
-3
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
|
||||
import org.jetbrains.kotlin.renderer.NameShortness;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
import org.jetbrains.kotlin.test.JetLiteFixture;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
@@ -170,13 +171,13 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
|
||||
Name propertyName = Name.identifier(name);
|
||||
JetScope memberScope = packageView.getMemberScope();
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName);
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, Location.NOWHERE);
|
||||
if (properties.isEmpty()) {
|
||||
for (DeclarationDescriptor descriptor : memberScope.getAllDescriptors()) {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
Collection<VariableDescriptor> classProperties =
|
||||
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList())
|
||||
.getProperties(propertyName);
|
||||
.getProperties(propertyName, Location.NOWHERE);
|
||||
if (!classProperties.isEmpty()) {
|
||||
properties = classProperties;
|
||||
break;
|
||||
@@ -197,7 +198,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
|
||||
Name propertyName = Name.identifier(name);
|
||||
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName);
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, Location.NOWHERE);
|
||||
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName();
|
||||
return (PropertyDescriptor) properties.iterator().next();
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class DescriptorValidator {
|
||||
public Void visitVariableDescriptor(
|
||||
VariableDescriptor descriptor, JetScope scope
|
||||
) {
|
||||
assertFound(scope, descriptor, scope.getProperties(descriptor.getName()));
|
||||
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), Location.NOWHERE));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude.NonExtensions
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
@@ -296,7 +297,7 @@ public abstract class LazyJavaMemberScope(
|
||||
return propertyType
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> = properties(name)
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> = properties(name)
|
||||
|
||||
override fun getOwnDeclaredDescriptors() = getDescriptors()
|
||||
|
||||
|
||||
+17
-11
@@ -16,18 +16,24 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.lazy.findClassInJava
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptorKindExclude
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.lazy.findClassInJava
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
public class LazyPackageFragmentScopeForJavaPackage(
|
||||
c: LazyJavaResolverContext,
|
||||
@@ -66,7 +72,7 @@ public class LazyPackageFragmentScopeForJavaPackage(
|
||||
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? = classes(name)
|
||||
|
||||
override fun getProperties(name: Name) = deserializedPackageScope().getProperties(name)
|
||||
override fun getProperties(name: Name, location: Location) = deserializedPackageScope().getProperties(name)
|
||||
override fun getFunctions(name: Name) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
|
||||
|
||||
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
@@ -51,7 +52,7 @@ class FunctionClassScope(
|
||||
return allDescriptors().filterIsInstance<FunctionDescriptor>().filter { it.getName() == name }
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> {
|
||||
return allDescriptors().filterIsInstance<PropertyDescriptor>().filter { it.getName() == name }
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -25,10 +25,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl;
|
||||
import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass;
|
||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||
import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
@@ -195,14 +192,14 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name, @NotNull Location location) {
|
||||
return (Collection) properties.invoke(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
private Collection<PropertyDescriptor> computeProperties(@NotNull Name name) {
|
||||
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name));
|
||||
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, Location.NOWHERE));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -270,7 +267,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
Collection<DeclarationDescriptor> result = new HashSet<DeclarationDescriptor>();
|
||||
for (Name name : enumMemberNames.invoke()) {
|
||||
result.addAll(getFunctions(name));
|
||||
result.addAll(getProperties(name));
|
||||
result.addAll(getProperties(name, Location.NOWHERE));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class AbstractScopeAdapter : JetScope {
|
||||
return workerScope.getClassifier(name)
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> {
|
||||
return workerScope.getProperties(name)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public open class ChainedScope(
|
||||
override fun getPackage(name: Name): PackageViewDescriptor?
|
||||
= getFirstMatch { it.getPackage(name) }
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor>
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor>
|
||||
= getFromAllScopes { it.getProperties(name) }
|
||||
|
||||
override fun getLocalVariable(name: Name): VariableDescriptor?
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ExplicitImportsScope(private val descriptors: Collection<Declaratio
|
||||
|
||||
override fun getPackage(name: Name)= descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<PackageViewDescriptor>()
|
||||
|
||||
override fun getProperties(name: Name) = descriptors.filter { it.getName() == name }.filterIsInstance<VariableDescriptor>()
|
||||
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>()
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
|
||||
|
||||
override fun getClassifier(name: Name) = filterDescriptor(workerScope.getClassifier(name))
|
||||
|
||||
override fun getProperties(name: Name) = workerScope.getProperties(name).filter(predicate)
|
||||
override fun getProperties(name: Name, location: Location) = workerScope.getProperties(name).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = workerScope.getSyntheticExtensionProperties(receiverTypes, name).filter(predicate)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface JetScope {
|
||||
|
||||
public fun getPackage(name: Name): PackageViewDescriptor?
|
||||
|
||||
public fun getProperties(name: Name): Collection<VariableDescriptor>
|
||||
public fun getProperties(name: Name, location: Location = Location.NOWHERE): Collection<VariableDescriptor>
|
||||
|
||||
public fun getLocalVariable(name: Name): VariableDescriptor?
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
public abstract class JetScopeImpl : JetScope {
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? = null
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> = setOf()
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> = setOf()
|
||||
|
||||
override fun getLocalVariable(name: Name): VariableDescriptor? = null
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name) = substitute(workerScope.getProperties(name))
|
||||
override fun getProperties(name: Name, location: Location) = substitute(workerScope.getProperties(name))
|
||||
|
||||
override fun getLocalVariable(name: Name) = substitute(workerScope.getLocalVariable(name))
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.*;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
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.error.ErrorSimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.utils.Printer;
|
||||
@@ -87,7 +88,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name, @NotNull Location location) {
|
||||
return ERROR_VARIABLE_GROUP;
|
||||
}
|
||||
|
||||
@@ -191,7 +192,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name, @NotNull Location location) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,11 +20,11 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.util.ArrayList
|
||||
@@ -104,7 +104,7 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name): Collection<VariableDescriptor> = properties.invoke(name)
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> = properties.invoke(name)
|
||||
|
||||
override fun getClassifier(name: Name) = getClassDescriptor(name)
|
||||
|
||||
|
||||
+2
-1
@@ -60,6 +60,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -147,7 +148,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
||||
else if (declaration instanceof JetProperty) {
|
||||
JetProperty jetProperty = (JetProperty) declaration;
|
||||
Name name = jetProperty.getNameAsSafeName();
|
||||
Collection<VariableDescriptor> properties = packageDescriptor.getMemberScope().getProperties(name);
|
||||
Collection<VariableDescriptor> properties = packageDescriptor.getMemberScope().getProperties(name, Location.NOWHERE);
|
||||
for (VariableDescriptor descriptor : properties) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||
}
|
||||
|
||||
+3
-2
@@ -74,6 +74,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
@@ -579,7 +580,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
Name newName = Name.identifier(info.getNewName());
|
||||
Collection<? extends CallableDescriptor> conflicts = oldDescriptor instanceof FunctionDescriptor
|
||||
? callableScope.getFunctions(newName)
|
||||
: callableScope.getProperties(newName);
|
||||
: callableScope.getProperties(newName, Location.NOWHERE);
|
||||
for (CallableDescriptor conflict : conflicts) {
|
||||
if (conflict == oldDescriptor) continue;
|
||||
|
||||
@@ -602,7 +603,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
}
|
||||
if (parametersScope != null) {
|
||||
if (kind == JetMethodDescriptor.Kind.PRIMARY_CONSTRUCTOR && valOrVar != JetValVar.None) {
|
||||
for (VariableDescriptor property : parametersScope.getProperties(Name.identifier(parameterName))) {
|
||||
for (VariableDescriptor property : parametersScope.getProperties(Name.identifier(parameterName), Location.NOWHERE)) {
|
||||
PsiElement propertyDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(property);
|
||||
|
||||
if (propertyDeclaration != null && !(propertyDeclaration.getParent() instanceof JetParameterList)) {
|
||||
|
||||
Reference in New Issue
Block a user