Fix objects appearing in type position in completion
After the object refactoring they're present as classes in scopes, not as object descriptors
This commit is contained in:
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorBase;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetNamed;
|
import org.jetbrains.jet.lang.psi.JetNamed;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
@@ -46,10 +45,7 @@ public class ResolveSessionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Collection<ClassDescriptor> getClassDescriptorsByFqName(
|
public static Collection<ClassDescriptor> getClassDescriptorsByFqName(@NotNull KotlinCodeAnalyzer analyzer, @NotNull FqName fqName) {
|
||||||
@NotNull KotlinCodeAnalyzer analyzer,
|
|
||||||
@NotNull FqName fqName
|
|
||||||
) {
|
|
||||||
return getClassOrObjectDescriptorsByFqName(analyzer, fqName, false);
|
return getClassOrObjectDescriptorsByFqName(analyzer, fqName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +82,10 @@ public class ResolveSessionUtils {
|
|||||||
return classDescriptors;
|
return classDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private static Collection<ClassDescriptor> getClassOrObjectDescriptorsByFqName(
|
private static Collection<ClassDescriptor> getClassOrObjectDescriptorsByFqName(
|
||||||
NamespaceDescriptor packageDescriptor,
|
@NotNull NamespaceDescriptor packageDescriptor,
|
||||||
FqName path,
|
@NotNull FqName path,
|
||||||
boolean includeObjectDeclarations
|
boolean includeObjectDeclarations
|
||||||
) {
|
) {
|
||||||
if (path.isRoot()) {
|
if (path.isRoot()) {
|
||||||
@@ -103,9 +100,8 @@ public class ResolveSessionUtils {
|
|||||||
Collection<JetScope> tempScopes = Lists.newArrayList();
|
Collection<JetScope> tempScopes = Lists.newArrayList();
|
||||||
for (JetScope scope : scopes) {
|
for (JetScope scope : scopes) {
|
||||||
ClassifierDescriptor classifier = scope.getClassifier(subName);
|
ClassifierDescriptor classifier = scope.getClassifier(subName);
|
||||||
if (classifier instanceof ClassDescriptorBase) {
|
if (classifier instanceof ClassDescriptor) {
|
||||||
ClassDescriptorBase classDescriptor = (ClassDescriptorBase) classifier;
|
tempScopes.add(((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope());
|
||||||
tempScopes.add(classDescriptor.getUnsubstitutedInnerClassesScope());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scopes = tempScopes;
|
scopes = tempScopes;
|
||||||
@@ -116,15 +112,10 @@ public class ResolveSessionUtils {
|
|||||||
Collection<ClassDescriptor> resultClassifierDescriptors = Lists.newArrayList();
|
Collection<ClassDescriptor> resultClassifierDescriptors = Lists.newArrayList();
|
||||||
for (JetScope scope : scopes) {
|
for (JetScope scope : scopes) {
|
||||||
ClassifierDescriptor classifier = scope.getClassifier(shortName);
|
ClassifierDescriptor classifier = scope.getClassifier(shortName);
|
||||||
if (classifier instanceof ClassDescriptor) {
|
if (classifier instanceof ClassDescriptor &&
|
||||||
|
includeObjectDeclarations == ((ClassDescriptor) classifier).getKind().isSingleton()) {
|
||||||
resultClassifierDescriptors.add((ClassDescriptor) classifier);
|
resultClassifierDescriptors.add((ClassDescriptor) classifier);
|
||||||
}
|
}
|
||||||
if (includeObjectDeclarations) {
|
|
||||||
ClassDescriptor objectDescriptor = scope.getObjectDescriptor(shortName);
|
|
||||||
if (objectDescriptor != null) {
|
|
||||||
resultClassifierDescriptors.add(objectDescriptor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultClassifierDescriptors;
|
return resultClassifierDescriptors;
|
||||||
@@ -132,8 +123,7 @@ public class ResolveSessionUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Name safeNameForLazyResolve(@NotNull JetNamed named) {
|
public static Name safeNameForLazyResolve(@NotNull JetNamed named) {
|
||||||
Name name = named.getNameAsName();
|
return safeNameForLazyResolve(named.getNameAsName());
|
||||||
return safeNameForLazyResolve(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user