Special factory method for local analysis
- No need to pass the same flags all the time - No need to check for local mode when in LAZY mode
This commit is contained in:
@@ -103,12 +103,10 @@ public class ReplInterpreter {
|
||||
Project project = jetCoreEnvironment.getProject();
|
||||
trace = new BindingTraceContext();
|
||||
module = AnalyzerFacadeForJVM.createJavaModule("<repl>");
|
||||
TopDownAnalysisParameters topDownAnalysisParameters = TopDownAnalysisParameters.create(
|
||||
TopDownAnalysisParameters topDownAnalysisParameters = TopDownAnalysisParameters.createForLocalDeclarations(
|
||||
new LockBasedStorageManager(),
|
||||
new ExceptionTracker(), // dummy
|
||||
Predicates.<PsiFile>alwaysTrue(),
|
||||
false,
|
||||
true
|
||||
Predicates.<PsiFile>alwaysTrue()
|
||||
);
|
||||
injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module, MemberFilter.ALWAYS_TRUE);
|
||||
topDownAnalysisContext = new TopDownAnalysisContext(topDownAnalysisParameters);
|
||||
|
||||
@@ -590,7 +590,7 @@ public class BodyResolver {
|
||||
JetScope declaringScope = c.getDeclaringScopes().apply(declaration);
|
||||
assert declaringScope != null;
|
||||
|
||||
if (!c.getTopDownAnalysisParameters().isLazyTopDownAnalysis() || c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
if (!c.getTopDownAnalysisParameters().isLazyTopDownAnalysis()) {
|
||||
resolveAnnotationArguments(declaringScope, declaration);
|
||||
}
|
||||
resolveFunctionBody(c, trace, declaration, descriptor, declaringScope);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ScriptBodyResolver {
|
||||
JetScript declaration = e.getKey();
|
||||
ScriptDescriptor descriptor = e.getValue();
|
||||
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis() && !c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis()) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,15 @@ public class TopDownAnalysisParameters implements GlobalContext {
|
||||
declaredLocally, LAZY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TopDownAnalysisParameters createForLocalDeclarations(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ExceptionTracker exceptionTracker,
|
||||
@NotNull Predicate<PsiFile> analyzeCompletely
|
||||
) {
|
||||
return new TopDownAnalysisParameters(storageManager, exceptionTracker, analyzeCompletely, false, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private final StorageManager storageManager;
|
||||
@NotNull
|
||||
|
||||
@@ -129,7 +129,7 @@ public class TopDownAnalyzer {
|
||||
// c.enableDebugOutput();
|
||||
c.debug("Enter");
|
||||
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis() && !c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis()) {
|
||||
final ResolveSession resolveSession = new InjectorForLazyResolve(
|
||||
project,
|
||||
new GlobalContextImpl((LockBasedStorageManager) c.getStorageManager(), c.getExceptionTracker()), // TODO
|
||||
@@ -356,12 +356,10 @@ public class TopDownAnalyzer {
|
||||
PlatformToKotlinClassMap.EMPTY);
|
||||
|
||||
TopDownAnalysisParameters topDownAnalysisParameters =
|
||||
TopDownAnalysisParameters.create(
|
||||
TopDownAnalysisParameters.createForLocalDeclarations(
|
||||
globalContext.getStorageManager(),
|
||||
globalContext.getExceptionTracker(),
|
||||
Predicates.equalTo(object.getContainingFile()),
|
||||
false,
|
||||
true
|
||||
Predicates.equalTo(object.getContainingFile())
|
||||
);
|
||||
|
||||
InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic(
|
||||
|
||||
@@ -333,9 +333,9 @@ public class ResolveElementCache {
|
||||
}
|
||||
|
||||
private static TopDownAnalysisParameters createParameters(@NotNull ResolveSession resolveSession) {
|
||||
return TopDownAnalysisParameters.create(
|
||||
return TopDownAnalysisParameters.createForLocalDeclarations(
|
||||
resolveSession.getStorageManager(), resolveSession.getExceptionTracker(),
|
||||
Predicates.<PsiFile>alwaysTrue(), false, true);
|
||||
Predicates.<PsiFile>alwaysTrue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user