jvm.backend: get JetStandardLibrary from analyzer

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