This commit is contained in:
Andrey Breslav
2011-05-16 21:41:49 +04:00
parent cefdf3a266
commit fe5d5771e1
10 changed files with 57 additions and 334 deletions
@@ -34,7 +34,7 @@ public class JetHighlighter extends SyntaxHighlighterBase {
public static final TextAttributesKey JET_FIELD_IDENTIFIER = TextAttributesKey.createTextAttributesKey(
"JET.FIELD.IDENTIFIER",
// TODO: proper attributes
SyntaxHighlighterColors.KEYWORD.getDefaultAttributes()
SyntaxHighlighterColors.NUMBER.getDefaultAttributes()
);
public static final TextAttributesKey JET_PROPERTY_WITH_BACKING_FIELD_IDENTIFIER = TextAttributesKey.createTextAttributesKey(
@@ -98,7 +98,7 @@ public class FunctionDescriptorUtil {
@NotNull
public static JetScope getFunctionInnerScope(@NotNull JetScope outerScope, @NotNull FunctionDescriptor descriptor, @NotNull BindingTrace trace) {
WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, trace.getErrorHandler(), null);
WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, trace.getErrorHandler());
for (TypeParameterDescriptor typeParameter : descriptor.getTypeParameters()) {
parameterScope.addTypeParameterDescriptor(typeParameter);
}
@@ -29,22 +29,9 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
public MutableClassDescriptor(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor containingDeclaration, @NotNull JetScope outerScope) {
super(containingDeclaration);
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, trace.getErrorHandler(), null);
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, trace.getErrorHandler(), null);
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, trace.getErrorHandler(), null);
// this.scopeForMemberLookup = new WritableScopeImpl(scopeForMemberResolution, this, trace.getErrorHandler(), new DeclarationDescriptorVisitor<Void, WritableScope>() {
// @Override
// public Void visitPropertyDescriptor(PropertyDescriptor descriptor, WritableScope data) {
// properties.add(descriptor);
// return null;
// }
//
// @Override
// public Void visitFunctionDescriptor(FunctionDescriptor descriptor, WritableScope data) {
// functions.add(descriptor);
// return null;
// }
// });
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, trace.getErrorHandler());
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, trace.getErrorHandler());
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, trace.getErrorHandler());
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -69,7 +69,7 @@ public class AnalyzingUtils {
JetScope libraryScope = semanticServices.getStandardLibrary().getLibraryScope();
ModuleDescriptor owner = new ModuleDescriptor("<module>");
final WritableScope scope = new WritableScopeImpl(libraryScope, owner, bindingTraceContext.getErrorHandler(), null);
final WritableScope scope = new WritableScopeImpl(libraryScope, owner, bindingTraceContext.getErrorHandler());
// scope.importScope(javaSemanticServices.getDescriptorResolver().resolveNamespace("").getMemberScope());
// scope.importScope(javaSemanticServices.getDescriptorResolver().resolveNamespace("java.lang").getMemberScope());
scope.importScope(new JavaPackageScope("", null, javaSemanticServices));
@@ -38,14 +38,14 @@ public class ClassDescriptorResolver {
@Nullable
public ClassDescriptor resolveClassDescriptor(@NotNull JetScope scope, @NotNull JetClass classElement) {
ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(
final ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(
scope.getContainingDeclaration(),
AnnotationResolver.INSTANCE.resolveAnnotations(classElement.getModifierList()),
JetPsiUtil.safeName(classElement.getName()));
trace.recordDeclarationResolution(classElement, classDescriptor);
WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler(), null);
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler());
// This call has side-effects on the parameterScope (fills it in)
List<TypeParameterDescriptor> typeParameters
@@ -57,11 +57,42 @@ public class ClassDescriptorResolver {
? Collections.singleton(JetStandardClasses.getAnyType())
: resolveDelegationSpecifiers(parameterScope, delegationSpecifiers, typeResolver);
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
WritableScope members = resolveMembers(classDescriptor, classElement, typeParameters, scope, parameterScope, supertypes);
final WritableScope memberDeclarations = new WritableScopeImpl(parameterScope, classDescriptor, trace.getErrorHandler());
List<JetDeclaration> declarations = classElement.getDeclarations();
for (JetDeclaration declaration : declarations) {
declaration.accept(new JetVisitor() {
@Override
public void visitProperty(JetProperty property) {
if (property.getPropertyTypeRef() != null) {
memberDeclarations.addVariableDescriptor(resolvePropertyDescriptor(classDescriptor, parameterScope, property));
} else {
// TODO : Caution: a cyclic dependency possible
throw new UnsupportedOperationException();
}
}
@Override
public void visitFunction(JetFunction function) {
if (function.getReturnTypeRef() != null) {
memberDeclarations.addFunctionDescriptor(resolveFunctionDescriptor(classDescriptor, parameterScope, function));
} else {
// TODO : Caution: a cyclic dependency possible
throw new UnsupportedOperationException();
}
}
@Override
public void visitJetElement(JetElement elem) {
throw new UnsupportedOperationException(elem.toString());
}
});
}
WritableFunctionGroup constructors = new WritableFunctionGroup("<init>");
for (JetConstructor constructor : classElement.getSecondaryConstructors()) {
constructors.addFunction(resolveSecondaryConstructorDescriptor(members, classDescriptor, constructor));
constructors.addFunction(resolveSecondaryConstructorDescriptor(memberDeclarations, classDescriptor, constructor));
}
ConstructorDescriptor primaryConstructorDescriptor = resolvePrimaryConstructorDescriptor(scope, classDescriptor, classElement);
if (primaryConstructorDescriptor != null) {
@@ -71,7 +102,7 @@ public class ClassDescriptorResolver {
!open,
typeParameters,
supertypes,
members,
memberDeclarations,
constructors,
primaryConstructorDescriptor
);
@@ -149,93 +180,6 @@ public class ClassDescriptorResolver {
}
}
public void resolveMutableClassDescriptor(@NotNull JetScope scope, @NotNull JetClass classElement, @NotNull MutableClassDescriptor descriptor) {
descriptor.setName(JetPsiUtil.safeName(classElement.getName()));
descriptor.getScopeForMemberResolution().addLabeledDeclaration(descriptor);
WritableScope parameterScope = descriptor.getScopeForSupertypeResolution();
// This call has side-effects on the parameterScope (fills it in)
List<TypeParameterDescriptor> typeParameters
= resolveTypeParameters(descriptor, parameterScope, classElement.getTypeParameters());
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
List<JetType> supertypes = new ArrayList<JetType>();
TypeConstructorImpl typeConstructor = new TypeConstructorImpl(
descriptor,
AnnotationResolver.INSTANCE.resolveAnnotations(classElement.getModifierList()),
!open,
JetPsiUtil.safeName(classElement.getName()),
typeParameters,
supertypes);
descriptor.setTypeConstructor(
typeConstructor
);
List<JetDelegationSpecifier> delegationSpecifiers = classElement.getDelegationSpecifiers();
// TODO : assuming that the hierarchy is acyclic
Collection<? extends JetType> superclasses = delegationSpecifiers.isEmpty()
? Collections.singleton(JetStandardClasses.getAnyType())
: resolveDelegationSpecifiers(parameterScope, delegationSpecifiers, typeResolver);
// TODO : UGLY HACK
supertypes.addAll(superclasses);
// TODO : importing may be a bad idea
for (JetType supertype : superclasses) {
assert supertype != null : classElement.getName();
parameterScope.importScope(supertype.getMemberScope());
}
descriptor.getScopeForMemberResolution().setThisType(descriptor.getDefaultType());
trace.recordDeclarationResolution(classElement, descriptor);
}
private WritableScope resolveMembers(
final ClassDescriptor classDescriptor,
final JetClass classElement,
List<TypeParameterDescriptor> typeParameters,
final JetScope outerScope,
final JetScope typeParameterScope,
final Collection<? extends JetType> supertypes) {
final WritableScope memberDeclarations = new WritableScopeImpl(typeParameterScope, classDescriptor, trace.getErrorHandler(), null);
List<JetDeclaration> declarations = classElement.getDeclarations();
for (JetDeclaration declaration : declarations) {
declaration.accept(new JetVisitor() {
@Override
public void visitProperty(JetProperty property) {
if (property.getPropertyTypeRef() != null) {
memberDeclarations.addVariableDescriptor(resolvePropertyDescriptor(classDescriptor, typeParameterScope, property));
} else {
// TODO : Caution: a cyclic dependency possible
throw new UnsupportedOperationException();
}
}
@Override
public void visitFunction(JetFunction function) {
if (function.getReturnTypeRef() != null) {
memberDeclarations.addFunctionDescriptor(resolveFunctionDescriptor(classDescriptor, typeParameterScope, function));
} else {
// TODO : Caution: a cyclic dependency possible
throw new UnsupportedOperationException();
}
}
@Override
public void visitJetElement(JetElement elem) {
throw new UnsupportedOperationException(elem.toString());
}
});
}
return memberDeclarations;
}
@NotNull
public FunctionDescriptorImpl resolveFunctionDescriptor(DeclarationDescriptor containingDescriptor, final JetScope scope, final JetFunction function) {
final FunctionDescriptorImpl functionDescriptor = new FunctionDescriptorImpl(
@@ -243,7 +187,7 @@ public class ClassDescriptorResolver {
AnnotationResolver.INSTANCE.resolveAnnotations(function.getModifierList()),
JetPsiUtil.safeName(function.getName())
);
WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, trace.getErrorHandler(), null);
WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, trace.getErrorHandler());
innerScope.addLabeledDeclaration(functionDescriptor);
// The two calls below have side-effects on parameterScope
@@ -569,7 +513,7 @@ public class ClassDescriptorResolver {
return constructorDescriptor.initialize(
resolveValueParameters(
constructorDescriptor,
new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler(), null),
new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler()),
valueParameters));
}
@@ -76,9 +76,6 @@ public class TopDownAnalyzer {
};
}
// public void process(@NotNull JetScope outerScope, @NotNull JetDeclaration declaration) {
// process(outerScope, Collections.singletonList(declaration));
// }
public void process(@NotNull WritableScope outerScope, NamespaceLike owner, @NotNull List<JetDeclaration> declarations) {
collectNamespacesAndClassifiers(outerScope, owner, declarations); // namespaceScopes, classes
@@ -91,11 +88,6 @@ public class TopDownAnalyzer {
// Constructor headers are resolved as well
resolveExecutableCode();
// processBehaviorDeclarators(outerScope, declarations);
// readyToProcessExpressions = true;
// resolveBehaviorDeclarationBodies();
}
private void collectNamespacesAndClassifiers(
@@ -115,11 +107,11 @@ public class TopDownAnalyzer {
NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name);
if (namespaceDescriptor == null) {
namespaceDescriptor = new NamespaceDescriptorImpl(
owner.getOriginal(), //declaringScope.getContainingDeclaration(),
owner.getOriginal(),
Collections.<Annotation>emptyList(), // TODO
name
);
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler(), null));
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler()));
owner.addNamespace(namespaceDescriptor);
trace.recordDeclarationResolution(namespace, namespaceDescriptor);
}
@@ -231,7 +223,6 @@ public class TopDownAnalyzer {
for (JetConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
processSecondaryConstructor(classDescriptor, jetConstructor);
}
// processBehaviorDeclarators(classDescriptor.getScopeForMemberLookup(), jetClass.getDeclarations());
// TODO : Constructors
}
@@ -266,169 +257,6 @@ public class TopDownAnalyzer {
resolveBehaviorDeclarationBodies();
}
// @NotNull
// public JetScope process(@NotNull JetScope outerScope, @NotNull List<JetDeclaration> declarations) {
// final WritableScope toplevelScope = new WritableScopeImpl(outerScope, outerScope.getContainingDeclaration(), trace.getErrorHandler(), null); // TODO ?!
//
// collectTypeDeclarators(toplevelScope, declarations);
// resolveTypeDeclarations();
// processBehaviorDeclarators(toplevelScope, declarations);
// readyToProcessExpressions = true;
// resolveBehaviorDeclarationBodies();
// return toplevelScope;
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// private void collectTypeDeclarators(
// @NotNull final WritableScope declaringScope,
// List<JetDeclaration> declarations) {
// for (JetDeclaration declaration : declarations) {
// declaration.accept(new JetVisitor() {
// @Override
// public void visitNamespace(JetNamespace namespace) {
// List<JetImportDirective> importDirectives = namespace.getImportDirectives();
//
// String name = namespace.getName();
// if (name == null) {
// name = "<no name provided>";
// }
// NamespaceDescriptorImpl namespaceDescriptor = (NamespaceDescriptorImpl) declaringScope.getDeclaredNamespace(name);
// if (namespaceDescriptor == null) {
// namespaceDescriptor = new NamespaceDescriptorImpl(
// declaringScope.getContainingDeclaration(),
// Collections.<Annotation>emptyList(), // TODO
// name
// );
// namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler(), null));
// declaringScope.addNamespace(namespaceDescriptor);
// trace.recordDeclarationResolution(namespace, namespaceDescriptor);
// }
//
// WritableScope namespaceScope = new WriteThroughScope(declaringScope, (WritableScope) namespaceDescriptor.getMemberScope());
// namespaceScopes.put(namespace, namespaceScope);
//
// for (JetImportDirective importDirective : importDirectives) {
// if (importDirective.isAbsoluteInRootNamespace()) {
// throw new UnsupportedOperationException();
// }
// if (importDirective.isAllUnder()) {
// JetExpression importedReference = importDirective.getImportedReference();
// if (importedReference != null) {
// JetType type = semanticServices.getTypeInferrer(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, importedReference, false);
// if (type != null) {
// namespaceScope.importScope(type.getMemberScope());
// }
// }
// } else {
// throw new UnsupportedOperationException();
// }
// }
//
// collectTypeDeclarators(namespaceScope, namespace.getDeclarations());
// }
//
// @Override
// public void visitClass(JetClass klass) {
// MutableClassDescriptor mutableClassDescriptor = new MutableClassDescriptor(trace, declaringScope.getContainingDeclaration(), declaringScope);
// mutableClassDescriptor.setName(JetPsiUtil.safeName(klass.getName()));
//
// declaringScope.addClassifierDescriptor(mutableClassDescriptor);
//
// classes.put(klass, mutableClassDescriptor);
// declaringScopes.put(klass, declaringScope);
//
// WritableScope classScope = mutableClassDescriptor.getScopeForMemberLookup();
// collectTypeDeclarators(classScope, klass.getDeclarations());
// }
//
// @Override
// public void visitTypedef(JetTypedef typedef) {
// trace.getErrorHandler().genericError(typedef.getNode(), "Unsupported [TopDownAnalyzer]");
// }
//
// @Override
// public void visitExtension(JetExtension extension) {
// trace.getErrorHandler().genericError(extension.getNode(), "Unsupported [TopDownAnalyzer]");
// }
//
// @Override
// public void visitDeclaration(JetDeclaration dcl) {
// // Other declarations do not declare visible types
// }
// });
// }
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// private void resolveTypeDeclarations() {
// for (Map.Entry<JetClass, MutableClassDescriptor> entry : classes.entrySet()) {
// JetClass jetClass = entry.getKey();
// MutableClassDescriptor descriptor = entry.getValue();
// classDescriptorResolver.resolveMutableClassDescriptor(declaringScopes.get(jetClass), jetClass, descriptor);
// }
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// private void processBehaviorDeclarators(@NotNull final WritableScope declaringScope, List<JetDeclaration> declarations) {
// for (JetDeclaration declaration : declarations) {
// declaration.accept(new JetVisitor() {
// @Override
// public void visitClass(JetClass klass) {
// MutableClassDescriptor mutableClassDescriptor = classes.get(klass);
// processPrimaryConstructor(mutableClassDescriptor, klass);
// processBehaviorDeclarators(mutableClassDescriptor.getScopeForMemberLookup(), klass.getDeclarations());
// }
//
// @Override
// public void visitClassObject(JetClassObject classObject) {
// processClassObject(classObject);
// processBehaviorDeclarators(declaringScope, classObject.getObject().getDeclarations());
// }
//
// @Override
// public void visitNamespace(JetNamespace namespace) {
// WritableScope namespaceScope = namespaceScopes.get(namespace);
// processBehaviorDeclarators(namespaceScope, namespace.getDeclarations());
// }
//
// @Override
// public void visitFunction(JetFunction function) {
// processFunction(declaringScope, function);
// }
//
// @Override
// public void visitProperty(JetProperty property) {
// processProperty(declaringScope, property);
// }
//
// @Override
// public void visitConstructor(JetConstructor constructor) {
// DeclarationDescriptor containingDeclaration = declaringScope.getContainingDeclaration();
// if (containingDeclaration instanceof ClassDescriptor) {
// processSecondaryConstructor((MutableClassDescriptor) containingDeclaration, constructor);
// }
// else {
// trace.getErrorHandler().genericError(constructor.getNode(), "Constructors are only allowed inside classes");
// }
// }
//
// @Override
// public void visitAnonymousInitializer(JetClassInitializer initializer) {
// // Nothing
// }
//
// @Override
// public void visitDeclaration(JetDeclaration dcl) {
// trace.getErrorHandler().genericError(dcl.getNode(), "[TopDownAnalyzer] Unsupported declaration: " + dcl); // TODO
// }
// });
// }
//
// }
private void processPrimaryConstructor(MutableClassDescriptor classDescriptor, JetClass klass) {
if (!klass.hasPrimaryConstructor()) return;
@@ -459,26 +287,6 @@ public class TopDownAnalyzer {
declaringScopes.put(constructor, classDescriptor.getScopeForMemberLookup());
}
// private void processFunction(@NotNull WritableScope declaringScope, JetFunction function) {
// declaringScopes.put(function, declaringScope);
// FunctionDescriptorImpl descriptor = classDescriptorResolver.resolveFunctionDescriptor(declaringScope.getContainingDeclaration(), declaringScope, function);
// declaringScope.addFunctionDescriptor(descriptor);
// functions.put(function, descriptor);
// }
//
// private void processProperty(WritableScope declaringScope, JetProperty property) {
// declaringScopes.put(property, declaringScope);
// // TODO : Do not infer the type from the initializer here: the scope is wrong, and not ready anyway
// PropertyDescriptor descriptor = classDescriptorResolver.resolvePropertyDescriptor(declaringScope.getContainingDeclaration(), declaringScope, property);
// declaringScope.addVariableDescriptor(descriptor);
// declaringScopesToProperties.put(declaringScope.getContainingDeclaration(), descriptor);
// properties.put(property, descriptor);
// }
//
// private void processClassObject(JetClassObject classObject) {
// trace.getErrorHandler().genericError(classObject.getNode(), "Class objects are not supported yet"); // TODO
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void resolveBehaviorDeclarationBodies() {
@@ -725,7 +533,7 @@ public class TopDownAnalyzer {
@NotNull
private JetScope getInnerScopeForConstructor(@NotNull ConstructorDescriptor descriptor, @NotNull JetScope declaringScope) {
WritableScope constructorScope = new WritableScopeImpl(declaringScope, declaringScope.getContainingDeclaration(), trace.getErrorHandler(), null);
WritableScope constructorScope = new WritableScopeImpl(declaringScope, declaringScope.getContainingDeclaration(), trace.getErrorHandler());
for (PropertyDescriptor propertyDescriptor : ((MutableClassDescriptor) descriptor.getContainingDeclaration()).getProperties()) {
constructorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
}
@@ -783,7 +591,7 @@ public class TopDownAnalyzer {
private void resolvePropertyAccessors(JetProperty property, PropertyDescriptor propertyDescriptor, JetScope declaringScope) {
BindingTraceAdapter fieldAccessTrackingTrace = createFieldTrackingTrace(propertyDescriptor);
WritableScope accessorScope = new WritableScopeImpl(declaringScope, declaringScope.getContainingDeclaration(), trace.getErrorHandler(), null);
WritableScope accessorScope = new WritableScopeImpl(declaringScope, declaringScope.getContainingDeclaration(), trace.getErrorHandler());
accessorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
JetPropertyAccessor getter = property.getGetter();
@@ -36,14 +36,10 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@Nullable
private JetType thisType;
@Nullable
private final DeclarationDescriptorVisitor<?, ? super WritableScopeImpl> modificationListener;
public WritableScopeImpl(@NotNull JetScope scope, @NotNull DeclarationDescriptor owner, @NotNull ErrorHandler errorHandler, @Nullable DeclarationDescriptorVisitor<?, ? super WritableScopeImpl> modificationListener) {
public WritableScopeImpl(@NotNull JetScope scope, @NotNull DeclarationDescriptor owner, @NotNull ErrorHandler errorHandler) {
super(scope);
this.ownerDeclarationDescriptor = owner;
this.errorHandler = errorHandler;
this.modificationListener = modificationListener;
}
@NotNull
@@ -52,12 +48,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
return ownerDeclarationDescriptor;
}
private void notifyListeners(DeclarationDescriptor descriptor) {
if (modificationListener != null) {
descriptor.accept(modificationListener, this);
}
}
@NotNull
private Map<String, List<DeclarationDescriptor>> getLabelsToDescriptors() {
if (labelsToDescriptors == null) {
@@ -92,7 +82,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
labelsToDescriptors.put(name, declarationDescriptors);
}
declarationDescriptors.add(descriptor);
notifyListeners(descriptor);
}
@NotNull
@@ -112,7 +101,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
}
// TODO : Should this always happen?
propertyDescriptors.put(variableDescriptor.getName(), variableDescriptor);
notifyListeners(variableDescriptor);
}
@Override
@@ -157,7 +145,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
functionGroups.put(name, functionGroup);
}
functionGroup.addFunction(functionDescriptor);
notifyListeners(functionDescriptor);
}
@Override
@@ -214,7 +201,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
errorHandler.redeclaration(originalDescriptor, classifierDescriptor);
}
classifierDescriptors.put(name, classifierDescriptor);
notifyListeners(classifierDescriptor);
}
@Override
@@ -257,7 +243,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
if (oldValue != null) {
errorHandler.redeclaration(oldValue, namespaceDescriptor);
}
notifyListeners(namespaceDescriptor);
}
@Override
@@ -304,7 +289,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@Override
public void addPropertyDescriptorByFieldName(@NotNull String fieldName, @NotNull PropertyDescriptor propertyDescriptor) {
getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor);
notifyListeners(propertyDescriptor);
}
@Override
@@ -173,7 +173,7 @@ public class JetStandardClasses {
/*package*/ static final JetScope STANDARD_CLASSES;
static {
WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, ErrorHandler.DO_NOTHING, null);
WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, ErrorHandler.DO_NOTHING);
STANDARD_CLASSES = writableScope;
writableScope.addClassifierAlias("Unit", getTuple(0));
@@ -73,7 +73,7 @@ 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, null);
WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, ErrorHandler.THROW_EXCEPTION);
// this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations());
bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
@@ -349,7 +349,7 @@ public class JetTypeInferrer {
}
DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration();
WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, trace.getErrorHandler(), null);
WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, trace.getErrorHandler());
return getBlockReturnedTypeWithWritableScope(scope, block);
}
@@ -727,7 +727,7 @@ public class JetTypeInferrer {
if (returnTypeRef != null) {
returnType = typeResolver.resolveType(scope, returnTypeRef);
} else {
WritableScope writableScope = new WritableScopeImpl(scope, functionDescriptor, trace.getErrorHandler(), null);
WritableScope writableScope = new WritableScopeImpl(scope, functionDescriptor, trace.getErrorHandler());
for (VariableDescriptor variableDescriptor : parameterDescriptors.values()) {
writableScope.addVariableDescriptor(variableDescriptor);
}
@@ -983,7 +983,7 @@ public class JetTypeInferrer {
if (catchParameter != null) {
VariableDescriptor variableDescriptor = classDescriptorResolver.resolveLocalVariableDescriptor(scope.getContainingDeclaration(), scope, catchParameter);
if (catchBody != null) {
WritableScope catchScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler(), null);
WritableScope catchScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler());
catchScope.addVariableDescriptor(variableDescriptor);
JetType type = getType(catchScope, catchBody, true);
if (type != null) {
@@ -1071,7 +1071,7 @@ public class JetTypeInferrer {
if (body instanceof JetFunctionLiteralExpression) {
JetFunctionLiteralExpression function = (JetFunctionLiteralExpression) body;
if (!function.hasParameterSpecification()) {
WritableScope writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler(), null);
WritableScope writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler());
conditionScope = writableScope;
getBlockReturnedTypeWithWritableScope(writableScope, function.getBody());
trace.recordBlock(function);
@@ -1080,7 +1080,7 @@ public class JetTypeInferrer {
}
}
else if (body != null) {
WritableScope writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler(), null);
WritableScope writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler());
conditionScope = writableScope;
getBlockReturnedTypeWithWritableScope(writableScope, Collections.singletonList(body));
}
@@ -1101,7 +1101,7 @@ public class JetTypeInferrer {
expectedParameterType = checkIterableConvention(loopRangeType, loopRange.getNode());
}
WritableScope loopScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler(), null);
WritableScope loopScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), trace.getErrorHandler());
if (loopParameter != null) {
JetTypeReference typeReference = loopParameter.getTypeReference();