Unified processing in TopDownAnalyzer to avoid inconsistencies
This commit is contained in:
@@ -97,6 +97,8 @@ public class OverrideResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void checkOverridesInAClass(MutableClassDescriptor classDescriptor, JetClassOrObject klass) {
|
protected void checkOverridesInAClass(MutableClassDescriptor classDescriptor, JetClassOrObject klass) {
|
||||||
|
if (context.analyzingBootstrapLibrary()) return;
|
||||||
|
|
||||||
// Check overrides for internal consistency
|
// Check overrides for internal consistency
|
||||||
for (CallableMemberDescriptor member : classDescriptor.getCallableMembers()) {
|
for (CallableMemberDescriptor member : classDescriptor.getCallableMembers()) {
|
||||||
checkOverride(member);
|
checkOverride(member);
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
private StringBuilder debugOutput;
|
private StringBuilder debugOutput;
|
||||||
|
|
||||||
|
private boolean analyzingBootstrapLibrary = false;
|
||||||
|
|
||||||
public TopDownAnalysisContext(JetSemanticServices semanticServices, BindingTrace trace, Predicate<PsiFile> analyzeCompletely) {
|
public TopDownAnalysisContext(JetSemanticServices semanticServices, BindingTrace trace, Predicate<PsiFile> analyzeCompletely) {
|
||||||
this.trace = new ObservableBindingTrace(trace);
|
this.trace = new ObservableBindingTrace(trace);
|
||||||
this.semanticServices = semanticServices;
|
this.semanticServices = semanticServices;
|
||||||
@@ -66,6 +68,14 @@ import java.util.Set;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean analyzingBootstrapLibrary() {
|
||||||
|
return analyzingBootstrapLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalyzingBootstrapLibrary(boolean analyzingBootstrapLibrary) {
|
||||||
|
this.analyzingBootstrapLibrary = analyzingBootstrapLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean completeAnalysisNeeded(@NotNull PsiElement element) {
|
public boolean completeAnalysisNeeded(@NotNull PsiElement element) {
|
||||||
PsiFile containingFile = element.getContainingFile();
|
PsiFile containingFile = element.getContainingFile();
|
||||||
boolean result = containingFile != null && analyzeCompletely.apply(containingFile);
|
boolean result = containingFile != null && analyzeCompletely.apply(containingFile);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||||
@@ -45,6 +44,16 @@ public class TopDownAnalyzer {
|
|||||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
|
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
|
||||||
boolean declaredLocally) {
|
boolean declaredLocally) {
|
||||||
TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace, analyzeCompletely);
|
TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace, analyzeCompletely);
|
||||||
|
doProcess(context, outerScope, owner, declarations, flowDataTraceFactory, declaredLocally);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void doProcess(
|
||||||
|
TopDownAnalysisContext context, JetScope outerScope,
|
||||||
|
NamespaceLike owner,
|
||||||
|
Collection<? extends JetDeclaration> declarations,
|
||||||
|
JetControlFlowDataTraceFactory flowDataTraceFactory,
|
||||||
|
boolean declaredLocally) {
|
||||||
// context.enableDebugOutput();
|
// context.enableDebugOutput();
|
||||||
context.debug("Enter");
|
context.debug("Enter");
|
||||||
|
|
||||||
@@ -53,9 +62,11 @@ public class TopDownAnalyzer {
|
|||||||
new DelegationResolver(context).process();
|
new DelegationResolver(context).process();
|
||||||
new OverrideResolver(context).process();
|
new OverrideResolver(context).process();
|
||||||
new OverloadResolver(context).process();
|
new OverloadResolver(context).process();
|
||||||
new BodyResolver(context).resolveBehaviorDeclarationBodies();
|
if (!context.analyzingBootstrapLibrary()) {
|
||||||
new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process();
|
new BodyResolver(context).resolveBehaviorDeclarationBodies();
|
||||||
new DeclarationsChecker(context).process();
|
new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process();
|
||||||
|
new DeclarationsChecker(context).process();
|
||||||
|
}
|
||||||
|
|
||||||
context.debug("Exit");
|
context.debug("Exit");
|
||||||
context.printDebugOutput(System.out);
|
context.printDebugOutput(System.out);
|
||||||
@@ -69,17 +80,9 @@ public class TopDownAnalyzer {
|
|||||||
context.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope());
|
context.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope());
|
||||||
context.getNamespaceDescriptors().put(namespace, standardLibraryNamespace);
|
context.getNamespaceDescriptors().put(namespace, standardLibraryNamespace);
|
||||||
context.getDeclaringScopes().put(namespace, outerScope);
|
context.getDeclaringScopes().put(namespace, outerScope);
|
||||||
|
context.setAnalyzingBootstrapLibrary(true);
|
||||||
|
|
||||||
new TypeHierarchyResolver(context).process(outerScope, standardLibraryNamespace, namespace.getDeclarations());
|
doProcess(context, outerScope, standardLibraryNamespace, namespace.getDeclarations(), JetControlFlowDataTraceFactory.EMPTY, false);
|
||||||
new DeclarationResolver(context).process();
|
|
||||||
new DelegationResolver(context).process();
|
|
||||||
OverrideResolver overrideResolver = new OverrideResolver(context) {
|
|
||||||
@Override
|
|
||||||
protected void checkOverridesInAClass(MutableClassDescriptor classDescriptor, JetClassOrObject klass) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
overrideResolver.process();
|
|
||||||
new BodyResolver(context).resolveBehaviorDeclarationBodies();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processObject(
|
public static void processObject(
|
||||||
|
|||||||
Reference in New Issue
Block a user