DescriptorFinder now can find class names in a package
This helps to get rid of "repeated class_name" field in Package protobuf message. DescriptorFinder in resolve.java uses PSI to find all classes in a package, and the finder for built-ins just reads .kotlin_class_names file
This commit is contained in:
+8
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.resolve.java.AbiVersionUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
|
||||
@@ -42,6 +43,7 @@ import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.ClassReader.*;
|
||||
@@ -75,6 +77,12 @@ public final class DeserializedDescriptorResolver {
|
||||
public NamespaceDescriptor findPackage(@NotNull FqName name) {
|
||||
return javaNamespaceResolver.resolveNamespace(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Name> getClassNames(@NotNull FqName packageName) {
|
||||
return javaNamespaceResolver.getClassNamesInPackage(packageName);
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
|
||||
+18
-3
@@ -39,12 +39,11 @@ import org.jetbrains.jet.lang.resolve.java.scope.JavaClassStaticMembersScope;
|
||||
import org.jetbrains.jet.lang.resolve.java.scope.JavaPackageScopeWithoutMembers;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiClassWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.AbiVersionUtil.INVALID_VERSION;
|
||||
|
||||
@@ -273,4 +272,20 @@ public final class JavaNamespaceResolver {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<Name> getClassNamesInPackage(@NotNull FqName packageName) {
|
||||
PsiPackage psiPackage = psiClassFinder.findPsiPackage(packageName);
|
||||
if (psiPackage == null) return Collections.emptyList();
|
||||
|
||||
PsiClass[] classes = psiPackage.getClasses();
|
||||
List<Name> result = new ArrayList<Name>(classes.length);
|
||||
for (PsiClass psiClass : classes) {
|
||||
if (DescriptorResolverUtils.isKotlinClass(psiClass)) {
|
||||
result.add(Name.identifier(psiClass.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user