JDR: drop various code that is marked as temporary
Remove additional logic for comparing files in JavaClassFinderImpl Drop redundant check for builtins in findClassInJava(FqName) Drop resolve cache query in LazyJavaClassMemberScope and LazyJavaPackageFragmentScope
This commit is contained in:
-19
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
@@ -62,24 +61,6 @@ public class JavaClassFinderImpl implements JavaClassFinder {
|
||||
return myBaseScope.contains(file) && file.getFileType() != JetFileType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(VirtualFile file1, VirtualFile file2) {
|
||||
//TODO_r: delete this code?
|
||||
// TODO: this is a hackish workaround for the following problem:
|
||||
// since we are working with the allScope(), if the same class FqName
|
||||
// to be on the class path twice, because it is included into different libraries
|
||||
// (e.g. junit-4.0.jar is used as a separate library and as a part of idea_full)
|
||||
// the two libraries are attached to different modules, the parent compare()
|
||||
// can't tell which one comes first, so they can come in random order
|
||||
// To fix this, we sort additionally by the full path, to make the ordering deterministic
|
||||
// TODO: Delete this hack when proper scopes are used
|
||||
int compare = super.compare(file1, file2);
|
||||
if (compare == 0) {
|
||||
return Comparing.compare(file1.getPath(), file2.getPath());
|
||||
}
|
||||
return compare;
|
||||
}
|
||||
|
||||
//NOTE: expected by class finder to be not null
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
-11
@@ -24,16 +24,9 @@ import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSessionUtils
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.lang.types.TypeProjection
|
||||
import javax.inject.Inject
|
||||
import java.util.Collections
|
||||
import kotlin.properties.Delegates
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaClassImpl
|
||||
import com.google.common.base.Predicates
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PackageViewDescriptorImpl
|
||||
import org.jetbrains.jet.lang.resolve.name.tail
|
||||
import org.jetbrains.jet.lang.resolve.name.each
|
||||
|
||||
@@ -62,10 +55,6 @@ public class LazyResolveBasedCache() : JavaResolverCache {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClass(javaClass: JavaClass): ClassDescriptor? {
|
||||
return traceBasedCache.getClass(javaClass) ?: null
|
||||
}
|
||||
|
||||
override fun recordMethod(method: JavaMethod, descriptor: SimpleFunctionDescriptor) {
|
||||
traceBasedCache.recordMethod(method, descriptor)
|
||||
}
|
||||
|
||||
-10
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.java.resolver;
|
||||
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
@@ -27,8 +25,6 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaClass;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaField;
|
||||
@@ -57,12 +53,6 @@ public class TraceBasedJavaResolverCache implements JavaResolverCache {
|
||||
return trace.get(FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassDescriptor getClass(@NotNull JavaClass javaClass) {
|
||||
return trace.get(CLASS, ((JavaClassImpl) javaClass).getPsi());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordMethod(@NotNull JavaMethod method, @NotNull SimpleFunctionDescriptor descriptor) {
|
||||
BindingContextUtils.recordFunctionDeclarationToDescriptor(trace, ((JavaMethodImpl) method).getPsi(), descriptor);
|
||||
|
||||
+3
-9
@@ -231,15 +231,9 @@ public class LazyJavaClassMemberScope(
|
||||
else null
|
||||
}
|
||||
else {
|
||||
// TODO: this caching is a temporary workaround, should be replaced with properly caching the whole LazyJavaPackageFragmentProvider
|
||||
//TODO_R: remove this logic?
|
||||
val alreadyResolved = c.javaResolverCache.getClass(jNestedClass)
|
||||
if (alreadyResolved != null)
|
||||
alreadyResolved
|
||||
else LazyJavaClassDescriptor(c,
|
||||
getContainingDeclaration(),
|
||||
DescriptorUtils.getFqName(getContainingDeclaration()).child(name).toSafe(),
|
||||
jNestedClass)
|
||||
LazyJavaClassDescriptor(
|
||||
c, getContainingDeclaration(), DescriptorUtils.getFqName(getContainingDeclaration()).child(name).toSafe(), jNestedClass
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-10
@@ -114,16 +114,10 @@ public class LazyPackageFragmentScopeForJavaPackage(
|
||||
else if (jClass == null)
|
||||
null
|
||||
else {
|
||||
// TODO: this caching is a temporary workaround, should be replaced with properly caching the whole LazyJavaSubModule
|
||||
val cached = c.javaResolverCache.getClass(jClass)
|
||||
if (cached != null)
|
||||
cached
|
||||
else {
|
||||
val classDescriptor = c.javaClassResolver.resolveClass(jClass)
|
||||
assert(classDescriptor == null || classDescriptor.getContainingDeclaration() == packageFragment,
|
||||
"Wrong package fragment for $classDescriptor, expected $packageFragment")
|
||||
classDescriptor
|
||||
}
|
||||
val classDescriptor = c.javaClassResolver.resolveClass(jClass)
|
||||
assert(classDescriptor == null || classDescriptor.getContainingDeclaration() == packageFragment,
|
||||
"Wrong package fragment for $classDescriptor, expected $packageFragment")
|
||||
classDescriptor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,12 +75,6 @@ fun LazyJavaResolverContext.lookupBinaryClass(javaClass: JavaClass): ClassDescri
|
||||
}
|
||||
|
||||
fun LazyJavaResolverContext.findClassInJava(fqName: FqName): JavaClassLookupResult {
|
||||
// TODO: this should be governed by module separation logic
|
||||
// Do not look for JavaClasses for Kotlin binaries & built-ins
|
||||
if (DescriptorResolverUtils.getKotlinBuiltinClassDescriptor(fqName) != null) {
|
||||
return JavaClassLookupResult()
|
||||
}
|
||||
|
||||
val kotlinClass = kotlinClassFinder.findKotlinClass(fqName)
|
||||
val binaryClassResult = resolveBinaryClass(kotlinClass)
|
||||
if (binaryClassResult != null) return binaryClassResult
|
||||
|
||||
-18
@@ -287,22 +287,4 @@ public final class DescriptorResolverUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getKotlinBuiltinClassDescriptor(@NotNull FqName qualifiedName) {
|
||||
if (!qualifiedName.firstSegmentIs(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) return null;
|
||||
|
||||
List<Name> segments = qualifiedName.pathSegments();
|
||||
if (segments.size() < 2) return null;
|
||||
|
||||
JetScope scope = KotlinBuiltIns.getInstance().getBuiltInsPackageScope();
|
||||
for (int i = 1, size = segments.size(); i < size; i++) {
|
||||
ClassifierDescriptor classifier = scope.getClassifier(segments.get(i));
|
||||
if (classifier == null) return null;
|
||||
assert classifier instanceof ClassDescriptor : "Unexpected classifier in built-ins: " + classifier;
|
||||
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
|
||||
}
|
||||
|
||||
return (ClassDescriptor) scope.getContainingDeclaration();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,7 +18,10 @@ package org.jetbrains.jet.lang.resolve.java.resolver;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaClass;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaField;
|
||||
@@ -29,9 +32,6 @@ public interface JavaResolverCache {
|
||||
@Nullable
|
||||
ClassDescriptor getClassResolvedFromSource(@NotNull FqName fqName);
|
||||
|
||||
@Nullable
|
||||
ClassDescriptor getClass(@NotNull JavaClass javaClass);
|
||||
|
||||
void recordMethod(@NotNull JavaMethod method, @NotNull SimpleFunctionDescriptor descriptor);
|
||||
|
||||
void recordConstructor(@NotNull JavaElement element, @NotNull ConstructorDescriptor descriptor);
|
||||
|
||||
Reference in New Issue
Block a user