Get rid of unneeded additional map in JavaToKotlinClassMap
This commit is contained in:
+17
-10
@@ -34,7 +34,6 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
|||||||
|
|
||||||
private final Map<FqName, ClassDescriptor> classDescriptorMap = new HashMap<FqName, ClassDescriptor>();
|
private final Map<FqName, ClassDescriptor> classDescriptorMap = new HashMap<FqName, ClassDescriptor>();
|
||||||
private final Map<FqName, ClassDescriptor> classDescriptorMapForCovariantPositions = new HashMap<FqName, ClassDescriptor>();
|
private final Map<FqName, ClassDescriptor> classDescriptorMapForCovariantPositions = new HashMap<FqName, ClassDescriptor>();
|
||||||
private final Set<ClassDescriptor> allKotlinClasses = new LinkedHashSet<ClassDescriptor>();
|
|
||||||
|
|
||||||
private JavaToKotlinClassMap() {
|
private JavaToKotlinClassMap() {
|
||||||
init();
|
init();
|
||||||
@@ -45,12 +44,8 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
|||||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||||
|
|
||||||
for (JvmPrimitiveType jvmType : JvmPrimitiveType.values()) {
|
for (JvmPrimitiveType jvmType : JvmPrimitiveType.values()) {
|
||||||
PrimitiveType type = jvmType.getPrimitiveType();
|
register(jvmType.getWrapperFqName(), builtIns.getPrimitiveClassDescriptor(jvmType.getPrimitiveType()));
|
||||||
register(jvmType.getWrapperFqName(), builtIns.getPrimitiveClassDescriptor(type));
|
|
||||||
allKotlinClasses.add(builtIns.getPrimitiveArrayClassDescriptor(type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allKotlinClasses.add(builtIns.getUnit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -89,12 +84,10 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
|||||||
|
|
||||||
private void register(@NotNull FqName javaClassName, @NotNull ClassDescriptor kotlinDescriptor) {
|
private void register(@NotNull FqName javaClassName, @NotNull ClassDescriptor kotlinDescriptor) {
|
||||||
classDescriptorMap.put(javaClassName, kotlinDescriptor);
|
classDescriptorMap.put(javaClassName, kotlinDescriptor);
|
||||||
allKotlinClasses.add(kotlinDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerCovariant(@NotNull FqName javaClassName, @NotNull ClassDescriptor kotlinDescriptor) {
|
private void registerCovariant(@NotNull FqName javaClassName, @NotNull ClassDescriptor kotlinDescriptor) {
|
||||||
classDescriptorMapForCovariantPositions.put(javaClassName, kotlinDescriptor);
|
classDescriptorMapForCovariantPositions.put(javaClassName, kotlinDescriptor);
|
||||||
allKotlinClasses.add(kotlinDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -121,8 +114,22 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
|||||||
return mapPlatformClass(className.toSafe());
|
return mapPlatformClass(className.toSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: get rid of this method, it's unclear what it does
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<ClassDescriptor> allKotlinClasses() {
|
public List<ClassDescriptor> allKotlinClasses() {
|
||||||
return Collections.unmodifiableSet(allKotlinClasses);
|
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||||
|
|
||||||
|
List<ClassDescriptor> result = new ArrayList<ClassDescriptor>();
|
||||||
|
result.addAll(classDescriptorMap.values());
|
||||||
|
result.addAll(classDescriptorMapForCovariantPositions.values());
|
||||||
|
|
||||||
|
for (PrimitiveType type : PrimitiveType.values()) {
|
||||||
|
result.add(builtIns.getPrimitiveArrayClassDescriptor(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(builtIns.getUnit());
|
||||||
|
result.add(builtIns.getNothing());
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -24,7 +24,6 @@ import com.intellij.psi.search.GlobalSearchScope
|
|||||||
import com.intellij.psi.util.CachedValueProvider
|
import com.intellij.psi.util.CachedValueProvider
|
||||||
import com.intellij.psi.util.CachedValuesManager
|
import com.intellij.psi.util.CachedValuesManager
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
@@ -49,7 +48,7 @@ class AllClassesCompletion(val parameters: CompletionParameters,
|
|||||||
val visibilityFilter: (DeclarationDescriptor) -> Boolean) {
|
val visibilityFilter: (DeclarationDescriptor) -> Boolean) {
|
||||||
fun collect(result: LookupElementsCollector) {
|
fun collect(result: LookupElementsCollector) {
|
||||||
//TODO: this is a temporary hack until we have built-ins in indices
|
//TODO: this is a temporary hack until we have built-ins in indices
|
||||||
val builtIns = JavaToKotlinClassMap.INSTANCE.allKotlinClasses() + listOf(KotlinBuiltIns.getInstance().getNothing())
|
val builtIns = JavaToKotlinClassMap.INSTANCE.allKotlinClasses()
|
||||||
val filteredBuiltIns = builtIns.filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) }
|
val filteredBuiltIns = builtIns.filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) }
|
||||||
result.addDescriptorElements(filteredBuiltIns, suppressAutoInsertion = true)
|
result.addDescriptorElements(filteredBuiltIns, suppressAutoInsertion = true)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user