Removed ex-ModuleConfiguration classes.
This commit is contained in:
+8
-2
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java;
|
|||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.psi.PsiFile;
|
import com.intellij.psi.PsiFile;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -26,7 +27,6 @@ import org.jetbrains.jet.analyzer.AnalyzerFacade;
|
|||||||
import org.jetbrains.jet.analyzer.AnalyzerFacadeForEverything;
|
import org.jetbrains.jet.analyzer.AnalyzerFacadeForEverything;
|
||||||
import org.jetbrains.jet.di.InjectorForJavaDescriptorResolver;
|
import org.jetbrains.jet.di.InjectorForJavaDescriptorResolver;
|
||||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
@@ -47,6 +47,12 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
|||||||
|
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
public static final List<ImportPath> DEFAULT_IMPORTS = ImmutableList.of(
|
||||||
|
new ImportPath("java.lang.*"),
|
||||||
|
new ImportPath("kotlin.*"),
|
||||||
|
new ImportPath("kotlin.io.*"),
|
||||||
|
new ImportPath("jet.*"));
|
||||||
|
|
||||||
private AnalyzerFacadeForJVM() {
|
private AnalyzerFacadeForJVM() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +201,6 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ModuleDescriptorImpl createJavaModule(@NotNull String name) {
|
public static ModuleDescriptorImpl createJavaModule(@NotNull String name) {
|
||||||
return new ModuleDescriptorImpl(Name.special(name), JavaBridgeConfiguration.ALL_JAVA_IMPORTS, JavaToKotlinClassMap.getInstance());
|
return new ModuleDescriptorImpl(Name.special(name), DEFAULT_IMPORTS, JavaToKotlinClassMap.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.java;
|
|
||||||
|
|
||||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class JavaBridgeConfiguration {
|
|
||||||
|
|
||||||
public static final List<ImportPath> DEFAULT_JAVA_IMPORTS = Collections.unmodifiableList(Arrays.asList(new ImportPath("java.lang.*")));
|
|
||||||
public static final List<ImportPath> ALL_JAVA_IMPORTS;
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<ImportPath> allJavaImports = new ArrayList<ImportPath>();
|
|
||||||
allJavaImports.addAll(DEFAULT_JAVA_IMPORTS);
|
|
||||||
allJavaImports.addAll(DefaultModuleConfiguration.DEFAULT_JET_IMPORTS);
|
|
||||||
ALL_JAVA_IMPORTS = Collections.unmodifiableList(allJavaImports);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.lang;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DefaultModuleConfiguration {
|
|
||||||
public static final List<ImportPath> DEFAULT_JET_IMPORTS = ImmutableList.of(
|
|
||||||
new ImportPath("kotlin.*"),
|
|
||||||
new ImportPath("kotlin.io.*"),
|
|
||||||
new ImportPath("jet.*"));
|
|
||||||
|
|
||||||
private DefaultModuleConfiguration() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,16 +20,15 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
|
||||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.MutablePackageFragmentDescriptor;
|
import org.jetbrains.jet.lang.descriptors.impl.MutablePackageFragmentDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
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.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.name.SpecialNames;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||||
@@ -128,7 +127,7 @@ public class KotlinBuiltIns {
|
|||||||
private KotlinBuiltIns() {
|
private KotlinBuiltIns() {
|
||||||
try {
|
try {
|
||||||
this.builtInsModule = new ModuleDescriptorImpl(Name.special("<built-ins lazy module>"),
|
this.builtInsModule = new ModuleDescriptorImpl(Name.special("<built-ins lazy module>"),
|
||||||
DefaultModuleConfiguration.DEFAULT_JET_IMPORTS,
|
Collections.<ImportPath>emptyList(),
|
||||||
PlatformToKotlinClassMap.EMPTY);
|
PlatformToKotlinClassMap.EMPTY);
|
||||||
loadBuiltIns(builtInsModule);
|
loadBuiltIns(builtInsModule);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ public class JetDeclarationRemotenessWeigher extends LookupElementWeigher {
|
|||||||
return MyResult.notImported;
|
return MyResult.notImported;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ImportInsertHelper.isImportedWithKotlinDefault(importPath)) {
|
if (ImportInsertHelper.isImportedWithDefault(importPath, file)) {
|
||||||
return MyResult.kotlinDefaultImport;
|
return MyResult.kotlinDefaultImport;
|
||||||
}
|
}
|
||||||
return MyResult.imported;
|
return MyResult.imported;
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.annotations.TestOnly;
|
import org.jetbrains.annotations.TestOnly;
|
||||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||||
import org.jetbrains.jet.codegen.binding.PsiCodegenPredictor;
|
import org.jetbrains.jet.codegen.binding.PsiCodegenPredictor;
|
||||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
|
||||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||||
import org.jetbrains.jet.lang.resolve.java.mapping.KotlinToJavaTypesMap;
|
import org.jetbrains.jet.lang.resolve.java.mapping.KotlinToJavaTypesMap;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||||
@@ -222,7 +222,7 @@ public class JetSourceNavigationHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ModuleDescriptorImpl moduleDescriptor = new ModuleDescriptorImpl(Name.special("<library module>"),
|
ModuleDescriptorImpl moduleDescriptor = new ModuleDescriptorImpl(Name.special("<library module>"),
|
||||||
DefaultModuleConfiguration.DEFAULT_JET_IMPORTS,
|
AnalyzerFacadeForJVM.DEFAULT_IMPORTS,
|
||||||
PlatformToKotlinClassMap.EMPTY);
|
PlatformToKotlinClassMap.EMPTY);
|
||||||
KotlinCodeAnalyzer analyzer = new ResolveSession(
|
KotlinCodeAnalyzer analyzer = new ResolveSession(
|
||||||
project,
|
project,
|
||||||
|
|||||||
@@ -22,18 +22,17 @@ import com.intellij.openapi.editor.Document;
|
|||||||
import com.intellij.openapi.util.TextRange;
|
import com.intellij.openapi.util.TextRange;
|
||||||
import com.intellij.psi.*;
|
import com.intellij.psi.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaBridgeConfiguration;
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.plugin.project.ProjectStructureUtil;
|
import org.jetbrains.jet.plugin.project.ProjectStructureUtil;
|
||||||
import org.jetbrains.jet.plugin.references.JetPsiReference;
|
import org.jetbrains.jet.plugin.references.JetPsiReference;
|
||||||
import org.jetbrains.jet.util.QualifiedNamesUtil;
|
import org.jetbrains.jet.util.QualifiedNamesUtil;
|
||||||
import org.jetbrains.k2js.analyze.JsConfiguration;
|
import org.jetbrains.k2js.analyze.AnalyzerFacadeForJS;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -135,26 +134,14 @@ public class ImportInsertHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImportedWithKotlinDefault(importPath)) return true;
|
return isImportedWithDefault(importPath, jetFile);
|
||||||
|
|
||||||
if (ProjectStructureUtil.isJsKotlinModule(jetFile)) {
|
|
||||||
return isImportedWithJsDefault(importPath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return isImportedWithJavaDefault(importPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isImportedWithJavaDefault(ImportPath importPath) {
|
public static boolean isImportedWithDefault(@NotNull ImportPath importPath, @NotNull JetFile contextFile) {
|
||||||
return QualifiedNamesUtil.isImported(JavaBridgeConfiguration.DEFAULT_JAVA_IMPORTS, importPath);
|
List<ImportPath> defaultImports = ProjectStructureUtil.isJsKotlinModule(contextFile)
|
||||||
}
|
? AnalyzerFacadeForJS.DEFAULT_IMPORTS
|
||||||
|
: AnalyzerFacadeForJVM.DEFAULT_IMPORTS;
|
||||||
public static boolean isImportedWithJsDefault(ImportPath importPath) {
|
return QualifiedNamesUtil.isImported(defaultImports, importPath);
|
||||||
return QualifiedNamesUtil.isImported(JsConfiguration.DEFAULT_IMPORT_PATHS, importPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isImportedWithKotlinDefault(ImportPath importPath) {
|
|
||||||
return QualifiedNamesUtil.isImported(DefaultModuleConfiguration.DEFAULT_JET_IMPORTS, importPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doNeedImport(@NotNull ImportPath importPath, @NotNull JetFile file) {
|
public static boolean doNeedImport(@NotNull ImportPath importPath, @NotNull JetFile file) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.k2js.analyze;
|
|||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.psi.PsiFile;
|
import com.intellij.psi.PsiFile;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,6 +36,7 @@ import org.jetbrains.jet.lang.resolve.lazy.declarations.FileBasedDeclarationProv
|
|||||||
import org.jetbrains.jet.lang.resolve.lazy.storage.LockBasedLazyResolveStorageManager;
|
import org.jetbrains.jet.lang.resolve.lazy.storage.LockBasedLazyResolveStorageManager;
|
||||||
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;
|
||||||
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.k2js.config.Config;
|
import org.jetbrains.k2js.config.Config;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -42,6 +44,11 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class AnalyzerFacadeForJS {
|
public final class AnalyzerFacadeForJS {
|
||||||
|
public static final List<ImportPath> DEFAULT_IMPORTS = ImmutableList.of(
|
||||||
|
new ImportPath("js.*"),
|
||||||
|
new ImportPath("java.lang.*"),
|
||||||
|
new ImportPath("jet.*"),
|
||||||
|
new ImportPath("kotlin.*"));
|
||||||
|
|
||||||
private AnalyzerFacadeForJS() {
|
private AnalyzerFacadeForJS() {
|
||||||
}
|
}
|
||||||
@@ -152,7 +159,7 @@ public final class AnalyzerFacadeForJS {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static ModuleDescriptorImpl createJsModule(@NotNull String name) {
|
private static ModuleDescriptorImpl createJsModule(@NotNull String name) {
|
||||||
return new ModuleDescriptorImpl(Name.special(name), JsConfiguration.DEFAULT_IMPORT_PATHS, PlatformToKotlinClassMap.EMPTY);
|
return new ModuleDescriptorImpl(Name.special(name), DEFAULT_IMPORTS, PlatformToKotlinClassMap.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.k2js.analyze;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class JsConfiguration {
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static final List<ImportPath> DEFAULT_IMPORT_PATHS = ImmutableList.of(
|
|
||||||
new ImportPath("js.*"),
|
|
||||||
new ImportPath("java.lang.*"),
|
|
||||||
new ImportPath(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName(), true),
|
|
||||||
new ImportPath("kotlin.*"));
|
|
||||||
|
|
||||||
JsConfiguration() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user