diff --git a/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java b/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java index 6c9b846f39d..6507660af4b 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java @@ -77,10 +77,7 @@ public class AnalyzingUtils { scope.importScope(new JavaPackageScope("", null, javaSemanticServices)); scope.importScope(new JavaPackageScope("java.lang", null, javaSemanticServices)); - TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, bindingTraceContext); -// topDownAnalyzer.process(scope, Collections.singletonList(namespace)); -// if (false) - topDownAnalyzer.process(scope, new NamespaceLike.Adapter(owner) { + TopDownAnalyzer.process(semanticServices, bindingTraceContext, scope, new NamespaceLike.Adapter(owner) { @Override public NamespaceDescriptorImpl getNamespace(String name) { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index d03f0a826e0..db213171413 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -13,16 +13,16 @@ import java.util.List; * @author abreslav */ public class TopDownAnalyzer { - private final JetSemanticServices semanticServices; - private final BindingTrace trace; - public TopDownAnalyzer(JetSemanticServices semanticServices, @NotNull BindingTrace bindingTrace) { - this.semanticServices = semanticServices; - this.trace = bindingTrace; - } + private TopDownAnalyzer() {} - public void processObject(@NotNull JetScope outerScope, @NotNull DeclarationDescriptor containingDeclaration, @NotNull JetObjectDeclaration object) { - process(outerScope, new NamespaceLike.Adapter(containingDeclaration) { + public static void processObject( + @NotNull JetSemanticServices semanticServices, + @NotNull BindingTrace trace, + @NotNull JetScope outerScope, + @NotNull DeclarationDescriptor containingDeclaration, + @NotNull JetObjectDeclaration object) { + process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) { @Override public NamespaceDescriptorImpl getNamespace(String name) { @@ -56,7 +56,10 @@ public class TopDownAnalyzer { }, Collections.singletonList(object)); } - public void process(@NotNull JetScope outerScope, NamespaceLike owner, @NotNull List declarations) { + public static void process( + @NotNull JetSemanticServices semanticServices, + @NotNull BindingTrace trace, + @NotNull JetScope outerScope, NamespaceLike owner, @NotNull List declarations) { TypeHierarchyResolver typeHierarchyResolver = new TypeHierarchyResolver(semanticServices, trace); typeHierarchyResolver.process(outerScope, owner, declarations); @@ -66,7 +69,10 @@ public class TopDownAnalyzer { new BodyResolver(semanticServices, trace, typeHierarchyResolver, declarationResolver).resolveBehaviorDeclarationBodies(); } - public void processStandardLibraryNamespace(@NotNull WritableScope outerScope, @NotNull NamespaceDescriptorImpl standardLibraryNamespace, @NotNull JetNamespace namespace) { + public static void processStandardLibraryNamespace( + @NotNull JetSemanticServices semanticServices, + @NotNull BindingTrace trace, + @NotNull WritableScope outerScope, @NotNull NamespaceDescriptorImpl standardLibraryNamespace, @NotNull JetNamespace namespace) { TypeHierarchyResolver typeHierarchyResolver = new TypeHierarchyResolver(semanticServices, trace); typeHierarchyResolver.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope()); typeHierarchyResolver.getNamespaceDescriptors().put(namespace, standardLibraryNamespace); diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzerForStandardLibrary.java b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzerForStandardLibrary.java deleted file mode 100644 index dc1adf442c2..00000000000 --- a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzerForStandardLibrary.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.jetbrains.jet.lang.resolve; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.JetSemanticServices; -import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.psi.JetNamedFunction; -import org.jetbrains.jet.lang.psi.JetNamespace; -import org.jetbrains.jet.lang.psi.JetProperty; - -/** - * @author svtk - */ -//public class TopDownAnalyzerForStandardLibrary extends TopDownAnalyzer { -// -// public TopDownAnalyzerForStandardLibrary(JetSemanticServices semanticServices, @NotNull BindingTrace bindingTrace) { -// super(semanticServices, bindingTrace); -// } -// -// public void processStandardLibraryNamespace(@NotNull WritableScope outerScope, @NotNull NamespaceDescriptorImpl standardLibraryNamespace, @NotNull JetNamespace namespace) { -// namespaceScopes.put(namespace, standardLibraryNamespace.getMemberScope()); -// namespaceDescriptors.put(namespace, standardLibraryNamespace); -// TypeHierarchyResolver typeHierarchyResolver = new TypeHierarchyResolver(semanticServices, trace); -// typeHierarchyResolver.process(outerScope, standardLibraryNamespace, namespace.getDeclarations()); -// -// DeclarationResolver declarationResolver = new DeclarationResolver(semanticServices, trace, typeHierarchyResolver); -// declarationResolver.process(); -// -// new BodyResolver(semanticServices, trace, typeHierarchyResolver, declarationResolver).resolveBehaviorDeclarationBodies(); -// } -// -// @Override -// protected void checkProperty(JetProperty property, PropertyDescriptor propertyDescriptor, ClassDescriptor classDescriptor) {} -// -// -// @Override -// protected void checkFunction(JetNamedFunction function, FunctionDescriptor functionDescriptor, DeclarationDescriptor containingDescriptor) {} -//} diff --git a/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index d086844c1d7..bdc7a8098ed 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -97,11 +97,10 @@ public class JetStandardLibrary { JetSemanticServices bootstrappingSemanticServices = JetSemanticServices.createSemanticServices(this); BindingTraceContext bindingTraceContext = new BindingTraceContext(); - TopDownAnalyzer bootstrappingTDA = new TopDownAnalyzer(bootstrappingSemanticServices, bindingTraceContext); WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, ErrorHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope"); // this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations()); // bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations()); - bootstrappingTDA.processStandardLibraryNamespace(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace()); + TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace()); this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope(); AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingTraceContext.getBindingContext()); diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index be5fbe04c40..934a0bdcf99 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -867,8 +867,7 @@ public class JetTypeInferrer { //noinspection unchecked traceAdapter.addHandler(slice, handler); } - TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, traceAdapter); - topDownAnalyzer.processObject(context.scope, context.scope.getContainingDeclaration(), expression.getObjectDeclaration()); + TopDownAnalyzer.processObject(semanticServices, traceAdapter, context.scope, context.scope.getContainingDeclaration(), expression.getObjectDeclaration()); return context.services.checkType(result[0], expression, context); } @@ -2514,8 +2513,7 @@ public class JetTypeInferrer { @Override public JetType visitObjectDeclaration(JetObjectDeclaration declaration, TypeInferenceContext context) { - TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, context.trace); - topDownAnalyzer.processObject(scope, scope.getContainingDeclaration(), declaration); + TopDownAnalyzer.processObject(semanticServices, context.trace, scope, scope.getContainingDeclaration(), declaration); ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, declaration); if (classDescriptor != null) { PropertyDescriptor propertyDescriptor = context.classDescriptorResolver.resolveObjectDeclarationAsPropertyDescriptor(scope.getContainingDeclaration(), declaration, classDescriptor);