LAZY flag is moved to TopDownAnalysisParameters
This commit is contained in:
@@ -121,7 +121,7 @@ public class BodyResolver {
|
||||
|
||||
resolvePropertyDeclarationBodies(c);
|
||||
|
||||
if (!TopDownAnalyzer.LAZY) {
|
||||
if (!c.getTopDownAnalysisParameters().isLazyTopDownAnalysis()) {
|
||||
resolveClassAnnotations(c);
|
||||
}
|
||||
resolveAnonymousInitializers(c);
|
||||
@@ -590,7 +590,7 @@ public class BodyResolver {
|
||||
JetScope declaringScope = c.getDeclaringScopes().apply(declaration);
|
||||
assert declaringScope != null;
|
||||
|
||||
if (!TopDownAnalyzer.LAZY || c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
if (!c.getTopDownAnalysisParameters().isLazyTopDownAnalysis() || c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
resolveAnnotationArguments(declaringScope, declaration);
|
||||
}
|
||||
resolveFunctionBody(c, trace, declaration, descriptor, declaringScope);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DeclarationsChecker {
|
||||
|
||||
if (classOrObject instanceof JetClass) {
|
||||
JetClass jetClass = (JetClass) classOrObject;
|
||||
checkClass(jetClass, classDescriptor);
|
||||
checkClass(bodiesResolveContext, jetClass, classDescriptor);
|
||||
descriptorResolver.checkNamesInConstraints(
|
||||
jetClass, classDescriptor, classDescriptor.getScopeForClassHeaderResolution(), trace);
|
||||
}
|
||||
@@ -255,9 +255,9 @@ public class DeclarationsChecker {
|
||||
reportErrorIfHasIllegalModifier(declaration);
|
||||
}
|
||||
|
||||
private void checkClass(JetClass aClass, ClassDescriptorWithResolutionScopes classDescriptor) {
|
||||
private void checkClass(BodiesResolveContext c, JetClass aClass, ClassDescriptorWithResolutionScopes classDescriptor) {
|
||||
checkOpenMembers(classDescriptor);
|
||||
if (TopDownAnalyzer.LAZY) {
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis()) {
|
||||
checkTypeParameters(aClass);
|
||||
}
|
||||
if (aClass.isTrait()) {
|
||||
|
||||
@@ -103,6 +103,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
public void resolveMutableClassDescriptor(
|
||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
||||
@NotNull JetClass classElement,
|
||||
@NotNull MutableClassDescriptor descriptor,
|
||||
BindingTrace trace
|
||||
@@ -111,7 +112,7 @@ public class DescriptorResolver {
|
||||
List<TypeParameterDescriptor> typeParameters = Lists.newArrayList();
|
||||
int index = 0;
|
||||
for (JetTypeParameter typeParameter : classElement.getTypeParameters()) {
|
||||
if (!TopDownAnalyzer.LAZY) {
|
||||
if (!topDownAnalysisParameters.isLazyTopDownAnalysis()) {
|
||||
// TODO: Support
|
||||
AnnotationResolver.reportUnsupportedAnnotationForTypeParameter(typeParameter, trace);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ScriptBodyResolver {
|
||||
JetScript declaration = e.getKey();
|
||||
ScriptDescriptor descriptor = e.getValue();
|
||||
|
||||
if (TopDownAnalyzer.LAZY && !c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis() && !c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||
continue;
|
||||
}
|
||||
|
||||
+17
-2
@@ -27,6 +27,12 @@ import org.jetbrains.jet.storage.StorageManager;
|
||||
* Various junk that cannot be placed into context (yet).
|
||||
*/
|
||||
public class TopDownAnalysisParameters implements GlobalContext {
|
||||
private static boolean LAZY;
|
||||
|
||||
static {
|
||||
LAZY = "true".equals(System.getProperty("lazy.tda"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TopDownAnalysisParameters create(
|
||||
@NotNull StorageManager storageManager,
|
||||
@@ -36,7 +42,7 @@ public class TopDownAnalysisParameters implements GlobalContext {
|
||||
boolean declaredLocally
|
||||
) {
|
||||
return new TopDownAnalysisParameters(storageManager, exceptionTracker, analyzeCompletely, analyzingBootstrapLibrary,
|
||||
declaredLocally);
|
||||
declaredLocally, LAZY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -47,19 +53,22 @@ public class TopDownAnalysisParameters implements GlobalContext {
|
||||
private final Predicate<PsiFile> analyzeCompletely;
|
||||
private final boolean analyzingBootstrapLibrary;
|
||||
private final boolean declaredLocally;
|
||||
private final boolean lazyTopDownAnalysis;
|
||||
|
||||
private TopDownAnalysisParameters(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ExceptionTracker exceptionTracker,
|
||||
@NotNull Predicate<PsiFile> analyzeCompletely,
|
||||
boolean analyzingBootstrapLibrary,
|
||||
boolean declaredLocally
|
||||
boolean declaredLocally,
|
||||
boolean lazyTopDownAnalysis
|
||||
) {
|
||||
this.storageManager = storageManager;
|
||||
this.exceptionTracker = exceptionTracker;
|
||||
this.analyzeCompletely = analyzeCompletely;
|
||||
this.analyzingBootstrapLibrary = analyzingBootstrapLibrary;
|
||||
this.declaredLocally = declaredLocally;
|
||||
this.lazyTopDownAnalysis = lazyTopDownAnalysis;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,4 +95,10 @@ public class TopDownAnalysisParameters implements GlobalContext {
|
||||
public boolean isDeclaredLocally() {
|
||||
return declaredLocally;
|
||||
}
|
||||
|
||||
// Used temporarily while we are transitioning from eager to lazy analysis of headers in the IDE
|
||||
@Deprecated
|
||||
public boolean isLazyTopDownAnalysis() {
|
||||
return lazyTopDownAnalysis;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +56,6 @@ import static org.jetbrains.jet.lang.diagnostics.Errors.MANY_CLASS_OBJECTS;
|
||||
|
||||
public class TopDownAnalyzer {
|
||||
|
||||
public static boolean LAZY;
|
||||
|
||||
static {
|
||||
LAZY = "true".equals(System.getProperty("lazy.tda"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private BindingTrace trace;
|
||||
@NotNull
|
||||
@@ -135,7 +129,7 @@ public class TopDownAnalyzer {
|
||||
// c.enableDebugOutput();
|
||||
c.debug("Enter");
|
||||
|
||||
if (LAZY && !c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
if (c.getTopDownAnalysisParameters().isLazyTopDownAnalysis() && !c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
final ResolveSession resolveSession = new InjectorForLazyResolve(
|
||||
project,
|
||||
new GlobalContextImpl((LockBasedStorageManager) c.getStorageManager(), c.getExceptionTracker()), // TODO
|
||||
|
||||
@@ -190,7 +190,9 @@ public class TypeHierarchyResolver {
|
||||
JetClassOrObject classOrObject = entry.getKey();
|
||||
MutableClassDescriptor descriptor = (MutableClassDescriptor) entry.getValue();
|
||||
if (classOrObject instanceof JetClass) {
|
||||
descriptorResolver.resolveMutableClassDescriptor((JetClass) classOrObject, descriptor, trace);
|
||||
descriptorResolver.resolveMutableClassDescriptor(
|
||||
c.getTopDownAnalysisParameters(),
|
||||
(JetClass) classOrObject, descriptor, trace);
|
||||
}
|
||||
else if (classOrObject instanceof JetObjectDeclaration) {
|
||||
descriptor.setModality(Modality.FINAL);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.jet.types;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
@@ -27,6 +29,7 @@ import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||
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.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -35,6 +38,8 @@ import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.storage.ExceptionTracker;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -92,7 +97,11 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
|
||||
private ClassDescriptorWithResolutionScopes createClassDescriptor(ClassKind kind, JetClass aClass) {
|
||||
MutableClassDescriptor classDescriptor = new MutableClassDescriptor(root, scope, kind, false, Name.identifier(aClass.getName()));
|
||||
descriptorResolver.resolveMutableClassDescriptor(aClass, classDescriptor, JetTestUtils.DUMMY_TRACE);
|
||||
TopDownAnalysisParameters parameters = TopDownAnalysisParameters.create(
|
||||
LockBasedStorageManager.NO_LOCKS, new ExceptionTracker(), Predicates.<PsiFile>alwaysTrue(), false, false
|
||||
);
|
||||
descriptorResolver.resolveMutableClassDescriptor(
|
||||
parameters, aClass, classDescriptor, JetTestUtils.DUMMY_TRACE);
|
||||
return classDescriptor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user