Do reference resolution with lazy resolve
This commit is contained in:
@@ -18,8 +18,11 @@ package org.jetbrains.jet.plugin.project;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
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.lazy.ResolveSession;
|
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||||
|
import org.jetbrains.jet.lang.resolve.lazy.ResolveSessionUtils;
|
||||||
|
|
||||||
public final class WholeProjectAnalyzerFacade {
|
public final class WholeProjectAnalyzerFacade {
|
||||||
|
|
||||||
@@ -35,4 +38,9 @@ public final class WholeProjectAnalyzerFacade {
|
|||||||
public static ResolveSession getLazyResolveSessionForFile(@NotNull JetFile file) {
|
public static ResolveSession getLazyResolveSessionForFile(@NotNull JetFile file) {
|
||||||
return AnalyzerFacadeWithCache.getLazyResolveSession(file);
|
return AnalyzerFacadeWithCache.getLazyResolveSession(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BindingContext getContextForExpression(@NotNull JetExpression jetExpression) {
|
||||||
|
ResolveSession resolveSession = getLazyResolveSessionForFile((JetFile) jetExpression.getContainingFile());
|
||||||
|
return ResolveSessionUtils.resolveToExpression(resolveSession, jetExpression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,16 +102,16 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected PsiElement doResolve() {
|
protected PsiElement doResolve() {
|
||||||
JetFile file = (JetFile) getElement().getContainingFile();
|
BindingContext context = WholeProjectAnalyzerFacade.getContextForExpression(myExpression);
|
||||||
BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file).getBindingContext();
|
|
||||||
List<PsiElement> psiElements = BindingContextUtils.resolveToDeclarationPsiElements(bindingContext, myExpression);
|
List<PsiElement> psiElements = BindingContextUtils.resolveToDeclarationPsiElements(context, myExpression);
|
||||||
if (psiElements.size() == 1) {
|
if (psiElements.size() == 1) {
|
||||||
return psiElements.iterator().next();
|
return psiElements.iterator().next();
|
||||||
}
|
}
|
||||||
if (psiElements.size() > 1) {
|
if (psiElements.size() > 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Collection<PsiElement> stdlibSymbols = resolveStandardLibrarySymbol(bindingContext);
|
Collection<PsiElement> stdlibSymbols = resolveStandardLibrarySymbol(context);
|
||||||
if (stdlibSymbols.size() == 1) {
|
if (stdlibSymbols.size() == 1) {
|
||||||
return stdlibSymbols.iterator().next();
|
return stdlibSymbols.iterator().next();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user