DefaultModuleConfiguration made a singleton, ALL_JAVA_IMPORTS constant introduced
This commit is contained in:
+6
-15
@@ -17,8 +17,6 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.java;
|
package org.jetbrains.jet.lang.resolve.java;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||||
@@ -29,34 +27,27 @@ import org.jetbrains.jet.lang.resolve.ImportPath;
|
|||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class JavaBridgeConfiguration implements ModuleConfiguration {
|
public class JavaBridgeConfiguration implements ModuleConfiguration {
|
||||||
|
|
||||||
public static final List<ImportPath> DEFAULT_JAVA_IMPORTS = ImmutableList.of(new ImportPath("java.lang.*"));
|
public static final List<ImportPath> DEFAULT_JAVA_IMPORTS = ImmutableList.of(new ImportPath("java.lang.*"));
|
||||||
|
public static final List<ImportPath> ALL_JAVA_IMPORTS = ImmutableList.<ImportPath>builder()
|
||||||
|
.addAll(DEFAULT_JAVA_IMPORTS)
|
||||||
|
.addAll(DefaultModuleConfiguration.DEFAULT_JET_IMPORTS)
|
||||||
|
.build();
|
||||||
|
|
||||||
private JavaSemanticServices javaSemanticServices;
|
private JavaSemanticServices javaSemanticServices;
|
||||||
private ModuleConfiguration delegateConfiguration;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public void setJavaSemanticServices(@NotNull JavaSemanticServices javaSemanticServices) {
|
public void setJavaSemanticServices(@NotNull JavaSemanticServices javaSemanticServices) {
|
||||||
this.javaSemanticServices = javaSemanticServices;
|
this.javaSemanticServices = javaSemanticServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
this.delegateConfiguration = DefaultModuleConfiguration.createStandardConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImportPath> getDefaultImports() {
|
public List<ImportPath> getDefaultImports() {
|
||||||
Set<ImportPath> imports = Sets.newLinkedHashSet(DEFAULT_JAVA_IMPORTS);
|
return ALL_JAVA_IMPORTS;
|
||||||
imports.addAll(delegateConfiguration.getDefaultImports());
|
|
||||||
|
|
||||||
return Lists.newArrayList(imports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,7 +56,7 @@ public class JavaBridgeConfiguration implements ModuleConfiguration {
|
|||||||
if (javaPackageScope != null) {
|
if (javaPackageScope != null) {
|
||||||
namespaceMemberScope.importScope(javaPackageScope);
|
namespaceMemberScope.importScope(javaPackageScope);
|
||||||
}
|
}
|
||||||
delegateConfiguration.extendNamespaceScope(trace, namespaceDescriptor, namespaceMemberScope);
|
DefaultModuleConfiguration.INSTANCE.extendNamespaceScope(trace, namespaceDescriptor, namespaceMemberScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ public class DefaultModuleConfiguration implements ModuleConfiguration {
|
|||||||
new ImportPath("kotlin.io.*"),
|
new ImportPath("kotlin.io.*"),
|
||||||
new ImportPath("jet.*"));
|
new ImportPath("jet.*"));
|
||||||
|
|
||||||
public static DefaultModuleConfiguration createStandardConfiguration() {
|
public static final ModuleConfiguration INSTANCE = new DefaultModuleConfiguration();
|
||||||
return new DefaultModuleConfiguration();
|
|
||||||
|
public static ModuleConfiguration createStandardConfiguration() {
|
||||||
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefaultModuleConfiguration() {
|
private DefaultModuleConfiguration() {
|
||||||
|
|||||||
Reference in New Issue
Block a user