add 'getKotlinAnalogs' to ModuleConfiguration
This commit is contained in:
+11
-5
@@ -21,18 +21,21 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -42,13 +45,9 @@ public class JavaBridgeConfiguration implements ModuleConfiguration {
|
||||
public static final ImportPath[] DEFAULT_JAVA_IMPORTS = new ImportPath[] { new ImportPath("java.lang.*") };
|
||||
|
||||
|
||||
@NotNull
|
||||
private Project project;
|
||||
@NotNull
|
||||
private JavaSemanticServices javaSemanticServices;
|
||||
@NotNull
|
||||
private ModuleConfiguration delegateConfiguration;
|
||||
@NotNull
|
||||
private BuiltinsScopeExtensionMode builtinsScopeExtensionMode;
|
||||
|
||||
@Inject
|
||||
@@ -90,5 +89,12 @@ public class JavaBridgeConfiguration implements ModuleConfiguration {
|
||||
delegateConfiguration.extendNamespaceScope(trace, namespaceDescriptor, namespaceMemberScope);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
if (className.isSafe()) {
|
||||
return JavaToKotlinTypesMap.getInstance().getAllKotlinAnalogs(className.toSafe());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
+19
-3
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.java;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -28,9 +29,7 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -124,4 +123,21 @@ public class JavaToKotlinTypesMap {
|
||||
mappedTypeNames.add(javaClassName.getFqName());
|
||||
classDescriptorMapForCovariantPositions.put(javaClassName, kotlinDescriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<ClassDescriptor> getAllKotlinAnalogs(@NotNull FqName fqName) {
|
||||
ClassDescriptor kotlinAnalog = classDescriptorMap.get(fqName);
|
||||
ClassDescriptor kotlinCovariantAnalog = classDescriptorMapForCovariantPositions.get(fqName);
|
||||
if (kotlinAnalog == null && kotlinCovariantAnalog == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ArrayList<ClassDescriptor> descriptors = Lists.newArrayList();
|
||||
if (kotlinAnalog != null) {
|
||||
descriptors.add(kotlinAnalog);
|
||||
}
|
||||
if (kotlinCovariantAnalog != null) {
|
||||
descriptors.add(kotlinCovariantAnalog);
|
||||
}
|
||||
return descriptors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,20 @@ package org.jetbrains.jet.lang;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -70,4 +73,10 @@ public class DefaultModuleConfiguration implements ModuleConfiguration {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
package org.jetbrains.jet.lang;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -37,6 +40,11 @@ public interface ModuleConfiguration {
|
||||
public void extendNamespaceScope(@NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor, @NotNull WritableScope namespaceMemberScope) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
|
||||
void addDefaultImports(@NotNull Collection<JetImportDirective> directives);
|
||||
@@ -47,4 +55,6 @@ public interface ModuleConfiguration {
|
||||
*/
|
||||
void extendNamespaceScope(@NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor, @NotNull WritableScope namespaceMemberScope);
|
||||
|
||||
@NotNull
|
||||
Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.test.util.NamespaceComparator;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
@@ -45,6 +46,7 @@ import org.junit.Test;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -114,5 +116,11 @@ public class LazyResolveBuiltinClassesTest extends KotlinTestWithEnvironment {
|
||||
@NotNull WritableScope namespaceMemberScope) {
|
||||
// DO nothing
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -37,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPackageScope;
|
||||
import org.jetbrains.jet.lang.resolve.java.PsiClassFinder;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
@@ -115,6 +117,12 @@ public class LazyResolveTestUtil {
|
||||
namespaceMemberScope.importScope(javaPackageScope);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
|
||||
ModuleDescriptor lazyModule = new ModuleDescriptor(Name.special("<lazy module>"));
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.di.InjectorForJavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
@@ -50,6 +51,7 @@ import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.FileBasedDeclarationProviderFactory;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
@@ -106,6 +108,7 @@ public final class AnalyzerFacadeWithCache {
|
||||
AnalyzeExhaust analyzeExhaustHeaders = analyzeHeadersWithCacheOnFile(file, declarationProvider);
|
||||
|
||||
BodiesResolveContext context = analyzeExhaustHeaders.getBodiesResolveContext();
|
||||
ModuleConfiguration moduleConfiguration = analyzeExhaustHeaders.getModuleConfiguration();
|
||||
assert context != null : "Headers resolver should prepare and stored information for bodies resolve";
|
||||
|
||||
// Need to resolve bodies in given file and all in the same package
|
||||
@@ -114,7 +117,8 @@ public final class AnalyzerFacadeWithCache {
|
||||
Collections.<AnalyzerScriptParameter>emptyList(),
|
||||
new JetFilesProvider.SameJetFilePredicate(file),
|
||||
new DelegatingBindingTrace(analyzeExhaustHeaders.getBindingContext()),
|
||||
context);
|
||||
context,
|
||||
moduleConfiguration);
|
||||
|
||||
return new Result<AnalyzeExhaust>(exhaust, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
@@ -236,6 +240,12 @@ public final class AnalyzerFacadeWithCache {
|
||||
namespaceMemberScope.importScope(javaPackageScope);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
|
||||
ModuleDescriptor lazyModule = new ModuleDescriptor(Name.special("<lazy module>"));
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
@@ -30,11 +31,13 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isRootNamespace;
|
||||
@@ -102,4 +105,10 @@ public final class JsConfiguration implements ModuleConfiguration {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> getKotlinAnalogs(@NotNull FqNameUnsafe className) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user