TopDownAnalyzer is now a utility class
This commit is contained in:
@@ -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.<JetDeclaration>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) {
|
||||
|
||||
@@ -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.<JetDeclaration>singletonList(object));
|
||||
}
|
||||
|
||||
public void process(@NotNull JetScope outerScope, NamespaceLike owner, @NotNull List<JetDeclaration> declarations) {
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope, NamespaceLike owner, @NotNull List<JetDeclaration> 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);
|
||||
|
||||
@@ -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) {}
|
||||
//}
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user