Revert "WritableScope.changeLockLevel()"
This reverts commit 1866a245fa.
Stupid git
This commit is contained in:
@@ -80,7 +80,6 @@ public class FunctionDescriptorUtil {
|
|||||||
parameterScope.addVariableDescriptor(valueParameterDescriptor);
|
parameterScope.addVariableDescriptor(valueParameterDescriptor);
|
||||||
}
|
}
|
||||||
parameterScope.addLabeledDeclaration(descriptor);
|
parameterScope.addLabeledDeclaration(descriptor);
|
||||||
parameterScope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
return parameterScope;
|
return parameterScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,8 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
super(containingDeclaration);
|
super(containingDeclaration);
|
||||||
TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace);
|
TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace);
|
||||||
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler).setDebugName("MemberLookup");
|
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler).setDebugName("MemberLookup");
|
||||||
this.scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler).setDebugName("SupertypeResolution");
|
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler).setDebugName("SupertypeResolution");
|
||||||
this.scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler).setDebugName("MemberResolution");
|
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler).setDebugName("MemberResolution");
|
||||||
this.scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +180,6 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
this.typeParameters.add(typeParameterDescriptor);
|
this.typeParameters.add(typeParameterDescriptor);
|
||||||
scopeForSupertypeResolution.addTypeParameterDescriptor(typeParameterDescriptor);
|
scopeForSupertypeResolution.addTypeParameterDescriptor(typeParameterDescriptor);
|
||||||
}
|
}
|
||||||
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -348,13 +344,4 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
}
|
}
|
||||||
return implicitReceiver;
|
return implicitReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockScopes() {
|
|
||||||
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
if (classObjectDescriptor != null) {
|
|
||||||
classObjectDescriptor.lockScopes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ public class AnalyzingUtils {
|
|||||||
final WritableScope scope = new WritableScopeImpl(JetScope.EMPTY, owner, new TraceBasedRedeclarationHandler(bindingTraceContext)).setDebugName("Root scope in analyzeNamespace");
|
final WritableScope scope = new WritableScopeImpl(JetScope.EMPTY, owner, new TraceBasedRedeclarationHandler(bindingTraceContext)).setDebugName("Root scope in analyzeNamespace");
|
||||||
importingStrategy.addImports(project, semanticServices, bindingTraceContext, scope);
|
importingStrategy.addImports(project, semanticServices, bindingTraceContext, scope);
|
||||||
scope.importScope(libraryScope);
|
scope.importScope(libraryScope);
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
|
|
||||||
TopDownAnalyzer.process(semanticServices, bindingTraceContext, scope, new NamespaceLike.Adapter(owner) {
|
TopDownAnalyzer.process(semanticServices, bindingTraceContext, scope, new NamespaceLike.Adapter(owner) {
|
||||||
|
|
||||||
|
|||||||
@@ -382,8 +382,6 @@ public class BodyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructorScope.addLabeledDeclaration(descriptor); // TODO : Labels for constructors?!
|
constructorScope.addLabeledDeclaration(descriptor); // TODO : Labels for constructors?!
|
||||||
|
|
||||||
constructorScope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
|
|
||||||
return constructorScope;
|
return constructorScope;
|
||||||
}
|
}
|
||||||
@@ -444,7 +442,6 @@ public class BodyResolver {
|
|||||||
if (receiver.exists()) {
|
if (receiver.exists()) {
|
||||||
result.setImplicitReceiver(receiver);
|
result.setImplicitReceiver(receiver);
|
||||||
}
|
}
|
||||||
result.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +450,6 @@ public class BodyResolver {
|
|||||||
|
|
||||||
WritableScope accessorScope = new WritableScopeImpl(getPropertyDeclarationInnerScope(declaringScope, propertyDescriptor), declaringScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Accessor scope");
|
WritableScope accessorScope = new WritableScopeImpl(getPropertyDeclarationInnerScope(declaringScope, propertyDescriptor), declaringScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Accessor scope");
|
||||||
accessorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
|
accessorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
|
||||||
accessorScope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
|
|
||||||
JetPropertyAccessor getter = property.getGetter();
|
JetPropertyAccessor getter = property.getGetter();
|
||||||
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ public class DescriptorResolver {
|
|||||||
innerScope.addLabeledDeclaration(functionDescriptor);
|
innerScope.addLabeledDeclaration(functionDescriptor);
|
||||||
|
|
||||||
List<TypeParameterDescriptor> typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters());
|
List<TypeParameterDescriptor> typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters());
|
||||||
innerScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
resolveGenericBounds(function, innerScope, typeParameterDescriptors);
|
resolveGenericBounds(function, innerScope, typeParameterDescriptors);
|
||||||
|
|
||||||
JetType receiverType = null;
|
JetType receiverType = null;
|
||||||
@@ -158,10 +157,8 @@ public class DescriptorResolver {
|
|||||||
: scope;
|
: scope;
|
||||||
receiverType = typeResolver.resolveType(scopeForReceiver, receiverTypeRef);
|
receiverType = typeResolver.resolveType(scopeForReceiver, receiverTypeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ValueParameterDescriptor> valueParameterDescriptors = resolveValueParameters(functionDescriptor, innerScope, function.getValueParameters());
|
List<ValueParameterDescriptor> valueParameterDescriptors = resolveValueParameters(functionDescriptor, innerScope, function.getValueParameters());
|
||||||
|
|
||||||
innerScope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
|
|
||||||
JetTypeReference returnTypeRef = function.getReturnTypeRef();
|
JetTypeReference returnTypeRef = function.getReturnTypeRef();
|
||||||
JetType returnType;
|
JetType returnType;
|
||||||
@@ -502,10 +499,8 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WritableScope writableScope = new WritableScopeImpl(scope, containingDeclaration, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with type parameters of a property");
|
WritableScope writableScope = new WritableScopeImpl(scope, containingDeclaration, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with type parameters of a property");
|
||||||
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
typeParameterDescriptors = resolveTypeParameters(containingDeclaration, writableScope, typeParameters);
|
typeParameterDescriptors = resolveTypeParameters(containingDeclaration, writableScope, typeParameters);
|
||||||
resolveGenericBounds(property, writableScope, typeParameterDescriptors);
|
resolveGenericBounds(property, writableScope, typeParameterDescriptors);
|
||||||
writableScope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
scopeWithTypeParameters = writableScope;
|
scopeWithTypeParameters = writableScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,13 +761,11 @@ public class DescriptorResolver {
|
|||||||
isPrimary
|
isPrimary
|
||||||
);
|
);
|
||||||
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
|
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
|
||||||
WritableScopeImpl parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor");
|
|
||||||
parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
return constructorDescriptor.initialize(
|
return constructorDescriptor.initialize(
|
||||||
typeParameters,
|
typeParameters,
|
||||||
resolveValueParameters(
|
resolveValueParameters(
|
||||||
constructorDescriptor,
|
constructorDescriptor,
|
||||||
parameterScope,
|
new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor"),
|
||||||
valueParameters),
|
valueParameters),
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
resolveVisibilityFromModifiers(modifierList));
|
resolveVisibilityFromModifiers(modifierList));
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public class TopDownAnalyzer {
|
|||||||
new TypeHierarchyResolver(context).process(outerScope, owner, declarations);
|
new TypeHierarchyResolver(context).process(outerScope, owner, declarations);
|
||||||
new DeclarationResolver(context).process();
|
new DeclarationResolver(context).process();
|
||||||
new DelegationResolver(context).process();
|
new DelegationResolver(context).process();
|
||||||
lockClasses(context);
|
|
||||||
new OverrideResolver(context).process();
|
new OverrideResolver(context).process();
|
||||||
new OverloadResolver(context).process();
|
new OverloadResolver(context).process();
|
||||||
if (!context.analyzingBootstrapLibrary()) {
|
if (!context.analyzingBootstrapLibrary()) {
|
||||||
@@ -73,15 +72,6 @@ public class TopDownAnalyzer {
|
|||||||
context.printDebugOutput(System.out);
|
context.printDebugOutput(System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void lockClasses(TopDownAnalysisContext context) {
|
|
||||||
for (MutableClassDescriptor mutableClassDescriptor : context.getClasses().values()) {
|
|
||||||
mutableClassDescriptor.lockScopes();
|
|
||||||
}
|
|
||||||
for (MutableClassDescriptor mutableClassDescriptor : context.getObjects().values()) {
|
|
||||||
mutableClassDescriptor.lockScopes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void processStandardLibraryNamespace(
|
public static void processStandardLibraryNamespace(
|
||||||
@NotNull JetSemanticServices semanticServices,
|
@NotNull JetSemanticServices semanticServices,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
|
|||||||
@@ -78,16 +78,13 @@ public class TypeHierarchyResolver {
|
|||||||
Collections.<AnnotationDescriptor>emptyList(), // TODO: annotations
|
Collections.<AnnotationDescriptor>emptyList(), // TODO: annotations
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
WritableScopeImpl memberScope = new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope");
|
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope"));
|
||||||
memberScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
namespaceDescriptor.initialize(memberScope);
|
|
||||||
owner.addNamespace(namespaceDescriptor);
|
owner.addNamespace(namespaceDescriptor);
|
||||||
context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor);
|
context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor);
|
||||||
}
|
}
|
||||||
context.getNamespaceDescriptors().put(namespace, namespaceDescriptor);
|
context.getNamespaceDescriptors().put(namespace, namespaceDescriptor);
|
||||||
|
|
||||||
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace()));
|
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace()));
|
||||||
namespaceScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
context.getNamespaceScopes().put(namespace, namespaceScope);
|
context.getNamespaceScopes().put(namespace, namespaceScope);
|
||||||
context.getDeclaringScopes().put(namespace, outerScope);
|
context.getDeclaringScopes().put(namespace, outerScope);
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
|||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public interface WritableScope extends JetScope {
|
public interface WritableScope extends JetScope {
|
||||||
enum LockLevel {
|
|
||||||
WRITING,
|
|
||||||
BOTH,
|
|
||||||
READING,
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeLockLevel(LockLevel lockLevel);
|
|
||||||
|
|
||||||
void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor);
|
void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor);
|
||||||
|
|
||||||
void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor);
|
void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor);
|
||||||
|
|||||||
@@ -55,22 +55,17 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importScope(@NotNull JetScope imported) {
|
public void importScope(@NotNull JetScope imported) {
|
||||||
checkMayWrite();
|
|
||||||
super.importScope(imported);
|
super.importScope(imported);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
allDescriptors.add(classifierDescriptor);
|
allDescriptors.add(classifierDescriptor);
|
||||||
super.importClassifierAlias(importedClassifierName, classifierDescriptor);
|
super.importClassifierAlias(importedClassifierName, classifierDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
allDescriptors.add(namespaceDescriptor);
|
allDescriptors.add(namespaceDescriptor);
|
||||||
super.importNamespaceAlias(aliasName, namespaceDescriptor);
|
super.importNamespaceAlias(aliasName, namespaceDescriptor);
|
||||||
}
|
}
|
||||||
@@ -78,8 +73,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<DeclarationDescriptor> getAllDescriptors() {
|
public Collection<DeclarationDescriptor> getAllDescriptors() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
if (!allDescriptorsDone) {
|
if (!allDescriptorsDone) {
|
||||||
allDescriptorsDone = true;
|
allDescriptorsDone = true;
|
||||||
allDescriptors.addAll(getWorkerScope().getAllDescriptors());
|
allDescriptors.addAll(getWorkerScope().getAllDescriptors());
|
||||||
@@ -101,8 +94,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull String labelName) {
|
public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull String labelName) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
Collection<DeclarationDescriptor> superResult = super.getDeclarationsByLabel(labelName);
|
Collection<DeclarationDescriptor> superResult = super.getDeclarationsByLabel(labelName);
|
||||||
Map<String, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
|
Map<String, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
|
||||||
List<DeclarationDescriptor> declarationDescriptors = labelsToDescriptors.get(labelName);
|
List<DeclarationDescriptor> declarationDescriptors = labelsToDescriptors.get(labelName);
|
||||||
@@ -117,8 +108,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
Map<String, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
|
Map<String, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
|
||||||
String name = descriptor.getName();
|
String name = descriptor.getName();
|
||||||
assert name != null;
|
assert name != null;
|
||||||
@@ -148,8 +137,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) {
|
public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||||
DeclarationDescriptor existingDescriptor = variableClassOrNamespaceDescriptors.get(variableDescriptor.getName());
|
DeclarationDescriptor existingDescriptor = variableClassOrNamespaceDescriptors.get(variableDescriptor.getName());
|
||||||
if (existingDescriptor != null) {
|
if (existingDescriptor != null) {
|
||||||
@@ -162,8 +149,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VariableDescriptor getVariable(@NotNull String name) {
|
public VariableDescriptor getVariable(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||||
DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name);
|
DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name);
|
||||||
if (descriptor instanceof VariableDescriptor) {
|
if (descriptor instanceof VariableDescriptor) {
|
||||||
@@ -187,8 +172,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
getFunctionGroups().put(functionDescriptor.getName(), functionDescriptor);
|
getFunctionGroups().put(functionDescriptor.getName(), functionDescriptor);
|
||||||
allDescriptors.add(functionDescriptor);
|
allDescriptors.add(functionDescriptor);
|
||||||
}
|
}
|
||||||
@@ -196,8 +179,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
Set<FunctionDescriptor> result = Sets.newLinkedHashSet(getFunctionGroups().get(name));
|
Set<FunctionDescriptor> result = Sets.newLinkedHashSet(getFunctionGroups().get(name));
|
||||||
|
|
||||||
result.addAll(getWorkerScope().getFunctions(name));
|
result.addAll(getWorkerScope().getFunctions(name));
|
||||||
@@ -209,23 +190,17 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
String name = typeParameterDescriptor.getName();
|
String name = typeParameterDescriptor.getName();
|
||||||
addClassifierAlias(name, typeParameterDescriptor);
|
addClassifierAlias(name, typeParameterDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) {
|
public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
addClassifierAlias(classDescriptor.getName(), classDescriptor);
|
addClassifierAlias(classDescriptor.getName(), classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
checkForRedeclaration(name, classifierDescriptor);
|
checkForRedeclaration(name, classifierDescriptor);
|
||||||
getVariableClassOrNamespaceDescriptors().put(name, classifierDescriptor);
|
getVariableClassOrNamespaceDescriptors().put(name, classifierDescriptor);
|
||||||
allDescriptors.add(classifierDescriptor);
|
allDescriptors.add(classifierDescriptor);
|
||||||
@@ -233,8 +208,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
checkForRedeclaration(name, namespaceDescriptor);
|
checkForRedeclaration(name, namespaceDescriptor);
|
||||||
getNamespaceAliases().put(name, namespaceDescriptor);
|
getNamespaceAliases().put(name, namespaceDescriptor);
|
||||||
allDescriptors.add(namespaceDescriptor);
|
allDescriptors.add(namespaceDescriptor);
|
||||||
@@ -249,8 +222,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||||
DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name);
|
DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name);
|
||||||
if (descriptor instanceof ClassifierDescriptor) return (ClassifierDescriptor) descriptor;
|
if (descriptor instanceof ClassifierDescriptor) return (ClassifierDescriptor) descriptor;
|
||||||
@@ -263,8 +234,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||||
DeclarationDescriptor oldValue = variableClassOrNamespaceDescriptors.put(namespaceDescriptor.getName(), namespaceDescriptor);
|
DeclarationDescriptor oldValue = variableClassOrNamespaceDescriptors.put(namespaceDescriptor.getName(), namespaceDescriptor);
|
||||||
if (oldValue != null) {
|
if (oldValue != null) {
|
||||||
@@ -275,8 +244,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) {
|
public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||||
DeclarationDescriptor namespaceDescriptor = variableClassOrNamespaceDescriptors.get(name);
|
DeclarationDescriptor namespaceDescriptor = variableClassOrNamespaceDescriptors.get(name);
|
||||||
if (namespaceDescriptor instanceof NamespaceDescriptor) return (NamespaceDescriptor) namespaceDescriptor;
|
if (namespaceDescriptor instanceof NamespaceDescriptor) return (NamespaceDescriptor) namespaceDescriptor;
|
||||||
@@ -285,8 +252,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
NamespaceDescriptor declaredNamespace = getDeclaredNamespace(name);
|
NamespaceDescriptor declaredNamespace = getDeclaredNamespace(name);
|
||||||
if (declaredNamespace != null) return declaredNamespace;
|
if (declaredNamespace != null) return declaredNamespace;
|
||||||
|
|
||||||
@@ -301,8 +266,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ReceiverDescriptor getImplicitReceiver() {
|
public ReceiverDescriptor getImplicitReceiver() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
if (implicitReceiver == null) {
|
if (implicitReceiver == null) {
|
||||||
return super.getImplicitReceiver();
|
return super.getImplicitReceiver();
|
||||||
}
|
}
|
||||||
@@ -311,8 +274,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) {
|
public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
if (this.implicitReceiver != null) {
|
if (this.implicitReceiver != null) {
|
||||||
throw new UnsupportedOperationException("Receiver redeclared");
|
throw new UnsupportedOperationException("Receiver redeclared");
|
||||||
}
|
}
|
||||||
@@ -321,8 +282,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getImplicitReceiversHierarchy(@NotNull List<ReceiverDescriptor> result) {
|
public void getImplicitReceiversHierarchy(@NotNull List<ReceiverDescriptor> result) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
if (implicitReceiver != null && implicitReceiver.exists()) {
|
if (implicitReceiver != null && implicitReceiver.exists()) {
|
||||||
result.add(implicitReceiver);
|
result.add(implicitReceiver);
|
||||||
}
|
}
|
||||||
@@ -344,8 +303,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor);
|
getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,16 +312,12 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
PropertyDescriptor descriptor = getPropertyDescriptorsByFieldNames().get(fieldName);
|
PropertyDescriptor descriptor = getPropertyDescriptorsByFieldNames().get(fieldName);
|
||||||
if (descriptor != null) return descriptor;
|
if (descriptor != null) return descriptor;
|
||||||
return super.getPropertyByFieldReference(fieldName);
|
return super.getPropertyByFieldReference(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VariableDescriptor> getDeclaredVariables() {
|
public List<VariableDescriptor> getDeclaredVariables() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
List<VariableDescriptor> result = Lists.newArrayList();
|
List<VariableDescriptor> result = Lists.newArrayList();
|
||||||
for (DeclarationDescriptor descriptor : getVariableClassOrNamespaceDescriptors().values()) {
|
for (DeclarationDescriptor descriptor : getVariableClassOrNamespaceDescriptors().values()) {
|
||||||
if (descriptor instanceof VariableDescriptor) {
|
if (descriptor instanceof VariableDescriptor) {
|
||||||
@@ -381,8 +334,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WritableScopeImpl setDebugName(@NotNull String debugName) {
|
public WritableScopeImpl setDebugName(@NotNull String debugName) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
super.setDebugName(debugName);
|
super.setDebugName(debugName);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
-46
@@ -31,36 +31,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
this.redeclarationHandler = redeclarationHandler;
|
this.redeclarationHandler = redeclarationHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private LockLevel lockLevel = LockLevel.WRITING;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changeLockLevel(LockLevel lockLevel) {
|
|
||||||
if (lockLevel.ordinal() < this.lockLevel.ordinal()) {
|
|
||||||
throw new IllegalStateException("cannot lower lock level from " + this.lockLevel + " to " + lockLevel);
|
|
||||||
}
|
|
||||||
this.lockLevel = lockLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void checkMayRead() {
|
|
||||||
if (lockLevel != LockLevel.READING && lockLevel != LockLevel.BOTH) {
|
|
||||||
throw new IllegalStateException("cannot read with lock level " + lockLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void checkMayWrite() {
|
|
||||||
if (lockLevel != LockLevel.WRITING && lockLevel != LockLevel.BOTH) {
|
|
||||||
throw new IllegalStateException("cannot write with lock level " + lockLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public WritableScopeWithImports setDebugName(@NotNull String debugName) {
|
public WritableScopeWithImports setDebugName(@NotNull String debugName) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
assert this.debugName == null : this.debugName;
|
assert this.debugName == null : this.debugName;
|
||||||
this.debugName = debugName;
|
this.debugName = debugName;
|
||||||
return this;
|
return this;
|
||||||
@@ -76,16 +47,12 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importScope(@NotNull JetScope imported) {
|
public void importScope(@NotNull JetScope imported) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
getImports().add(0, imported);
|
getImports().add(0, imported);
|
||||||
currentIndividualImportScope = null;
|
currentIndividualImportScope = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getImplicitReceiversHierarchy(@NotNull List<ReceiverDescriptor> result) {
|
public void getImplicitReceiversHierarchy(@NotNull List<ReceiverDescriptor> result) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
super.getImplicitReceiversHierarchy(result);
|
super.getImplicitReceiversHierarchy(result);
|
||||||
// Imported scopes come with their receivers
|
// Imported scopes come with their receivers
|
||||||
// Example: class member resolution scope imports a scope of it's class object
|
// Example: class member resolution scope imports a scope of it's class object
|
||||||
@@ -100,8 +67,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VariableDescriptor getVariable(@NotNull String name) {
|
public VariableDescriptor getVariable(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
// Meaningful lookup goes here
|
// Meaningful lookup goes here
|
||||||
for (JetScope imported : getImports()) {
|
for (JetScope imported : getImports()) {
|
||||||
VariableDescriptor importedDescriptor = imported.getVariable(name);
|
VariableDescriptor importedDescriptor = imported.getVariable(name);
|
||||||
@@ -115,8 +80,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
if (getImports().isEmpty()) {
|
if (getImports().isEmpty()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
@@ -129,8 +92,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
for (JetScope imported : getImports()) {
|
for (JetScope imported : getImports()) {
|
||||||
ClassifierDescriptor importedClassifier = imported.getClassifier(name);
|
ClassifierDescriptor importedClassifier = imported.getClassifier(name);
|
||||||
if (importedClassifier != null) {
|
if (importedClassifier != null) {
|
||||||
@@ -142,8 +103,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
for (JetScope imported : getImports()) {
|
for (JetScope imported : getImports()) {
|
||||||
NamespaceDescriptor importedDescriptor = imported.getNamespace(name);
|
NamespaceDescriptor importedDescriptor = imported.getNamespace(name);
|
||||||
if (importedDescriptor != null) {
|
if (importedDescriptor != null) {
|
||||||
@@ -156,7 +115,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
private WritableScope getCurrentIndividualImportScope() {
|
private WritableScope getCurrentIndividualImportScope() {
|
||||||
if (currentIndividualImportScope == null) {
|
if (currentIndividualImportScope == null) {
|
||||||
WritableScopeImpl writableScope = new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING).setDebugName("Individual import scope");
|
WritableScopeImpl writableScope = new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING).setDebugName("Individual import scope");
|
||||||
writableScope.changeLockLevel(LockLevel.BOTH);
|
|
||||||
importScope(writableScope);
|
importScope(writableScope);
|
||||||
currentIndividualImportScope = writableScope;
|
currentIndividualImportScope = writableScope;
|
||||||
}
|
}
|
||||||
@@ -165,16 +123,12 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor);
|
getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor);
|
getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,40 +25,30 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
return writableWorker.getPropertyByFieldReference(fieldName);
|
return writableWorker.getPropertyByFieldReference(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
return writableWorker.getDeclarationsByLabel(labelName);
|
return writableWorker.getDeclarationsByLabel(labelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public DeclarationDescriptor getContainingDeclaration() {
|
public DeclarationDescriptor getContainingDeclaration() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
return writableWorker.getContainingDeclaration();
|
return writableWorker.getContainingDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public ReceiverDescriptor getImplicitReceiver() {
|
public ReceiverDescriptor getImplicitReceiver() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
return writableWorker.getImplicitReceiver();
|
return writableWorker.getImplicitReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
Set<FunctionDescriptor> result = Sets.newLinkedHashSet();
|
Set<FunctionDescriptor> result = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
result.addAll(writableWorker.getFunctions(name));
|
result.addAll(writableWorker.getFunctions(name));
|
||||||
@@ -73,8 +63,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public VariableDescriptor getVariable(@NotNull String name) {
|
public VariableDescriptor getVariable(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
VariableDescriptor variable = writableWorker.getVariable(name);
|
VariableDescriptor variable = writableWorker.getVariable(name);
|
||||||
if (variable != null) return variable;
|
if (variable != null) return variable;
|
||||||
|
|
||||||
@@ -87,8 +75,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
NamespaceDescriptor namespace = writableWorker.getNamespace(name);
|
NamespaceDescriptor namespace = writableWorker.getNamespace(name);
|
||||||
if (namespace != null) return namespace;
|
if (namespace != null) return namespace;
|
||||||
|
|
||||||
@@ -101,8 +87,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
ClassifierDescriptor classifier = writableWorker.getClassifier(name);
|
ClassifierDescriptor classifier = writableWorker.getClassifier(name);
|
||||||
if (classifier != null) return classifier;
|
if (classifier != null) return classifier;
|
||||||
|
|
||||||
@@ -114,94 +98,68 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addLabeledDeclaration(descriptor); // TODO : review
|
writableWorker.addLabeledDeclaration(descriptor); // TODO : review
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) {
|
public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addVariableDescriptor(variableDescriptor);
|
writableWorker.addVariableDescriptor(variableDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addFunctionDescriptor(functionDescriptor);
|
writableWorker.addFunctionDescriptor(functionDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addTypeParameterDescriptor(typeParameterDescriptor);
|
writableWorker.addTypeParameterDescriptor(typeParameterDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) {
|
public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addClassifierDescriptor(classDescriptor);
|
writableWorker.addClassifierDescriptor(classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addClassifierAlias(name, classifierDescriptor);
|
writableWorker.addClassifierAlias(name, classifierDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addNamespaceAlias(name, namespaceDescriptor);
|
writableWorker.addNamespaceAlias(name, namespaceDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addNamespace(namespaceDescriptor);
|
writableWorker.addNamespace(namespaceDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) {
|
public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
return writableWorker.getDeclaredNamespace(name);
|
return writableWorker.getDeclaredNamespace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyDescriptorByFieldName(@NotNull String fieldName, @NotNull PropertyDescriptor propertyDescriptor) {
|
public void addPropertyDescriptorByFieldName(@NotNull String fieldName, @NotNull PropertyDescriptor propertyDescriptor) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.addPropertyDescriptorByFieldName(fieldName, propertyDescriptor);
|
writableWorker.addPropertyDescriptorByFieldName(fieldName, propertyDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importScope(@NotNull JetScope imported) {
|
public void importScope(@NotNull JetScope imported) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
super.importScope(imported); //
|
super.importScope(imported); //
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) {
|
public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) {
|
||||||
checkMayWrite();
|
|
||||||
|
|
||||||
writableWorker.setImplicitReceiver(implicitReceiver);
|
writableWorker.setImplicitReceiver(implicitReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<DeclarationDescriptor> getAllDescriptors() {
|
public Collection<DeclarationDescriptor> getAllDescriptors() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
if (allDescriptors == null) {
|
if (allDescriptors == null) {
|
||||||
allDescriptors = Lists.newArrayList();
|
allDescriptors = Lists.newArrayList();
|
||||||
allDescriptors.addAll(writableWorker.getAllDescriptors());
|
allDescriptors.addAll(writableWorker.getAllDescriptors());
|
||||||
@@ -212,8 +170,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetScope getOuterScope() {
|
public JetScope getOuterScope() {
|
||||||
checkMayRead();
|
|
||||||
|
|
||||||
return getWorkerScope();
|
return getWorkerScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,8 +194,6 @@ public class JetStandardClasses {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.DO_NOTHING).setDebugName("JetStandardClasses.STANDARD_CLASSES");
|
WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.DO_NOTHING).setDebugName("JetStandardClasses.STANDARD_CLASSES");
|
||||||
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
|
|
||||||
STANDARD_CLASSES = writableScope;
|
STANDARD_CLASSES = writableScope;
|
||||||
writableScope.addClassifierAlias("Unit", getTuple(0));
|
writableScope.addClassifierAlias("Unit", getTuple(0));
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
|||||||
import org.jetbrains.jet.lang.resolve.*;
|
import org.jetbrains.jet.lang.resolve.*;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
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.resolve.scopes.WritableScopeImpl;
|
||||||
import org.jetbrains.jet.plugin.JetFileType;
|
import org.jetbrains.jet.plugin.JetFileType;
|
||||||
|
|
||||||
@@ -134,7 +133,6 @@ public class JetStandardLibrary {
|
|||||||
JetSemanticServices bootstrappingSemanticServices = JetSemanticServices.createSemanticServices(this);
|
JetSemanticServices bootstrappingSemanticServices = JetSemanticServices.createSemanticServices(this);
|
||||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||||
WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope");
|
WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope");
|
||||||
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
// this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations());
|
// this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations());
|
||||||
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
|
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
|
||||||
TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
|
TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
|
||||||
|
|||||||
-1
@@ -140,7 +140,6 @@ public class ExpressionTypingServices {
|
|||||||
|
|
||||||
DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration();
|
DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration();
|
||||||
WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace)).setDebugName("getBlockReturnedType");
|
WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace)).setDebugName("getBlockReturnedType");
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
return getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context);
|
return getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -13,7 +13,6 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
|||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.jet.lang.types.JetStandardClasses;
|
import org.jetbrains.jet.lang.types.JetStandardClasses;
|
||||||
@@ -43,9 +42,7 @@ public class ExpressionTypingUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static WritableScopeImpl newWritableScopeImpl(ExpressionTypingContext context) {
|
public static WritableScopeImpl newWritableScopeImpl(ExpressionTypingContext context) {
|
||||||
WritableScopeImpl scope = new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace));
|
return new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace));
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
return scope;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBoolean(@NotNull JetSemanticServices semanticServices, @NotNull JetType type) {
|
public static boolean isBoolean(@NotNull JetSemanticServices semanticServices, @NotNull JetType type) {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
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.resolve.scopes.WritableScopeImpl;
|
||||||
import org.jetbrains.jet.lang.types.JetStandardLibrary;
|
import org.jetbrains.jet.lang.types.JetStandardLibrary;
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
|||||||
WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING);
|
WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING);
|
||||||
assert classDescriptor instanceof ClassifierDescriptor;
|
assert classDescriptor instanceof ClassifierDescriptor;
|
||||||
scope.addClassifierDescriptor((ClassifierDescriptor) classDescriptor);
|
scope.addClassifierDescriptor((ClassifierDescriptor) classDescriptor);
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -545,7 +545,6 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
JavaSemanticServices javaSemanticServices = new JavaSemanticServices(getProject(), semanticServices, JetTestUtils.DUMMY_TRACE);
|
JavaSemanticServices javaSemanticServices = new JavaSemanticServices(getProject(), semanticServices, JetTestUtils.DUMMY_TRACE);
|
||||||
writableScope.importScope(new JavaPackageScope("", null, javaSemanticServices));
|
writableScope.importScope(new JavaPackageScope("", null, javaSemanticServices));
|
||||||
writableScope.importScope(new JavaPackageScope("java.lang", null, javaSemanticServices));
|
writableScope.importScope(new JavaPackageScope("java.lang", null, javaSemanticServices));
|
||||||
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
return writableScope;
|
return writableScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +641,6 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
trace.record(BindingContext.CLASS, classElement, classDescriptor);
|
trace.record(BindingContext.CLASS, classElement, classDescriptor);
|
||||||
|
|
||||||
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace));
|
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace));
|
||||||
parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
|
|
||||||
// This call has side-effects on the parameterScope (fills it in)
|
// This call has side-effects on the parameterScope (fills it in)
|
||||||
List<TypeParameterDescriptor> typeParameters
|
List<TypeParameterDescriptor> typeParameters
|
||||||
@@ -662,7 +660,6 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
|
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
|
||||||
|
|
||||||
final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace));
|
final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace));
|
||||||
memberDeclarations.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
|
|
||||||
List<JetDeclaration> declarations = classElement.getDeclarations();
|
List<JetDeclaration> declarations = classElement.getDeclarations();
|
||||||
for (JetDeclaration declaration : declarations) {
|
for (JetDeclaration declaration : declarations) {
|
||||||
|
|||||||
Reference in New Issue
Block a user