jvm.backend: get JetStandardLibrary from analyzer
This is a big step towards removal of JetStandardLibrary.getInstance()
This commit is contained in:
@@ -24,7 +24,6 @@ import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
@@ -72,7 +71,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
private final BindingContext bindingContext;
|
||||
private final Map<TypeParameterDescriptor, StackValue> typeParameterExpressions = new HashMap<TypeParameterDescriptor, StackValue>();
|
||||
private final CodegenContext context;
|
||||
private final IntrinsicMethods intrinsics;
|
||||
|
||||
private final Stack<BlockStackElement> blockStackElements = new Stack<BlockStackElement>();
|
||||
|
||||
@@ -112,7 +110,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
this.v = new InstructionAdapter(v);
|
||||
this.bindingContext = state.getBindingContext();
|
||||
this.context = context;
|
||||
this.intrinsics = state.getIntrinsics();
|
||||
}
|
||||
|
||||
StackValue castToRequiredTypeOfInterfaceIfNeeded(StackValue inner, DeclarationDescriptor provided, @Nullable ClassDescriptor required) {
|
||||
@@ -976,7 +973,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
descriptor = ((VariableAsFunctionDescriptor) descriptor).getVariableDescriptor();
|
||||
}
|
||||
|
||||
final IntrinsicMethod intrinsic = intrinsics.getIntrinsic(descriptor);
|
||||
final IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(descriptor);
|
||||
if (intrinsic != null) {
|
||||
final Type expectedType = expressionType(expression);
|
||||
return intrinsic.generate(this, v, expectedType, expression, Collections.<JetExpression>emptyList(), receiver);
|
||||
@@ -1130,7 +1127,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
functionDescriptor = functionDescriptor.getOriginal();
|
||||
String owner;
|
||||
|
||||
IntrinsicMethod intrinsic = intrinsics.getIntrinsic(functionDescriptor);
|
||||
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(functionDescriptor);
|
||||
if(intrinsic != null) {
|
||||
intrinsic.generate(this, v, type, null, null, StackValue.onStack(TYPE_OBJECT));
|
||||
return;
|
||||
@@ -1321,7 +1318,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
Callable resolveToCallable(DeclarationDescriptor fd, boolean superCall) {
|
||||
final IntrinsicMethod intrinsic = intrinsics.getIntrinsic(fd);
|
||||
final IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
|
||||
if (intrinsic != null) {
|
||||
return intrinsic;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectLiteralExpression;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.utils.Progress;
|
||||
@@ -52,10 +53,14 @@ public class GenerationState {
|
||||
|
||||
private JetTypeMapper typeMapper;
|
||||
private final Stack<BindingContext> bindingContexts = new Stack<BindingContext>();
|
||||
private final JetStandardLibrary standardLibrary;
|
||||
private final IntrinsicMethods intrinsics;
|
||||
private final Progress progress;
|
||||
|
||||
|
||||
// initialized after analyze
|
||||
private JetStandardLibrary standardLibrary;
|
||||
private IntrinsicMethods intrinsics;
|
||||
|
||||
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory) {
|
||||
this(project, builderFactory, Progress.DEAF);
|
||||
}
|
||||
@@ -63,9 +68,7 @@ public class GenerationState {
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory, Progress progress) {
|
||||
this.project = project;
|
||||
this.progress = progress;
|
||||
this.standardLibrary = JetStandardLibrary.getInstance();
|
||||
this.factory = new ClassFileFactory(builderFactory, this);
|
||||
this.intrinsics = new IntrinsicMethods(project, standardLibrary);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -119,10 +122,11 @@ public class GenerationState {
|
||||
}
|
||||
|
||||
public BindingContext compile(JetFile file) {
|
||||
final BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(file, JetControlFlowDataTraceFactory.EMPTY);
|
||||
AnalyzingUtils.throwExceptionOnErrors(bindingContext);
|
||||
compileCorrectFiles(bindingContext, Collections.singletonList(file), CompilationErrorHandler.THROW_EXCEPTION, true);
|
||||
return bindingContext;
|
||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(file, JetControlFlowDataTraceFactory.EMPTY);
|
||||
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
compileCorrectFiles(analyzeExhaust, Collections.singletonList(file), CompilationErrorHandler.THROW_EXCEPTION, true);
|
||||
return analyzeExhaust.getBindingContext();
|
||||
// NamespaceCodegen codegen = forNamespace(namespace);
|
||||
// bindingContexts.push(bindingContext);
|
||||
// typeMapper = new JetTypeMapper(standardLibrary, bindingContext);
|
||||
@@ -137,14 +141,17 @@ public class GenerationState {
|
||||
// }
|
||||
}
|
||||
|
||||
public void compileCorrectFiles(BindingContext bindingContext, List<JetFile> files, boolean annotate) {
|
||||
public void compileCorrectFiles(AnalyzeExhaust bindingContext, List<JetFile> files, boolean annotate) {
|
||||
compileCorrectFiles(bindingContext, files, CompilationErrorHandler.THROW_EXCEPTION, annotate);
|
||||
}
|
||||
|
||||
public void compileCorrectFiles(BindingContext bindingContext, List<JetFile> files, @NotNull CompilationErrorHandler errorHandler, boolean annotate) {
|
||||
InjectorForJvmCodegen injector = new InjectorForJvmCodegen(standardLibrary, bindingContext, files);
|
||||
public void compileCorrectFiles(AnalyzeExhaust analyzeExhaust, List<JetFile> files, @NotNull CompilationErrorHandler errorHandler, boolean annotate) {
|
||||
this.standardLibrary = analyzeExhaust.getStandardLibrary();
|
||||
this.intrinsics = new IntrinsicMethods(project, standardLibrary);
|
||||
|
||||
InjectorForJvmCodegen injector = new InjectorForJvmCodegen(analyzeExhaust.getStandardLibrary(), analyzeExhaust.getBindingContext(), files);
|
||||
typeMapper = injector.getJetTypeMapper();
|
||||
bindingContexts.push(bindingContext);
|
||||
bindingContexts.push(analyzeExhaust.getBindingContext());
|
||||
try {
|
||||
for (JetFile file : files) {
|
||||
if (file == null) throw new IllegalArgumentException("A null file given for compilation");
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.diagnostics.Severity;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
@@ -64,11 +65,11 @@ public class CompileSession {
|
||||
private final PrintStream myErrorStream;
|
||||
private final boolean myIsVerbose;
|
||||
|
||||
public BindingContext getMyBindingContext() {
|
||||
public AnalyzeExhaust getMyBindingContext() {
|
||||
return myBindingContext;
|
||||
}
|
||||
|
||||
private BindingContext myBindingContext;
|
||||
private AnalyzeExhaust myBindingContext;
|
||||
|
||||
public CompileSession(JetCoreEnvironment environment, MessageRenderer messageRenderer, PrintStream errorStream, boolean verbose) {
|
||||
myEnvironment = environment;
|
||||
@@ -171,7 +172,7 @@ public class CompileSession {
|
||||
myBindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
myEnvironment.getProject(), mySourceFiles, filesToAnalyzeCompletely, JetControlFlowDataTraceFactory.EMPTY);
|
||||
|
||||
for (Diagnostic diagnostic : myBindingContext.getDiagnostics()) {
|
||||
for (Diagnostic diagnostic : myBindingContext.getBindingContext().getDiagnostics()) {
|
||||
reportDiagnostic(myMessageCollector, diagnostic);
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ public class CompileSession {
|
||||
}
|
||||
|
||||
private void reportIncompleteHierarchies(MessageCollector collector) {
|
||||
Collection<ClassDescriptor> incompletes = myBindingContext.getKeys(BindingContext.INCOMPLETE_HIERARCHY);
|
||||
Collection<ClassDescriptor> incompletes = myBindingContext.getBindingContext().getKeys(BindingContext.INCOMPLETE_HIERARCHY);
|
||||
if (!incompletes.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
|
||||
for (ClassDescriptor incomplete : incompletes) {
|
||||
@@ -221,7 +222,7 @@ public class CompileSession {
|
||||
if (!module) {
|
||||
if (plugins != null) {
|
||||
for (CompilerPlugin plugin : plugins) {
|
||||
plugin.processFiles(myBindingContext, getSourceFileNamespaces());
|
||||
plugin.processFiles(myBindingContext.getBindingContext(), getSourceFileNamespaces());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class AnalyzeExhaust {
|
||||
@NotNull
|
||||
private final BindingContext bindingContext;
|
||||
@Nullable
|
||||
private final JetStandardLibrary standardLibrary;
|
||||
|
||||
public AnalyzeExhaust(@NotNull BindingContext bindingContext, @Nullable JetStandardLibrary standardLibrary) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.standardLibrary = standardLibrary;
|
||||
}
|
||||
|
||||
@NotNull public BindingContext getBindingContext() {
|
||||
return bindingContext;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetStandardLibrary getStandardLibrary() {
|
||||
return standardLibrary;
|
||||
}
|
||||
}
|
||||
+26
-22
@@ -35,10 +35,10 @@ import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -57,7 +57,7 @@ public class AnalyzerFacadeForJVM {
|
||||
}
|
||||
};
|
||||
|
||||
private final static Key<CachedValue<BindingContext>> BINDING_CONTEXT = Key.create("BINDING_CONTEXT");
|
||||
private final static Key<CachedValue<AnalyzeExhaust>> BINDING_CONTEXT = Key.create("BINDING_CONTEXT");
|
||||
private static final Object lock = new Object();
|
||||
|
||||
private AnalyzerFacadeForJVM() {
|
||||
@@ -65,25 +65,26 @@ public class AnalyzerFacadeForJVM {
|
||||
|
||||
/**
|
||||
* Analyze project with string cache for given file. Given file will be fully analyzed.
|
||||
*
|
||||
* @param file
|
||||
* @param declarationProvider
|
||||
* @return
|
||||
*/
|
||||
public static BindingContext analyzeFileWithCache(@NotNull final JetFile file, @NotNull final Function<JetFile, Collection<JetFile>> declarationProvider) {
|
||||
public static AnalyzeExhaust analyzeFileWithCache(@NotNull final JetFile file, @NotNull final Function<JetFile, Collection<JetFile>> declarationProvider) {
|
||||
// Need lock for getValue(), because parallel threads can start evaluation of compute() simultaneously
|
||||
synchronized (lock) {
|
||||
CachedValue<BindingContext> bindingContextCachedValue = file.getUserData(BINDING_CONTEXT);
|
||||
CachedValue<AnalyzeExhaust> bindingContextCachedValue = file.getUserData(BINDING_CONTEXT);
|
||||
if (bindingContextCachedValue == null) {
|
||||
bindingContextCachedValue = CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<BindingContext>() {
|
||||
bindingContextCachedValue = CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<AnalyzeExhaust>() {
|
||||
@Override
|
||||
public Result<BindingContext> compute() {
|
||||
public Result<AnalyzeExhaust> compute() {
|
||||
try {
|
||||
BindingContext bindingContext = analyzeFilesWithJavaIntegration(
|
||||
AnalyzeExhaust bindingContext = analyzeFilesWithJavaIntegration(
|
||||
file.getProject(),
|
||||
declarationProvider.fun(file),
|
||||
Predicates.<PsiFile>equalTo(file),
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
return new Result<BindingContext>(bindingContext, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
return new Result<AnalyzeExhaust>(bindingContext, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
@@ -93,7 +94,8 @@ public class AnalyzerFacadeForJVM {
|
||||
LOG.error(e);
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
bindingTraceContext.report(Errors.EXCEPTION_WHILE_ANALYZING.on(file, e));
|
||||
return new Result<BindingContext>(bindingTraceContext.getBindingContext(), PsiModificationTracker.MODIFICATION_COUNT);
|
||||
AnalyzeExhaust analyzeExhaust = new AnalyzeExhaust(bindingTraceContext.getBindingContext(), null);
|
||||
return new Result<AnalyzeExhaust>(analyzeExhaust, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
@@ -106,22 +108,22 @@ public class AnalyzerFacadeForJVM {
|
||||
/**
|
||||
* Analyze project with string cache for the whole project. All given files will be analyzed only for descriptors.
|
||||
*/
|
||||
public static BindingContext analyzeProjectWithCache(@NotNull final Project project,
|
||||
@NotNull final Collection<JetFile> files) {
|
||||
public static AnalyzeExhaust analyzeProjectWithCache(@NotNull final Project project,
|
||||
@NotNull final Collection<JetFile> files) {
|
||||
// Need lock for getValue(), because parallel threads can start evaluation of compute() simultaneously
|
||||
synchronized (lock) {
|
||||
CachedValue<BindingContext> bindingContextCachedValue = project.getUserData(BINDING_CONTEXT);
|
||||
CachedValue<AnalyzeExhaust> bindingContextCachedValue = project.getUserData(BINDING_CONTEXT);
|
||||
if (bindingContextCachedValue == null) {
|
||||
bindingContextCachedValue = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<BindingContext>() {
|
||||
bindingContextCachedValue = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<AnalyzeExhaust>() {
|
||||
@Override
|
||||
public Result<BindingContext> compute() {
|
||||
public Result<AnalyzeExhaust> compute() {
|
||||
try {
|
||||
BindingContext bindingContext = analyzeFilesWithJavaIntegration(
|
||||
AnalyzeExhaust analyzeExhaust = analyzeFilesWithJavaIntegration(
|
||||
project,
|
||||
files,
|
||||
Predicates.<PsiFile>alwaysFalse(),
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
return new Result<BindingContext>(bindingContext, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
return new Result<AnalyzeExhaust>(analyzeExhaust, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
@@ -130,7 +132,8 @@ public class AnalyzerFacadeForJVM {
|
||||
DiagnosticUtils.throwIfRunningOnServer(e);
|
||||
LOG.error(e);
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
return new Result<BindingContext>(bindingTraceContext.getBindingContext(), PsiModificationTracker.MODIFICATION_COUNT);
|
||||
AnalyzeExhaust analyzeExhaust = new AnalyzeExhaust(bindingTraceContext.getBindingContext(), null);
|
||||
return new Result<AnalyzeExhaust>(analyzeExhaust, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
@@ -140,12 +143,13 @@ public class AnalyzerFacadeForJVM {
|
||||
}
|
||||
}
|
||||
|
||||
public static BindingContext analyzeOneFileWithJavaIntegration(JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file), Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory);
|
||||
}
|
||||
|
||||
public static BindingContext analyzeFilesWithJavaIntegration(Project project, Collection<JetFile> files, Predicate<PsiFile> filesToAnalyzeCompletely,
|
||||
JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegration(
|
||||
Project project, Collection<JetFile> files, Predicate<PsiFile> filesToAnalyzeCompletely,
|
||||
JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
|
||||
final ModuleDescriptor owner = new ModuleDescriptor("<module>");
|
||||
@@ -160,10 +164,10 @@ public class AnalyzerFacadeForJVM {
|
||||
|
||||
|
||||
injector.getTopDownAnalyzer().analyzeFiles(files);
|
||||
return bindingTraceContext.getBindingContext();
|
||||
return new AnalyzeExhaust(bindingTraceContext.getBindingContext(), JetStandardLibrary.getInstance());
|
||||
}
|
||||
|
||||
public static BindingContext shallowAnalyzeFiles(Collection<JetFile> files) {
|
||||
public static AnalyzeExhaust shallowAnalyzeFiles(Collection<JetFile> files) {
|
||||
assert files.size() > 0;
|
||||
|
||||
Project project = files.iterator().next().getProject();
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetJavaMirrorMarker;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
@@ -189,7 +190,7 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
|
||||
// The context must reflect _all files in the module_. not only the current file
|
||||
// Otherwise, the analyzer gets confused and can't, for example, tell which files come as sources and which
|
||||
// must be loaded from .class files
|
||||
BindingContext context = AnalyzerFacadeForJVM.shallowAnalyzeFiles(WholeProjectAnalyzerFacade.WHOLE_PROJECT_DECLARATION_PROVIDER.fun(file));
|
||||
AnalyzeExhaust context = AnalyzerFacadeForJVM.shallowAnalyzeFiles(WholeProjectAnalyzerFacade.WHOLE_PROJECT_DECLARATION_PROVIDER.fun(file));
|
||||
|
||||
state.compileCorrectFiles(context, Collections.singletonList(file), CompilationErrorHandler.THROW_EXCEPTION, true);
|
||||
state.getFactory().files();
|
||||
|
||||
+3
-2
@@ -33,6 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.asJava.JetFileUtil;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
@@ -89,12 +90,12 @@ public final class WholeProjectAnalyzerFacade {
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static BindingContext analyzeProjectWithCacheOnAFile(@NotNull JetFile file) {
|
||||
public static AnalyzeExhaust analyzeProjectWithCacheOnAFile(@NotNull JetFile file) {
|
||||
return AnalyzerFacadeForJVM.analyzeFileWithCache(file, WHOLE_PROJECT_DECLARATION_PROVIDER);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static BindingContext analyzeProjectWithCache(@NotNull Project project, @NotNull GlobalSearchScope scope) {
|
||||
public static AnalyzeExhaust analyzeProjectWithCache(@NotNull Project project, @NotNull GlobalSearchScope scope) {
|
||||
return AnalyzerFacadeForJVM.analyzeProjectWithCache(project, JetFileUtil.collectJetFiles(project, scope));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.slicedmap.SlicedMap;
|
||||
@@ -155,7 +156,7 @@ public class JetTestUtils {
|
||||
}
|
||||
};
|
||||
|
||||
public static BindingContext analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, flowDataTraceFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ public class CheckerTestUtilTest extends JetLiteFixture {
|
||||
public void test(final @NotNull PsiFile psiFile) {
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
||||
(JetFile) psiFile,
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
JetControlFlowDataTraceFactory.EMPTY)
|
||||
.getBindingContext();
|
||||
|
||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, psiFile)).toString();
|
||||
|
||||
|
||||
@@ -165,7 +165,9 @@ public class JetDiagnosticsTest extends JetLiteFixture {
|
||||
}
|
||||
}
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY)
|
||||
.getBindingContext();
|
||||
|
||||
boolean ok = true;
|
||||
|
||||
|
||||
@@ -98,7 +98,9 @@ public class TestlibTest extends CodegenTestCase {
|
||||
TestCase.class.getClassLoader()));
|
||||
|
||||
InjectorForJvmCodegen injector = new InjectorForJvmCodegen(
|
||||
classFileFactory.state.getStandardLibrary(), session.getMyBindingContext(), session.getSourceFileNamespaces());
|
||||
session.getMyBindingContext().getStandardLibrary(),
|
||||
session.getMyBindingContext().getBindingContext(),
|
||||
session.getSourceFileNamespaces());
|
||||
JetTypeMapper typeMapper = injector.getJetTypeMapper();
|
||||
TestSuite suite = new TestSuite("stdlib_test");
|
||||
try {
|
||||
@@ -107,7 +109,7 @@ public class TestlibTest extends CodegenTestCase {
|
||||
if(decl instanceof JetClass) {
|
||||
JetClass jetClass = (JetClass) decl;
|
||||
|
||||
ClassDescriptor descriptor = (ClassDescriptor) session.getMyBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
||||
ClassDescriptor descriptor = (ClassDescriptor) session.getMyBindingContext().getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
||||
Set<JetType> allSuperTypes = new THashSet<JetType>();
|
||||
CodegenUtil.addSuperTypes(descriptor.getDefaultType(), allSuperTypes);
|
||||
|
||||
|
||||
@@ -87,7 +87,8 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
||||
|
||||
AnalyzingUtils.checkForSyntacticErrors(psiFile);
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY);
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, JetControlFlowDataTraceFactory.EMPTY)
|
||||
.getBindingContext();
|
||||
AnalyzingUtils.throwExceptionOnErrors(bindingContext);
|
||||
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel("test"));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
@@ -136,7 +137,8 @@ public abstract class ExpectedResolveData {
|
||||
Project project = files.iterator().next().getProject();
|
||||
JetStandardLibrary lib = JetStandardLibrary.getInstance();
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
if (diagnostic instanceof UnresolvedReferenceDiagnostic) {
|
||||
UnresolvedReferenceDiagnostic unresolvedReferenceDiagnostic = (UnresolvedReferenceDiagnostic) diagnostic;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
@@ -61,8 +62,8 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
List<JetDeclaration> declarations = file.getDeclarations();
|
||||
JetDeclaration aClass = declarations.get(0);
|
||||
assert aClass instanceof JetClass;
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
DeclarationDescriptor classDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||
AnalyzeExhaust bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||
WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING);
|
||||
assert classDescriptor instanceof ClassifierDescriptor;
|
||||
scope.addClassifierDescriptor((ClassifierDescriptor) classDescriptor);
|
||||
|
||||
@@ -42,7 +42,8 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
|
||||
ref = PsiTreeUtil.getParentOfType(originalElement, JetReferenceExpression.class);
|
||||
}
|
||||
if (ref != null) {
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) ref.getContainingFile());
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) ref.getContainingFile())
|
||||
.getBindingContext();
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ref);
|
||||
if (declarationDescriptor != null) {
|
||||
return render(declarationDescriptor);
|
||||
|
||||
@@ -48,7 +48,8 @@ public class CopyAsDiagnosticTestAction extends AnAction {
|
||||
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
|
||||
assert editor != null && psiFile != null;
|
||||
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile);
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile)
|
||||
.getBindingContext();
|
||||
List<PsiErrorElement> syntaxError = AnalyzingUtils.getSyntaxErrorRanges(psiFile);
|
||||
|
||||
String result = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, bindingContext, syntaxError).toString();
|
||||
|
||||
@@ -42,7 +42,8 @@ public class ShowExpressionTypeAction extends AnAction {
|
||||
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
|
||||
assert editor != null && psiFile != null;
|
||||
JetExpression expression;
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile);
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile)
|
||||
.getBindingContext();
|
||||
if (editor.getSelectionModel().hasSelection()) {
|
||||
int startOffset = editor.getSelectionModel().getSelectionStart();
|
||||
int endOffset = editor.getSelectionModel().getSelectionEnd();
|
||||
|
||||
@@ -71,7 +71,8 @@ public class DebugInfoAnnotator implements Annotator {
|
||||
if (element instanceof JetFile) {
|
||||
JetFile file = (JetFile) element;
|
||||
try {
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file)
|
||||
.getBindingContext();
|
||||
|
||||
final Set<JetReferenceExpression> unresolvedReferences = Sets.newHashSet();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
|
||||
@@ -60,7 +60,8 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
||||
JetFile file = (JetFile) element.getContainingFile();
|
||||
if (file == null) return null;
|
||||
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file)
|
||||
.getBindingContext();
|
||||
|
||||
if (element instanceof JetClass) {
|
||||
JetClass jetClass = (JetClass) element;
|
||||
|
||||
@@ -71,7 +71,8 @@ public class JetPsiChecker implements Annotator {
|
||||
JetFile file = (JetFile) element;
|
||||
|
||||
try {
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file)
|
||||
.getBindingContext();
|
||||
|
||||
if (errorReportingEnabled) {
|
||||
Collection<Diagnostic> diagnostics = Sets.newLinkedHashSet(bindingContext.getDiagnostics());
|
||||
|
||||
@@ -163,7 +163,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
HashSet<FunctionDescriptor> result = new HashSet<FunctionDescriptor>();
|
||||
|
||||
JetFile jetFile = (JetFile) expression.getContainingFile();
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile);
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile).getBindingContext();
|
||||
JetScope jetScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||
|
||||
if (jetScope == null) {
|
||||
@@ -197,7 +197,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
|
||||
@NotNull
|
||||
public BindingContext getResolutionContext(@NotNull GlobalSearchScope scope) {
|
||||
return WholeProjectAnalyzerFacade.analyzeProjectWithCache(project, scope);
|
||||
return WholeProjectAnalyzerFacade.analyzeProjectWithCache(project, scope).getBindingContext();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
|
||||
JetFile jetFile = (JetFile) expression.getContainingFile();
|
||||
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile);
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile).getBindingContext();
|
||||
JetExpression receiverExpression = expression.getReceiverExpression();
|
||||
|
||||
if (receiverExpression != null) {
|
||||
|
||||
@@ -57,8 +57,8 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
|
||||
@NotNull
|
||||
public Set<CallableMemberDescriptor> collectMethodsToGenerate(@NotNull JetClassOrObject classOrObject) {
|
||||
BindingContext bindingContext =
|
||||
WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile)classOrObject.getContainingFile());
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile)classOrObject.getContainingFile())
|
||||
.getBindingContext();
|
||||
final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
|
||||
if (descriptor instanceof MutableClassDescriptor) {
|
||||
return collectMethodsToGenerate((MutableClassDescriptor)descriptor);
|
||||
|
||||
@@ -154,7 +154,8 @@ public class JetCompletionContributor extends CompletionContributor {
|
||||
Collection<DeclarationDescriptor> jetCallableExtensions = namesCache.getJetCallableExtensions(
|
||||
matchPrefixCondition, expression, GlobalSearchScope.allScope(position.getProject()));
|
||||
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) position.getContainingFile());
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) position.getContainingFile())
|
||||
.getBindingContext();
|
||||
|
||||
for (DeclarationDescriptor jetCallableExtension : jetCallableExtensions) {
|
||||
result.addElement(DescriptorLookupConverter.createLookupElement(context, jetCallableExtension));
|
||||
|
||||
@@ -153,7 +153,8 @@ public class JetPositionManager implements PositionManager {
|
||||
if (mapper != null) {
|
||||
return mapper;
|
||||
}
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file)
|
||||
.getBindingContext();
|
||||
final JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
InjectorForJvmCodegen injector = new InjectorForJvmCodegen(standardLibrary, bindingContext, Collections.singletonList(file));
|
||||
final JetTypeMapper typeMapper = injector.getJetTypeMapper();
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.plugin.compiler.WholeProjectAnalyzerFacade;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -201,7 +202,7 @@ public class BytecodeToolwindow extends JPanel implements Disposable {
|
||||
protected String generateToText(JetFile file) {
|
||||
GenerationState state = new GenerationState(myProject, ClassBuilderFactories.TEXT);
|
||||
try {
|
||||
BindingContext binding = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
AnalyzeExhaust binding = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
// AnalyzingUtils.throwExceptionOnErrors(binding);
|
||||
state.compileCorrectFiles(binding, Collections.singletonList(file), CompilationErrorHandler.THROW_EXCEPTION, true);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,8 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
||||
|| oldLocation.getStartOffset() != startOffset
|
||||
|| oldLocation.getEndOffset() != endOffset) {
|
||||
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile);
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile)
|
||||
.getBindingContext();
|
||||
|
||||
|
||||
PsiElement elementAtOffset;
|
||||
|
||||
@@ -67,7 +67,8 @@ public class JetSourceNavigationHelper {
|
||||
final List<JetFile> libraryFiles = findAllSourceFilesWhichContainIdentifier(declaration);
|
||||
for (JetFile libraryFile : libraryFiles) {
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(libraryFile,
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
D descriptor = bindingContext.get(slice, fqName);
|
||||
if (descriptor != null) {
|
||||
return new Tuple2<BindingContext, D>(bindingContext, descriptor);
|
||||
|
||||
+2
-1
@@ -66,7 +66,8 @@ class AnonymousTemplateEditingListener extends TemplateEditingAdapter {
|
||||
if (name != null && name.getParent() instanceof JetReferenceExpression) {
|
||||
JetReferenceExpression ref = (JetReferenceExpression) name.getParent();
|
||||
|
||||
BindingContext bc = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile);
|
||||
BindingContext bc = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile)
|
||||
.getBindingContext();
|
||||
DeclarationDescriptor descriptor = bc.get(BindingContext.REFERENCE_TARGET, ref);
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
classRef = ref;
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class BaseJetVariableMacro extends Macro {
|
||||
JetExpression contextExpression = findContextExpression(psiFile, context.getStartOffset());
|
||||
if (contextExpression == null) return null;
|
||||
|
||||
BindingContext bc = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile);
|
||||
BindingContext bc = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile).getBindingContext();
|
||||
JetScope scope = bc.get(BindingContext.RESOLUTION_SCOPE, contextExpression);
|
||||
if (scope == null) {
|
||||
return null;
|
||||
|
||||
@@ -90,7 +90,8 @@ public class JetAnonymousSuperMacro extends Macro {
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
if (!(psiFile instanceof JetFile)) return null;
|
||||
|
||||
BindingContext bc = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile);
|
||||
BindingContext bc = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) psiFile)
|
||||
.getBindingContext();
|
||||
JetExpression expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(context.getStartOffset()), JetExpression.class);
|
||||
JetScope scope = bc.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||
if (scope == null) {
|
||||
|
||||
+6
-3
@@ -190,7 +190,8 @@ public class JetFunctionParameterInfoHandler implements
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
JetFile file = (JetFile) argumentList.getContainingFile();
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
||||
@@ -328,8 +329,10 @@ public class JetFunctionParameterInfoHandler implements
|
||||
if (element.getParent() instanceof JetCallElement) {
|
||||
callExpression = (JetCallElement) element.getParent();
|
||||
} else return null;
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) file,
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(
|
||||
(JetFile) file,
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
JetExpression calleeExpression = callExpression.getCalleeExpression();
|
||||
if (calleeExpression == null) return null;
|
||||
JetSimpleNameExpression refExpression = null;
|
||||
|
||||
@@ -57,7 +57,8 @@ public class JetDeclarationTreeNode extends AbstractPsiBasedNode<JetDeclaration>
|
||||
JetDeclaration declaration = getValue();
|
||||
if (declaration != null) {
|
||||
BindingContext context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(
|
||||
(JetFile) declaration.getContainingFile());
|
||||
(JetFile) declaration.getContainingFile())
|
||||
.getBindingContext();
|
||||
|
||||
final DeclarationDescriptor descriptor =
|
||||
context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||
|
||||
@@ -73,7 +73,8 @@ public class ChangeVariableMutabilityFix implements IntentionAction {
|
||||
if (property != null) return property;
|
||||
JetSimpleNameExpression simpleNameExpression = PsiTreeUtil.getParentOfType(elementAtCaret, JetSimpleNameExpression.class);
|
||||
if (simpleNameExpression != null) {
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
VariableDescriptor descriptor = BindingContextUtils.extractVariableDescriptorIfAny(bindingContext, simpleNameExpression, true);
|
||||
if (descriptor != null) {
|
||||
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
|
||||
@@ -54,7 +54,8 @@ public class ImportInsertHelper {
|
||||
if (JetPluginUtil.checkTypeIsStandard(type, file.getProject()) || ErrorUtils.isErrorType(type)) {
|
||||
return;
|
||||
}
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache(file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
PsiElement element = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, type.getMemberScope().getContainingDeclaration());
|
||||
if (element != null && element.getContainingFile() == file) { //declaration is in the same file, so no import is needed
|
||||
return;
|
||||
|
||||
@@ -57,7 +57,8 @@ public class QuickFixUtil {
|
||||
public static JetType getDeclarationReturnType(JetNamedDeclaration declaration) {
|
||||
PsiFile file = declaration.getContainingFile();
|
||||
if (!(file instanceof JetFile)) return null;
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) file, AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||
if (!(descriptor instanceof CallableDescriptor)) return null;
|
||||
JetType type = ((CallableDescriptor) descriptor).getReturnType();
|
||||
|
||||
@@ -67,7 +67,8 @@ public class JetNameSuggester {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) expression.getContainingFile(),
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (jetType != null) {
|
||||
addNamesForType(result, jetType, validator);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class JetNameValidatorImpl implements JetNameValidator {
|
||||
private boolean checkElement(final String name, PsiElement sibling) {
|
||||
if (myBindingContext == null) {
|
||||
myBindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(
|
||||
(JetFile) myContainer.getContainingFile());
|
||||
(JetFile) myContainer.getContainingFile()).getBindingContext();
|
||||
}
|
||||
final Ref<Boolean> result = new Ref<Boolean>(true);
|
||||
JetVisitorVoid visitor = new JetVisitorVoid() {
|
||||
|
||||
@@ -103,7 +103,8 @@ public class JetRefactoringUtil {
|
||||
if (addExpression) {
|
||||
JetExpression expression = (JetExpression) element;
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) expression.getContainingFile(),
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (expressionType == null || !(expressionType instanceof NamespaceType) &&
|
||||
!JetTypeChecker.INSTANCE.equalTypes(JetStandardLibrary.
|
||||
|
||||
+4
-2
@@ -96,7 +96,8 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
|
||||
}
|
||||
}
|
||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) expression.getContainingFile(),
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression); //can be null or error type
|
||||
if (expressionType instanceof NamespaceType) {
|
||||
showErrorHint(project, editor, JetRefactoringBundle.message("cannot.refactor.namespace.expression"));
|
||||
@@ -349,7 +350,8 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
|
||||
final ArrayList<JetExpression> result = new ArrayList<JetExpression>();
|
||||
|
||||
final BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFileWithCache((JetFile) expression.getContainingFile(),
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER);
|
||||
AnalyzerFacadeForJVM.SINGLE_DECLARATION_PROVIDER)
|
||||
.getBindingContext();
|
||||
|
||||
JetVisitorVoid visitor = new JetVisitorVoid() {
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,8 @@ class JetArrayAccessReference extends JetPsiReference implements MultiRangeRefer
|
||||
|
||||
@Override
|
||||
protected PsiElement doResolve() {
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) getElement().getContainingFile());
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) getElement().getContainingFile())
|
||||
.getBindingContext();
|
||||
ResolvedCall<FunctionDescriptor> getFunction = bindingContext.get(INDEXED_LVALUE_GET, expression);
|
||||
ResolvedCall<FunctionDescriptor> setFunction = bindingContext.get(INDEXED_LVALUE_SET, expression);
|
||||
if (getFunction != null && setFunction != null) {
|
||||
@@ -68,7 +69,8 @@ class JetArrayAccessReference extends JetPsiReference implements MultiRangeRefer
|
||||
|
||||
@Override
|
||||
protected ResolveResult[] doMultiResolve() {
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) getElement().getContainingFile());
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) getElement().getContainingFile())
|
||||
.getBindingContext();
|
||||
ResolvedCall<FunctionDescriptor> getFunction = bindingContext.get(INDEXED_LVALUE_GET, expression);
|
||||
PsiElement getFunctionElement = bindingContext.get(DESCRIPTOR_TO_DECLARATION, getFunction.getResultingDescriptor());
|
||||
ResolvedCall<FunctionDescriptor> setFunction = bindingContext.get(INDEXED_LVALUE_SET, expression);
|
||||
|
||||
@@ -41,7 +41,8 @@ public class JetPackageReference extends JetPsiReference {
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(
|
||||
(JetFile) myExpression.getContainingFile());
|
||||
(JetFile) myExpression.getContainingFile())
|
||||
.getBindingContext();
|
||||
|
||||
return DescriptorLookupConverter.collectLookupElements(
|
||||
bindingContext, TipsManager.getReferenceVariants(packageExpression, bindingContext));
|
||||
|
||||
@@ -99,7 +99,8 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
@Nullable
|
||||
protected PsiElement doResolve() {
|
||||
JetFile file = (JetFile) getElement().getContainingFile();
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file)
|
||||
.getBindingContext();
|
||||
PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, myExpression);
|
||||
if (psiElement != null) {
|
||||
return psiElement;
|
||||
@@ -113,7 +114,8 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
|
||||
protected ResolveResult[] doMultiResolve() {
|
||||
JetFile file = (JetFile) getElement().getContainingFile();
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file)
|
||||
.getBindingContext();
|
||||
Collection<? extends DeclarationDescriptor> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||
if (declarationDescriptors == null) return ResolveResult.EMPTY_ARRAY;
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ public class JetSimpleNameReference extends JetPsiReference {
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(
|
||||
(JetFile) myExpression.getContainingFile());
|
||||
(JetFile) myExpression.getContainingFile())
|
||||
.getBindingContext();
|
||||
|
||||
return DescriptorLookupConverter.collectLookupElements(
|
||||
bindingContext, TipsManager.getReferenceVariants(myExpression, bindingContext));
|
||||
|
||||
@@ -114,7 +114,8 @@ public class JetStructureViewElement implements StructureViewTreeElement {
|
||||
if (myElement instanceof JetFile) {
|
||||
final JetFile jetFile = (JetFile) myElement;
|
||||
|
||||
context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile);
|
||||
context = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile)
|
||||
.getBindingContext();
|
||||
|
||||
return wrapDeclarations(jetFile.getDeclarations());
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ public class RenameInKotlinTest extends MultiFileTestCase {
|
||||
doTest(new PerformAction() {
|
||||
@Override
|
||||
public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCache(getProject(), GlobalSearchScope.allScope(getProject()));
|
||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCache(
|
||||
getProject(), GlobalSearchScope.allScope(getProject()))
|
||||
.getBindingContext();
|
||||
ClassDescriptor classDescriptor = bindingContext.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, qClassName);
|
||||
|
||||
assertNotNull(classDescriptor);
|
||||
|
||||
Reference in New Issue
Block a user