proper environment when compiling special things
* do not include anything when compiling builtins * do not include kotlin-runtime and jdk-headers when compiling jdk-headers
This commit is contained in:
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaBridgeConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.java.PsiClassFinderForJvm;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer;
|
||||
import org.jetbrains.jet.lang.resolve.NamespaceFactoryImpl;
|
||||
@@ -47,6 +48,7 @@ public class InjectorForJavaSemanticServices {
|
||||
JavaBridgeConfiguration javaBridgeConfiguration = new JavaBridgeConfiguration();
|
||||
this.psiClassFinderForJvm = new PsiClassFinderForJvm();
|
||||
ModuleDescriptor moduleDescriptor = new org.jetbrains.jet.lang.descriptors.ModuleDescriptor("<dummy>");
|
||||
CompilerSpecialMode compilerSpecialMode = CompilerSpecialMode.REGULAR;
|
||||
this.project = project;
|
||||
JavaTypeTransformer javaTypeTransformer = new JavaTypeTransformer();
|
||||
NamespaceFactoryImpl namespaceFactoryImpl = new NamespaceFactoryImpl();
|
||||
@@ -63,6 +65,7 @@ public class InjectorForJavaSemanticServices {
|
||||
this.javaDescriptorResolver.setTrace(bindingTrace);
|
||||
|
||||
javaBridgeConfiguration.setJavaSemanticServices(javaSemanticServices);
|
||||
javaBridgeConfiguration.setMode(compilerSpecialMode);
|
||||
javaBridgeConfiguration.setProject(project);
|
||||
|
||||
this.psiClassFinderForJvm.setProject(project);
|
||||
@@ -74,6 +77,8 @@ public class InjectorForJavaSemanticServices {
|
||||
namespaceFactoryImpl.setModuleDescriptor(moduleDescriptor);
|
||||
namespaceFactoryImpl.setTrace(bindingTrace);
|
||||
|
||||
javaBridgeConfiguration.init();
|
||||
|
||||
psiClassFinderForJvm.initialize();
|
||||
|
||||
}
|
||||
|
||||
+7
-1
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaBridgeConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.java.PsiClassFinderForJvm;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
|
||||
@@ -51,6 +52,7 @@ import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/* This file is generated by org.jetbrains.jet.di.AllInjectorsGenerator. DO NOT EDIT! */
|
||||
@@ -72,7 +74,8 @@ public class InjectorForTopDownAnalyzerForJvm {
|
||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
||||
@NotNull ObservableBindingTrace observableBindingTrace,
|
||||
@NotNull ModuleDescriptor moduleDescriptor,
|
||||
JetControlFlowDataTraceFactory jetControlFlowDataTraceFactory
|
||||
JetControlFlowDataTraceFactory jetControlFlowDataTraceFactory,
|
||||
@NotNull CompilerSpecialMode compilerSpecialMode
|
||||
) {
|
||||
this.topDownAnalyzer = new TopDownAnalyzer();
|
||||
this.topDownAnalysisContext = new TopDownAnalysisContext();
|
||||
@@ -138,6 +141,7 @@ public class InjectorForTopDownAnalyzerForJvm {
|
||||
this.descriptorResolver.setTypeResolver(typeResolver);
|
||||
|
||||
this.javaBridgeConfiguration.setJavaSemanticServices(javaSemanticServices);
|
||||
this.javaBridgeConfiguration.setMode(compilerSpecialMode);
|
||||
this.javaBridgeConfiguration.setProject(project);
|
||||
|
||||
psiClassFinderForJvm.setProject(project);
|
||||
@@ -204,6 +208,8 @@ public class InjectorForTopDownAnalyzerForJvm {
|
||||
javaTypeTransformer.setJavaSemanticServices(javaSemanticServices);
|
||||
javaTypeTransformer.setResolver(javaDescriptorResolver);
|
||||
|
||||
javaBridgeConfiguration.init();
|
||||
|
||||
psiClassFinderForJvm.initialize();
|
||||
|
||||
}
|
||||
|
||||
+12
-6
@@ -84,7 +84,8 @@ public class AnalyzerFacadeForJVM {
|
||||
file.getProject(),
|
||||
declarationProvider.fun(file),
|
||||
Predicates.<PsiFile>equalTo(file),
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
JetControlFlowDataTraceFactory.EMPTY,
|
||||
CompilerSpecialMode.REGULAR);
|
||||
return new Result<AnalyzeExhaust>(bindingContext, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
@@ -123,7 +124,8 @@ public class AnalyzerFacadeForJVM {
|
||||
project,
|
||||
files,
|
||||
Predicates.<PsiFile>alwaysFalse(),
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
JetControlFlowDataTraceFactory.EMPTY,
|
||||
CompilerSpecialMode.REGULAR);
|
||||
return new Result<AnalyzeExhaust>(analyzeExhaust, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
@@ -156,12 +158,14 @@ public class AnalyzerFacadeForJVM {
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file), Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory);
|
||||
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file),
|
||||
Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory, CompilerSpecialMode.REGULAR);
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegration(
|
||||
Project project, Collection<JetFile> files, Predicate<PsiFile> filesToAnalyzeCompletely,
|
||||
JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
JetControlFlowDataTraceFactory flowDataTraceFactory,
|
||||
CompilerSpecialMode compilerSpecialMode) {
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
|
||||
final ModuleDescriptor owner = new ModuleDescriptor("<module>");
|
||||
@@ -172,7 +176,8 @@ public class AnalyzerFacadeForJVM {
|
||||
|
||||
InjectorForTopDownAnalyzerForJvm injector = new InjectorForTopDownAnalyzerForJvm(
|
||||
project, topDownAnalysisParameters,
|
||||
new ObservableBindingTrace(bindingTraceContext), owner, flowDataTraceFactory);
|
||||
new ObservableBindingTrace(bindingTraceContext), owner, flowDataTraceFactory,
|
||||
compilerSpecialMode);
|
||||
|
||||
|
||||
injector.getTopDownAnalyzer().analyzeFiles(files);
|
||||
@@ -184,6 +189,7 @@ public class AnalyzerFacadeForJVM {
|
||||
|
||||
Project project = files.iterator().next().getProject();
|
||||
|
||||
return analyzeFilesWithJavaIntegration(project, files, Predicates.<PsiFile>alwaysFalse(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
return analyzeFilesWithJavaIntegration(project, files, Predicates.<PsiFile>alwaysFalse(),
|
||||
JetControlFlowDataTraceFactory.EMPTY, CompilerSpecialMode.REGULAR);
|
||||
}
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public enum CompilerSpecialMode {
|
||||
REGULAR,
|
||||
BUILTINS,
|
||||
JDK_HEADERS,
|
||||
}
|
||||
+13
-1
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -48,11 +49,12 @@ public class JavaBridgeConfiguration implements ModuleConfiguration {
|
||||
private JavaSemanticServices javaSemanticServices;
|
||||
@NotNull
|
||||
private ModuleConfiguration delegateConfiguration;
|
||||
@NotNull
|
||||
private CompilerSpecialMode mode;
|
||||
|
||||
@Inject
|
||||
public void setProject(@NotNull Project project) {
|
||||
this.project = project;
|
||||
this.delegateConfiguration = DefaultModuleConfiguration.createStandardConfiguration(project);
|
||||
}
|
||||
|
||||
@Inject
|
||||
@@ -60,6 +62,16 @@ public class JavaBridgeConfiguration implements ModuleConfiguration {
|
||||
this.javaSemanticServices = javaSemanticServices;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setMode(@NotNull CompilerSpecialMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.delegateConfiguration = DefaultModuleConfiguration.createStandardConfiguration(project, mode == CompilerSpecialMode.BUILTINS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user