From a2b779fcd02e8554268ed5ab785c184fd76a39de Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 17 Aug 2011 21:21:44 +0400 Subject: [PATCH 1/3] Migrating BindingTraceContext to a transactional form --- grammar/src/class_members.grm | 2 +- grammar/src/expressions.grm | 2 +- grammar/src/when.grm | 2 +- idea/src/jet/Library.jet | 2 +- .../jet/lang/JetSemanticServices.java | 5 - .../jet/lang/psi/JetAnnotationEntry.java | 6 + .../org/jetbrains/jet/lang/psi/JetCall.java | 3 + .../jet/lang/psi/JetCallExpression.java | 1 + .../jet/lang/psi/JetDelegatorToSuperCall.java | 7 + .../jet/lang/psi/JetDelegatorToThisCall.java | 5 + .../jet/lang/resolve/AnalyzingUtils.java | 4 +- .../jet/lang/resolve/BindingTraceContext.java | 338 +++++++------- .../jet/lang/resolve/ChildBindingTrace.java | 254 +++++++++++ .../lang/resolve/ClassDescriptorResolver.java | 2 +- .../jet/lang/resolve/ScopeWithReceiver.java | 2 +- .../jet/lang/resolve/TopDownAnalyzer.java | 2 +- .../jet/lang/types/JetStandardLibrary.java | 7 +- .../jet/lang/types/JetTypeChecker.java | 353 +++++++++++---- .../jet/lang/types/JetTypeInferrer.java | 67 +++ .../jet/lang/types/TypeSubstitutor.java | 40 +- .../jetbrains/jet/lang/types/TypeUtils.java | 30 +- .../jetbrains/jet/lang/types/Variance.java | 12 + .../types/inference/ConstraintSystem.java | 415 ++++++++++++++++++ 23 files changed, 1271 insertions(+), 290 deletions(-) create mode 100644 idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java create mode 100644 idea/src/org/jetbrains/jet/lang/types/inference/ConstraintSystem.java diff --git a/grammar/src/class_members.grm b/grammar/src/class_members.grm index ac73ca56d1b..addd0c4eb65 100644 --- a/grammar/src/class_members.grm +++ b/grammar/src/class_members.grm @@ -119,7 +119,7 @@ parameter ; object - : "object" SimpleName ":" delegationSpecifier{","}? classBody? // Class body can be optional: this is a declaration + : "object" SimpleName (":" delegationSpecifier{","})? classBody? // Class body can be optional: this is a declaration /** bq. See [Object expressions and Declarations] */ diff --git a/grammar/src/expressions.grm b/grammar/src/expressions.grm index 2b3b21af0c5..fafe44f37f0 100644 --- a/grammar/src/expressions.grm +++ b/grammar/src/expressions.grm @@ -235,7 +235,7 @@ jump // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an expression in parentheses // to put a tuple, write write ((e)) tupleLiteral - : "(" ((SimpleName "=")? expression){","} ")" + : "(" (((SimpleName "=")? expression){","})? ")" ; // one can use "it" as a parameter name diff --git a/grammar/src/when.grm b/grammar/src/when.grm index ebdbcc58502..d6769712963 100644 --- a/grammar/src/when.grm +++ b/grammar/src/when.grm @@ -45,7 +45,7 @@ constantPattern ; tuplePattern - : "(" ((SimpleName "=")? pattern{","})? ")" + : "(" (((SimpleName "=")? pattern){","})? ")" ; bindingPattern diff --git a/idea/src/jet/Library.jet b/idea/src/jet/Library.jet index 9fbf46d6e81..211e49cf2db 100644 --- a/idea/src/jet/Library.jet +++ b/idea/src/jet/Library.jet @@ -100,7 +100,7 @@ class IntRange> : Range, Iterable { } -class Number : Hashable { +abstract class Number : Hashable { abstract val dbl : Double abstract val flt : Float abstract val lng : Long diff --git a/idea/src/org/jetbrains/jet/lang/JetSemanticServices.java b/idea/src/org/jetbrains/jet/lang/JetSemanticServices.java index 1821351ec89..ee82fb84c52 100644 --- a/idea/src/org/jetbrains/jet/lang/JetSemanticServices.java +++ b/idea/src/org/jetbrains/jet/lang/JetSemanticServices.java @@ -50,11 +50,6 @@ public class JetSemanticServices { return new JetTypeInferrer(flowInformationProvider, this).getServices(trace); } -// @NotNull -// public ErrorHandler getErrorHandler() { -// return errorHandler; -// } -// @NotNull public JetTypeChecker getTypeChecker() { return typeChecker; diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java b/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java index 6c5dfb4cb82..8971900a36e 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java @@ -32,6 +32,12 @@ public class JetAnnotationEntry extends JetElement implements JetCall { return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE); } + @Override + public JetExpression getCalleeExpression() { + // Make callee an expression instead of a type reference + throw new UnsupportedOperationException(); // TODO + } + @Override public JetValueArgumentList getValueArgumentList() { return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetCall.java b/idea/src/org/jetbrains/jet/lang/psi/JetCall.java index 6a40027884a..58a62ef1679 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetCall.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetCall.java @@ -10,6 +10,9 @@ import java.util.List; * @author abreslav */ public interface JetCall extends PsiElement { + @Nullable + JetExpression getCalleeExpression(); + @Nullable JetValueArgumentList getValueArgumentList(); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetCallExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetCallExpression.java index f49ff0c8dbe..33ae21cf505 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetCallExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetCallExpression.java @@ -26,6 +26,7 @@ public class JetCallExpression extends JetExpression implements JetCall { return visitor.visitCallExpression(this, data); } + @Override @Nullable public JetExpression getCalleeExpression() { return findChildByClass(JetExpression.class); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java b/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java index 0f4db427370..0fee55e31ec 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java @@ -26,6 +26,13 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J return visitor.visitDelegationToSuperCallSpecifier(this, data); } + @NotNull + @Override + public JetExpression getCalleeExpression() { + // Change the AST so the the callee is an expression + throw new UnsupportedOperationException(); // TODO + } + @Nullable public JetValueArgumentList getValueArgumentList() { return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.java b/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.java index 6e0bb69ba46..c06b8e216b1 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.java @@ -27,6 +27,11 @@ public class JetDelegatorToThisCall extends JetDelegationSpecifier implements Je return visitor.visitDelegationToThisCall(this, data); } + @Override + public JetExpression getCalleeExpression() { + return getThisReference(); + } + @Nullable public JetValueArgumentList getValueArgumentList() { return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST); diff --git a/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java b/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java index 8b13a6c03d5..1c466051715 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java @@ -52,7 +52,7 @@ public class AnalyzingUtils { e.printStackTrace(); BindingTraceContext bindingTraceContext = new BindingTraceContext(); bindingTraceContext.getErrorHandler().genericError(file.getNode(), e.getClass().getSimpleName() + ": " + e.getMessage()); - return new Result(bindingTraceContext, PsiModificationTracker.MODIFICATION_COUNT); + return new Result(bindingTraceContext.getBindingContext(), PsiModificationTracker.MODIFICATION_COUNT); } } } @@ -112,7 +112,7 @@ public class AnalyzingUtils { throw new IllegalStateException("Must be guaranteed not to happen by the parser"); } }, Collections.singletonList(namespace)); - return bindingTraceContext; + return bindingTraceContext.getBindingContext(); } public static void applyHandler(@NotNull ErrorHandler errorHandler, @NotNull BindingContext bindingContext) { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java index b629e475a75..c20ecfc4aea 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java @@ -20,7 +20,7 @@ import java.util.*; /** * @author abreslav */ -public class BindingTraceContext implements BindingContext, BindingTrace { +public class BindingTraceContext implements BindingTrace { private final Map expressionTypes = new HashMap(); private final Map resolutionResults = new HashMap(); private final Map labelResolutionResults = new HashMap(); @@ -46,6 +46,169 @@ public class BindingTraceContext implements BindingContext, BindingTrace { private Map annotationDescriptos = Maps.newHashMap(); private Map> compileTimeValues = Maps.newHashMap(); + private final BindingContext bindingContext = new BindingContext() { + @Override + public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) { + if (declaration instanceof JetNamespace) { + JetNamespace namespace = (JetNamespace) declaration; + return getNamespaceDescriptor(namespace); + } + return declarationsToDescriptors.get(declaration); + } + + public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) { + return namespaceDeclarationsToDescriptors.get(declaration); + } + + @Override + public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) { + return (ClassDescriptor) declarationsToDescriptors.get((JetDeclaration) declaration); + } + + @Override + public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) { + return (TypeParameterDescriptor) declarationsToDescriptors.get(declaration); + } + + @Override + public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) { + return (FunctionDescriptor) declarationsToDescriptors.get(declaration); + } + + @Override + public VariableDescriptor getVariableDescriptor(JetProperty declaration) { + return (VariableDescriptor) declarationsToDescriptors.get(declaration); + } + + @Override + public VariableDescriptor getVariableDescriptor(JetParameter declaration) { + return (VariableDescriptor) declarationsToDescriptors.get(declaration); + } + + @Override + public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) { + return primaryConstructorParameterDeclarationsToPropertyDescriptors.get(primaryConstructorParameter); + } + + @Override + public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) { + return (PropertyDescriptor) declarationsToDescriptors.get(objectDeclarationName); + } + + @Nullable + @Override + public ConstructorDescriptor getConstructorDescriptor(@NotNull JetElement declaration) { + return constructorDeclarationsToDescriptors.get(declaration); + } + + @Override + public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) { + return annotationDescriptos.get(annotationEntry); + } + + @Override + public CompileTimeConstant getCompileTimeValue(JetExpression expression) { + return compileTimeValues.get(expression); + } + + @Override + public JetType resolveTypeReference(JetTypeReference typeReference) { + return types.get(typeReference); + } + + @Override + public JetType getExpressionType(JetExpression expression) { + return expressionTypes.get(expression); + } + + @Override + public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) { + return resolutionResults.get(referenceExpression); + } + + @Override + public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) { + DeclarationDescriptor declarationDescriptor = resolveReferenceExpression(referenceExpression); + if (declarationDescriptor == null) { + return labelResolutionResults.get(referenceExpression); + } + return descriptorToDeclarations.get(getOriginal(declarationDescriptor)); + } + + @Override + public PsiElement getDeclarationPsiElement(@NotNull DeclarationDescriptor descriptor) { + return descriptorToDeclarations.get(getOriginal(descriptor)); + } + + @Override + public boolean isBlock(JetFunctionLiteralExpression expression) { + return !expression.getFunctionLiteral().hasParameterSpecification() && blocks.contains(expression); + } + + @Override + public boolean isStatement(@NotNull JetExpression expression) { + return statements.contains(expression); + } + + @Override + public boolean hasBackingField(@NotNull PropertyDescriptor propertyDescriptor) { + PsiElement declarationPsiElement = getDeclarationPsiElement(propertyDescriptor); + if (declarationPsiElement instanceof JetParameter) { + JetParameter jetParameter = (JetParameter) declarationPsiElement; + return jetParameter.getValOrVarNode() != null || + backingFieldRequired.contains(propertyDescriptor); + } + if (propertyDescriptor.getModifiers().isAbstract()) return false; + PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); + PropertySetterDescriptor setter = propertyDescriptor.getSetter(); + if (getter == null) { + return true; + } + else if (propertyDescriptor.isVar() && setter == null) { + return true; + } + else if (setter != null && !setter.hasBody() && !setter.getModifiers().isAbstract()) { + return true; + } + else if (!getter.hasBody() && !getter.getModifiers().isAbstract()) { + return true; + } + return backingFieldRequired.contains(propertyDescriptor); + } + + @Override + public boolean isVariableReassignment(JetExpression expression) { + return variableReassignments.contains(expression); + } + + public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) { + JetTypeReference typeReference = superCall.getTypeReference(); + if (typeReference == null) return null; + + JetTypeElement typeElement = typeReference.getTypeElement(); + if (!(typeElement instanceof JetUserType)) return null; + + DeclarationDescriptor descriptor = resolveReferenceExpression(((JetUserType) typeElement).getReferenceExpression()); + return descriptor instanceof ConstructorDescriptor ? (ConstructorDescriptor) descriptor : null; + } + + @Override + public JetType getAutoCastType(@NotNull JetExpression expression) { + return autoCasts.get(expression); + } + + @Override + public JetScope getResolutionScope(@NotNull JetExpression expression) { + return resolutionScopes.get(expression); + } + + @Override + public Collection getDiagnostics() { + return diagnostics; + } + + }; + public BindingTraceContext() { } @@ -72,6 +235,11 @@ public class BindingTraceContext implements BindingContext, BindingTrace { diagnostics.addAll(other.diagnostics); } + @Override + public BindingContext getBindingContext() { + return bindingContext; + } + private void safePutAll(Map my, Map other) { assert keySetIntersection(my, other).isEmpty() : keySetIntersection(my, other); @@ -84,7 +252,6 @@ public class BindingTraceContext implements BindingContext, BindingTrace { return keySet; } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @NotNull @@ -196,97 +363,6 @@ public class BindingTraceContext implements BindingContext, BindingTrace { statements.remove(statement); } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - @Override - public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) { - if (declaration instanceof JetNamespace) { - JetNamespace namespace = (JetNamespace) declaration; - return getNamespaceDescriptor(namespace); - } - return declarationsToDescriptors.get(declaration); - } - - public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) { - return namespaceDeclarationsToDescriptors.get(declaration); - } - - @Override - public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) { - return (ClassDescriptor) declarationsToDescriptors.get((JetDeclaration) declaration); - } - - @Override - public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) { - return (TypeParameterDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) { - return (FunctionDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public VariableDescriptor getVariableDescriptor(JetProperty declaration) { - return (VariableDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public VariableDescriptor getVariableDescriptor(JetParameter declaration) { - return (VariableDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) { - return primaryConstructorParameterDeclarationsToPropertyDescriptors.get(primaryConstructorParameter); - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) { - return (PropertyDescriptor) declarationsToDescriptors.get(objectDeclarationName); - } - - @Nullable - @Override - public ConstructorDescriptor getConstructorDescriptor(@NotNull JetElement declaration) { - return constructorDeclarationsToDescriptors.get(declaration); - } - - @Override - public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) { - return annotationDescriptos.get(annotationEntry); - } - - @Override - public CompileTimeConstant getCompileTimeValue(JetExpression expression) { - return compileTimeValues.get(expression); - } - - @Override - public JetType resolveTypeReference(JetTypeReference typeReference) { - return types.get(typeReference); - } - - @Override - public JetType getExpressionType(JetExpression expression) { - return expressionTypes.get(expression); - } - - @Override - public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) { - return resolutionResults.get(referenceExpression); - } - - @Override - public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) { - DeclarationDescriptor declarationDescriptor = resolveReferenceExpression(referenceExpression); - if (declarationDescriptor == null) { - return labelResolutionResults.get(referenceExpression); - } - return descriptorToDeclarations.get(getOriginal(declarationDescriptor)); - } - private DeclarationDescriptor getOriginal(DeclarationDescriptor declarationDescriptor) { if (declarationDescriptor instanceof VariableAsFunctionDescriptor) { VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) declarationDescriptor; @@ -295,78 +371,6 @@ public class BindingTraceContext implements BindingContext, BindingTrace { return declarationDescriptor.getOriginal(); } - @Override - public PsiElement getDeclarationPsiElement(@NotNull DeclarationDescriptor descriptor) { - return descriptorToDeclarations.get(getOriginal(descriptor)); - } - - @Override - public boolean isBlock(JetFunctionLiteralExpression expression) { - return !expression.getFunctionLiteral().hasParameterSpecification() && blocks.contains(expression); - } - - @Override - public boolean isStatement(@NotNull JetExpression expression) { - return statements.contains(expression); - } - - @Override - public boolean hasBackingField(@NotNull PropertyDescriptor propertyDescriptor) { - PsiElement declarationPsiElement = getDeclarationPsiElement(propertyDescriptor); - if (declarationPsiElement instanceof JetParameter) { - JetParameter jetParameter = (JetParameter) declarationPsiElement; - return jetParameter.getValOrVarNode() != null || - backingFieldRequired.contains(propertyDescriptor); - } - if (propertyDescriptor.getModifiers().isAbstract()) return false; - PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); - PropertySetterDescriptor setter = propertyDescriptor.getSetter(); - if (getter == null) { - return true; - } - else if (propertyDescriptor.isVar() && setter == null) { - return true; - } - else if (setter != null && !setter.hasBody() && !setter.getModifiers().isAbstract()) { - return true; - } - else if (!getter.hasBody() && !getter.getModifiers().isAbstract()) { - return true; - } - return backingFieldRequired.contains(propertyDescriptor); - } - - @Override - public boolean isVariableReassignment(JetExpression expression) { - return variableReassignments.contains(expression); - } - - public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) { - JetTypeReference typeReference = superCall.getTypeReference(); - if (typeReference == null) return null; - - JetTypeElement typeElement = typeReference.getTypeElement(); - if (!(typeElement instanceof JetUserType)) return null; - - DeclarationDescriptor descriptor = resolveReferenceExpression(((JetUserType) typeElement).getReferenceExpression()); - return descriptor instanceof ConstructorDescriptor ? (ConstructorDescriptor) descriptor : null; - } - - @Override - public JetType getAutoCastType(@NotNull JetExpression expression) { - return autoCasts.get(expression); - } - - @Override - public JetScope getResolutionScope(@NotNull JetExpression expression) { - return resolutionScopes.get(expression); - } - - @Override - public Collection getDiagnostics() { - return diagnostics; - } - @Override public void markAsProcessed(@NotNull JetExpression expression) { processed.add(expression); @@ -377,8 +381,4 @@ public class BindingTraceContext implements BindingContext, BindingTrace { return processed.contains(expression); } - @Override - public BindingContext getBindingContext() { - return this; - } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java b/idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java new file mode 100644 index 00000000000..10888682477 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java @@ -0,0 +1,254 @@ +package org.jetbrains.jet.lang.resolve; + +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.JetDiagnostic; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.types.JetType; + +import java.util.Collection; + +/** + * @author abreslav + */ +public class ChildBindingTrace extends BindingTraceContext { + + private final BindingContext parentBindingContext; + + private final BindingContext bindingContext = new BindingContext() { + @Override + @Deprecated + public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) { + DeclarationDescriptor value = ChildBindingTrace.super.getBindingContext().getDeclarationDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getDeclarationDescriptor(declaration); + } + + @Override + public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) { + NamespaceDescriptor value = ChildBindingTrace.super.getBindingContext().getNamespaceDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getNamespaceDescriptor(declaration); + } + + @Override + public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) { + ClassDescriptor value = ChildBindingTrace.super.getBindingContext().getClassDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getClassDescriptor(declaration); + } + + @Override + public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) { + TypeParameterDescriptor value = ChildBindingTrace.super.getBindingContext().getTypeParameterDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getTypeParameterDescriptor(declaration); + } + + @Override + public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) { + FunctionDescriptor value = ChildBindingTrace.super.getBindingContext().getFunctionDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getFunctionDescriptor(declaration); + } + + @Override + public ConstructorDescriptor getConstructorDescriptor(JetElement declaration) { + ConstructorDescriptor value = ChildBindingTrace.super.getBindingContext().getConstructorDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getConstructorDescriptor(declaration); + } + + @Override + public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) { + AnnotationDescriptor value = ChildBindingTrace.super.getBindingContext().getAnnotationDescriptor(annotationEntry); + if (value != null) { + return value; + } + return parentBindingContext.getAnnotationDescriptor(annotationEntry); + } + + @Override + @Nullable + public CompileTimeConstant getCompileTimeValue(JetExpression expression) { + return parentBindingContext.getCompileTimeValue(expression); + } + + @Override + public VariableDescriptor getVariableDescriptor(JetProperty declaration) { + VariableDescriptor value = ChildBindingTrace.super.getBindingContext().getVariableDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getVariableDescriptor(declaration); + } + + @Override + public VariableDescriptor getVariableDescriptor(JetParameter declaration) { + VariableDescriptor value = ChildBindingTrace.super.getBindingContext().getVariableDescriptor(declaration); + if (value != null) { + return value; + } + return parentBindingContext.getVariableDescriptor(declaration); + } + + @Override + public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) { + PropertyDescriptor value = ChildBindingTrace.super.getBindingContext().getPropertyDescriptor(primaryConstructorParameter); + if (value != null) { + return value; + } + return parentBindingContext.getPropertyDescriptor(primaryConstructorParameter); + } + + @Override + public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) { + PropertyDescriptor value = ChildBindingTrace.super.getBindingContext().getPropertyDescriptor(objectDeclarationName); + if (value != null) { + return value; + } + return parentBindingContext.getPropertyDescriptor(objectDeclarationName); + } + + @Override + public JetType getExpressionType(JetExpression expression) { + JetType value = ChildBindingTrace.super.getBindingContext().getExpressionType(expression); + if (value != null) { + return value; + } + return parentBindingContext.getExpressionType(expression); + } + + @Override + public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) { + DeclarationDescriptor value = ChildBindingTrace.super.getBindingContext().resolveReferenceExpression(referenceExpression); + if (value != null) { + return value; + } + return parentBindingContext.resolveReferenceExpression(referenceExpression); + } + + @Override + public JetType resolveTypeReference(JetTypeReference typeReference) { + JetType value = ChildBindingTrace.super.getBindingContext().resolveTypeReference(typeReference); + if (value != null) { + return value; + } + return parentBindingContext.resolveTypeReference(typeReference); + } + + @Override + public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) { + PsiElement value = ChildBindingTrace.super.getBindingContext().resolveToDeclarationPsiElement(referenceExpression); + if (value != null) { + return value; + } + return parentBindingContext.resolveToDeclarationPsiElement(referenceExpression); + } + + @Override + public PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor) { + PsiElement value = ChildBindingTrace.super.getBindingContext().getDeclarationPsiElement(descriptor); + if (value != null) { + return value; + } + return parentBindingContext.getDeclarationPsiElement(descriptor); + } + + @Override + public boolean isBlock(JetFunctionLiteralExpression expression) { + boolean value = ChildBindingTrace.super.getBindingContext().isBlock(expression); + if (!value) { + return value; + } + return parentBindingContext.isBlock(expression); + } + + @Override + public boolean isStatement(JetExpression expression) { + boolean value = ChildBindingTrace.super.getBindingContext().isStatement(expression); + if (!value) { + return value; + } + return parentBindingContext.isStatement(expression); + } + + @Override + public boolean hasBackingField(PropertyDescriptor propertyDescriptor) { + boolean value = ChildBindingTrace.super.getBindingContext().hasBackingField(propertyDescriptor); + if (!value) { + return value; + } + return parentBindingContext.hasBackingField(propertyDescriptor); + } + + @Override + public boolean isVariableReassignment(JetExpression expression) { + boolean value = ChildBindingTrace.super.getBindingContext().isVariableReassignment(expression); + if (!value) { + return value; + } + return parentBindingContext.isVariableReassignment(expression); + } + + @Override + public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) { + ConstructorDescriptor value = ChildBindingTrace.super.getBindingContext().resolveSuperConstructor(superCall); + if (value != null) { + return value; + } + return parentBindingContext.resolveSuperConstructor(superCall); + } + + @Override + @Nullable + public JetType getAutoCastType(@NotNull JetExpression expression) { + JetType value = ChildBindingTrace.super.getBindingContext().getAutoCastType(expression); + if (value != null) { + return value; + } + return parentBindingContext.getAutoCastType(expression); + } + + @Override + @Nullable + public JetScope getResolutionScope(@NotNull JetExpression expression) { + JetScope value = ChildBindingTrace.super.getBindingContext().getResolutionScope(expression); + if (value != null) { + return value; + } + return parentBindingContext.getResolutionScope(expression); + } + + @Override + public Collection getDiagnostics() { + // This deliberately returns only my own diagnostics + return ChildBindingTrace.super.getBindingContext().getDiagnostics(); + } + }; + + public ChildBindingTrace(BindingContext parent) { + this.parentBindingContext = parent; + } + + @Override + public BindingContext getBindingContext() { + return parentBindingContext; + } +} diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java index 9e3e747c234..f7ee75d5290 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java @@ -140,7 +140,7 @@ public class ClassDescriptorResolver { } descriptor.setTypeParameterDescriptors(typeParameters); - descriptor.setOpen(classElement.hasModifier(JetTokens.OPEN_KEYWORD)); + descriptor.setOpen(classElement.hasModifier(JetTokens.OPEN_KEYWORD) || classElement.hasModifier(JetTokens.ABSTRACT_KEYWORD)); trace.recordDeclarationResolution(classElement, descriptor); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java b/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java index db27c4cfa65..32ef6ae7b1b 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java @@ -37,7 +37,7 @@ public class ScopeWithReceiver extends JetScopeImpl { // return false; // } // // TODO : in case of inferred type arguments, substitute the receiver type first -// return typeChecker.isSubtypeOf(receiverType, functionReceiverType); +// return typeChecker.startForPairOfTypes(receiverType, functionReceiverType); // } // }); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index 567db243537..b6ad9bdfd55 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -31,7 +31,7 @@ public class TopDownAnalyzer { private final Map functions = Maps.newLinkedHashMap(); private final Map constructors = Maps.newLinkedHashMap(); - private final Map properties = new LinkedHashMap(); + private final Map properties = Maps.newLinkedHashMap(); private final Map declaringScopes = Maps.newHashMap(); private final Set primaryConstructorParameterProperties = Sets.newHashSet(); diff --git a/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index f31b5c56da5..29c67d84591 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -28,7 +28,8 @@ public class JetStandardLibrary { // private static final Map standardLibraryCache = new HashMap(); // TODO : double checked locking - synchronized public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) { + synchronized + public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) { if (cachedLibrary == null) { cachedLibrary = new JetStandardLibrary(project); } @@ -55,8 +56,8 @@ public class JetStandardLibrary { private final ClassDescriptor arrayClass; private final ClassDescriptor iterableClass; private final ClassDescriptor typeInfoClass; - private final JetType byteType; + private final JetType byteType; private final JetType charType; private final JetType shortType; private final JetType intType; @@ -86,7 +87,7 @@ public class JetStandardLibrary { // bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations()); bootstrappingTDA.processStandardLibraryNamespace(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace()); this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope(); - AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingTraceContext); + AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingTraceContext.getBindingContext()); this.byteClass = (ClassDescriptor) libraryScope.getClassifier("Byte"); this.charClass = (ClassDescriptor) libraryScope.getClassifier("Char"); diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java index 11f7564f3d4..ba36527a44e 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java @@ -313,28 +313,10 @@ public class JetTypeChecker { return false; } - public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) { - if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) { - return true; - } - if (!supertype.isNullable() && subtype.isNullable()) { - return false; - } - if (JetStandardClasses.isNothing(subtype)) { - return true; - } - @Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype); - if (closestSupertype == null) { - return false; - } - - return checkSubtypeForTheSameConstructor(closestSupertype, supertype); - } - // This method returns the supertype of the first parameter that has the same constructor // as the second parameter, applying the substitution of type arguments to it @Nullable - private JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { + private static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { TypeConstructor constructor = subtype.getConstructor(); if (constructor.equals(supertype.getConstructor())) { return subtype; @@ -348,75 +330,270 @@ public class JetTypeChecker { return null; } - private boolean checkSubtypeForTheSameConstructor(@NotNull JetType subtype, @NotNull JetType supertype) { - TypeConstructor constructor = subtype.getConstructor(); - assert constructor.equals(supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor(); - - List subArguments = subtype.getArguments(); - List superArguments = supertype.getArguments(); - List parameters = constructor.getParameters(); - for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) { - TypeParameterDescriptor parameter = parameters.get(i); - TypeProjection subArgument = subArguments.get(i); - TypeProjection superArgument = superArguments.get(i); - - JetType subArgumentType = subArgument.getType(); - JetType superArgumentType = superArgument.getType(); - switch (parameter.getVariance()) { - case INVARIANT: - switch (superArgument.getProjectionKind()) { - case INVARIANT: - if (!subArgumentType.equals(superArgumentType)) { - return false; - } - break; - case OUT_VARIANCE: - if (!subArgument.getProjectionKind().allowsOutPosition()) { - return false; - } - if (!isSubtypeOf(subArgumentType, superArgumentType)) { - return false; - } - break; - case IN_VARIANCE: - if (!subArgument.getProjectionKind().allowsInPosition()) { - return false; - } - if (!isSubtypeOf(superArgumentType, subArgumentType)) { - return false; - } - break; - } - break; - case IN_VARIANCE: - switch (superArgument.getProjectionKind()) { - case INVARIANT: - case IN_VARIANCE: - if (!isSubtypeOf(superArgumentType, subArgumentType)) { - return false; - } - break; - case OUT_VARIANCE: - if (!isSubtypeOf(subArgumentType, superArgumentType)) { - return false; - } - break; - } - break; - case OUT_VARIANCE: - switch (superArgument.getProjectionKind()) { - case INVARIANT: - case OUT_VARIANCE: - case IN_VARIANCE: - if (!isSubtypeOf(subArgumentType, superArgumentType)) { - return false; - } - break; - } - break; - } - } - return true; + public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) { + return new TypeCheckingProcedure().run(subtype, supertype); } + private static class OldProcedure { + public static boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) { + if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) { + return true; + } + if (!supertype.isNullable() && subtype.isNullable()) { + return false; + } + if (JetStandardClasses.isNothing(subtype)) { + return true; + } + @Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype); + if (closestSupertype == null) { + return false; + } + + return checkSubtypeForTheSameConstructor(closestSupertype, supertype); + } + + private static boolean checkSubtypeForTheSameConstructor(@NotNull JetType subtype, @NotNull JetType supertype) { + TypeConstructor constructor = subtype.getConstructor(); + assert constructor.equals(supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor(); + + List subArguments = subtype.getArguments(); + List superArguments = supertype.getArguments(); + List parameters = constructor.getParameters(); + boolean status = true; + for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) { + TypeParameterDescriptor parameter = parameters.get(i); + TypeProjection subArgument = subArguments.get(i); + TypeProjection superArgument = superArguments.get(i); + + JetType subArgumentType = subArgument.getType(); + JetType superArgumentType = superArgument.getType(); + switch (parameter.getVariance()) { + case INVARIANT: + switch (superArgument.getProjectionKind()) { + case INVARIANT: + status = subArgumentType.equals(superArgumentType); + break; + case OUT_VARIANCE: + if (!subArgument.getProjectionKind().allowsOutPosition()) { + status = false; + } else { + status = !isSubtypeOf(subArgumentType, superArgumentType); + } + break; + case IN_VARIANCE: + if (!subArgument.getProjectionKind().allowsInPosition()) { + status = false; + } else { + status = isSubtypeOf(superArgumentType, subArgumentType); + } + break; + } + break; + case IN_VARIANCE: + switch (superArgument.getProjectionKind()) { + case INVARIANT: + case IN_VARIANCE: + status = isSubtypeOf(superArgumentType, subArgumentType); + break; + case OUT_VARIANCE: + status = isSubtypeOf(subArgumentType, superArgumentType); + break; + } + break; + case OUT_VARIANCE: + switch (superArgument.getProjectionKind()) { + case INVARIANT: + case OUT_VARIANCE: + case IN_VARIANCE: + status = isSubtypeOf(subArgumentType, superArgumentType); + break; + } + break; + } + if (!status) { + return false; + } + } + return true; + } + } + + public static abstract class AbstractTypeCheckingProcedure { + + protected enum StatusAction { + PROCEED(false), + DONE_WITH_CURRENT_TYPE(true), + ABORT_ALL(true); + + private final boolean abort; + + private StatusAction(boolean abort) { + this.abort = abort; + } + + public boolean isAbort() { + return abort; + } + } + + public final T run(@NotNull JetType subtype, @NotNull JetType supertype) { + proceedOrStop(subtype, supertype); + return result(); + } + + protected abstract StatusAction startForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype); + + protected abstract StatusAction noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype); + + protected abstract StatusAction equalTypesRequired(@NotNull JetType subArgumentType, @NotNull JetType superArgumentType); + + protected abstract StatusAction varianceConflictFound(@NotNull TypeProjection subArgument, @NotNull TypeProjection superArgument); + + protected abstract StatusAction doneForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype); + + protected abstract T result(); + + private StatusAction proceedOrStop(@NotNull JetType subtype, @NotNull JetType supertype) { + StatusAction statusAction = startForPairOfTypes(subtype, supertype); + if (statusAction.isAbort()) { + return statusAction; + } + + JetType closestSupertype = findCorrespondingSupertype(subtype, supertype); + if (closestSupertype == null) { + return noCorrespondingSupertype(subtype, supertype); + } + + proceed(closestSupertype, supertype); + return doneForPairOfTypes(subtype, supertype); + } + + private void proceed(@NotNull JetType subtype, @NotNull JetType supertype) { + TypeConstructor constructor = subtype.getConstructor(); + assert constructor.equals(supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor(); + + List subArguments = subtype.getArguments(); + List superArguments = supertype.getArguments(); + List parameters = constructor.getParameters(); + + loop: + for (int i = 0; i < parameters.size(); i++) { + TypeParameterDescriptor parameter = parameters.get(i); + TypeProjection subArgument = subArguments.get(i); + TypeProjection superArgument = superArguments.get(i); + + JetType subArgumentType = subArgument.getType(); + JetType superArgumentType = superArgument.getType(); + + StatusAction action = null; + switch (parameter.getVariance()) { + case INVARIANT: + switch (superArgument.getProjectionKind()) { + case INVARIANT: + action = equalTypesRequired(subArgumentType, superArgumentType); + break; + case OUT_VARIANCE: + if (!subArgument.getProjectionKind().allowsOutPosition()) { + action = varianceConflictFound(subArgument, superArgument); + } + else { + action = proceedOrStop(subArgumentType, superArgumentType); + } + break; + case IN_VARIANCE: + if (!subArgument.getProjectionKind().allowsInPosition()) { + action = varianceConflictFound(subArgument, superArgument); + } + else { + action = proceedOrStop(superArgumentType, subArgumentType); + } + break; + } + break; + case IN_VARIANCE: + switch (superArgument.getProjectionKind()) { + case INVARIANT: + case IN_VARIANCE: + action = proceedOrStop(superArgumentType, subArgumentType); + break; + case OUT_VARIANCE: + action = proceedOrStop(subArgumentType, superArgumentType); + break; + } + break; + case OUT_VARIANCE: + switch (superArgument.getProjectionKind()) { + case INVARIANT: + case OUT_VARIANCE: + case IN_VARIANCE: + action = proceedOrStop(subArgumentType, superArgumentType); + break; + } + break; + } + switch (action) { + case ABORT_ALL: break loop; + case DONE_WITH_CURRENT_TYPE: + default: + } + } + } + + } + + + private static class TypeCheckingProcedure extends AbstractTypeCheckingProcedure { + + private boolean result = true; + + private StatusAction fail() { + result = false; + return StatusAction.ABORT_ALL; + } + + @Override + public StatusAction startForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) { + if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) { + return StatusAction.DONE_WITH_CURRENT_TYPE; + } + if (!supertype.isNullable() && subtype.isNullable()) { + return fail(); + } + if (JetStandardClasses.isNothing(subtype)) { + return StatusAction.DONE_WITH_CURRENT_TYPE; + } + return StatusAction.PROCEED; + } + + @Override + protected StatusAction noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { + return fail(); + } + + @Override + protected StatusAction equalTypesRequired(@NotNull JetType subArgumentType, @NotNull JetType superArgumentType) { + if (!subArgumentType.equals(superArgumentType)) { + return fail(); + } + return StatusAction.PROCEED; + } + + @Override + protected StatusAction varianceConflictFound(@NotNull TypeProjection subArgument, @NotNull TypeProjection superArgument) { + return fail(); + } + + @Override + protected StatusAction doneForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) { + return StatusAction.PROCEED; + } + + @Override + protected Boolean result() { + return result; + } + + + } } diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 4c201d48c4c..efe39889cdc 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -20,6 +20,7 @@ import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver; import org.jetbrains.jet.lang.resolve.constants.ErrorValue; +import org.jetbrains.jet.lang.types.inference.ConstraintSystem; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.resolve.DescriptorRenderer; import org.jetbrains.jet.lang.resolve.constants.StringValue; @@ -533,6 +534,71 @@ public class JetTypeInferrer { return result; } + @Nullable + private JetType resolveCall( + @NotNull JetScope scope, + @NotNull JetCall call, + @NotNull JetType expectedType + ) { + if (call.getTypeArguments().isEmpty()) { + JetExpression calleeExpression = call.getCalleeExpression(); + Collection candidates; + if (calleeExpression instanceof JetSimpleNameExpression) { + JetSimpleNameExpression expression = (JetSimpleNameExpression) calleeExpression; + candidates = scope.getFunctionGroup(expression.getReferencedName()).getFunctionDescriptors(); + } + else { + throw new UnsupportedOperationException("Type argument inference not implemented"); + } + + assert candidates.size() == 1; + + FunctionDescriptor candidate = candidates.iterator().next(); + + assert candidate.getTypeParameters().size() == call.getTypeArguments().size(); + + ConstraintSystem constraintSystem = new ConstraintSystem(); + for (TypeParameterDescriptor typeParameterDescriptor : candidate.getTypeParameters()) { + constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT); // TODO + } + + Iterator parameters = candidate.getValueParameters().iterator(); + for (JetValueArgument valueArgument : call.getValueArguments()) { + assert !valueArgument.isNamed(); + ValueParameterDescriptor valueParameterDescriptor = parameters.next(); + JetExpression expression = valueArgument.getArgumentExpression(); + JetType type = getType(scope, expression, false, NO_EXPECTED_TYPE); + constraintSystem.addSubtypingConstraint(type, valueParameterDescriptor.getOutType()); + } + + if (expectedType != NO_EXPECTED_TYPE) { + System.out.println("expectedType = " + expectedType); + constraintSystem.addSubtypingConstraint(candidate.getReturnType(), expectedType); + } + + ConstraintSystem.Solution solution = constraintSystem.solve(); + if (!solution.isSuccessful()) { + trace.getErrorHandler().genericError(calleeExpression.getNode(), "Type inference failed"); +// for (Inconsistency inconsistency : solution.getInconsistencies()) { +// System.out.println("inconsistency = " + inconsistency); +// } + return null; + } + else { + for (TypeParameterDescriptor typeParameterDescriptor : candidate.getTypeParameters()) { + JetType value = solution.getValue(typeParameterDescriptor); + System.out.println("typeParameterDescriptor = " + typeParameterDescriptor); + System.out.println("value = " + value); + } + return solution.getSubstitutor().substitute(candidate.getReturnType(), Variance.INVARIANT); // TODO + } +// return null; + } + else { + throw new UnsupportedOperationException("Explicit type arguments not implemented"); + } + } + @Nullable private JetType resolveCall( @NotNull JetScope scope, @@ -2230,6 +2296,7 @@ public class JetTypeInferrer { @Override public JetType visitCallExpression(JetCallExpression expression, TypeInferenceContext context) { +// return context.services.checkType(context.services.resolveCall(context.scope, expression, context.expectedType), expression, context); return context.services.checkType(getCallExpressionType(null, expression, context), expression, context); } diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java b/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java index 8894d010bfb..441054b7b3f 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java @@ -15,6 +15,30 @@ import java.util.Map; */ public class TypeSubstitutor { + public interface TypeSubstitution { + @Nullable + TypeProjection get(TypeConstructor key); + boolean isEmpty(); + } + + public static class MapToTypeSubstitutionAdapter implements TypeSubstitution { + private final @NotNull Map substitutionContext; + + public MapToTypeSubstitutionAdapter(@NotNull Map substitutionContext) { + this.substitutionContext = substitutionContext; + } + + @Override + public TypeProjection get(TypeConstructor key) { + return substitutionContext.get(key); + } + + @Override + public boolean isEmpty() { + return substitutionContext.isEmpty(); + } + } + public static final TypeSubstitutor EMPTY = create(Collections.emptyMap()); public static final class SubstitutionException extends Exception { @@ -23,8 +47,12 @@ public class TypeSubstitutor { } } + public static TypeSubstitutor create(@NotNull TypeSubstitution substitution) { + return new TypeSubstitutor(substitution); + } + public static TypeSubstitutor create(@NotNull Map substitutionContext) { - return new TypeSubstitutor(substitutionContext); + return create(new MapToTypeSubstitutionAdapter(substitutionContext)); } public static TypeSubstitutor create(@NotNull JetType context) { @@ -33,9 +61,9 @@ public class TypeSubstitutor { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private final @NotNull Map substitutionContext; + private final @NotNull TypeSubstitution substitutionContext; - private TypeSubstitutor(@NotNull Map substitutionContext) { + private TypeSubstitutor(@NotNull TypeSubstitution substitutionContext) { this.substitutionContext = substitutionContext; } @@ -109,7 +137,7 @@ public class TypeSubstitutor { @NotNull private TypeProjection substituteInProjection( - @NotNull Map substitutionContext, + @NotNull TypeSubstitution substitutionContext, @NotNull TypeProjection passedProjection, @NotNull TypeParameterDescriptor correspondingTypeParameter, @NotNull Variance contextCallSiteVariance) throws SubstitutionException { @@ -181,10 +209,6 @@ public class TypeSubstitutor { return new TypeProjection(effectiveProjectionKindValue, specializeType(effectiveTypeValue, effectiveContextVariance)); } - /*package*/ void addSubstitution(@NotNull TypeConstructor typeConstructor, @NotNull TypeProjection typeProjection) { - substitutionContext.put(typeConstructor, typeProjection); - } - private static Variance asymmetricOr(Variance a, Variance b) { return a == Variance.INVARIANT ? b : a; } diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java b/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java index 7e6318ad190..c20be85a0c1 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -50,6 +50,9 @@ public class TypeUtils { StringBuilder debugName = new StringBuilder(); boolean nullable = false; + Set resultingTypes = Sets.newHashSet(); + + outer: for (Iterator iterator = types.iterator(); iterator.hasNext();) { JetType type = iterator.next(); @@ -63,9 +66,17 @@ public class TypeUtils { } return type; } + else { + for (JetType other : types) { + if (!type.equals(other) && typeChecker.isSubtypeOf(other, type)) { + continue outer; + } + } + } nullable |= type.isNullable(); + resultingTypes.add(type); debugName.append(type.toString()); if (iterator.hasNext()) { debugName.append(" & "); @@ -79,11 +90,11 @@ public class TypeUtils { false, debugName.toString(), Collections.emptyList(), - types); + resultingTypes); - JetScope[] scopes = new JetScope[types.size()]; + JetScope[] scopes = new JetScope[resultingTypes.size()]; int i = 0; - for (JetType type : types) { + for (JetType type : resultingTypes) { scopes[i] = type.getMemberScope(); i++; } @@ -217,12 +228,15 @@ public class TypeUtils { */ @NotNull public static TypeSubstitutor buildDeepSubstitutor(@NotNull JetType type) { - TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(Maps.newHashMap()); - fillInDeepSubstitutor(type, typeSubstitutor); + HashMap substitution = Maps.newHashMap(); + TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution); + // we use the mutability of the map here + fillInDeepSubstitutor(type, typeSubstitutor, substitution); return typeSubstitutor; } - private static void fillInDeepSubstitutor(JetType context, TypeSubstitutor substitutor) { + // we use the mutability of the substitution map here + private static void fillInDeepSubstitutor(JetType context, TypeSubstitutor substitutor, Map substitution) { List parameters = context.getConstructor().getParameters(); List arguments = context.getArguments(); for (int i = 0; i < arguments.size(); i++) { @@ -232,10 +246,10 @@ public class TypeUtils { JetType substitute = substitutor.substitute(argument.getType(), Variance.INVARIANT); assert substitute != null; TypeProjection substitutedTypeProjection = new TypeProjection(argument.getProjectionKind(), substitute); - substitutor.addSubstitution(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection); + substitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection); } for (JetType supertype : context.getConstructor().getSupertypes()) { - fillInDeepSubstitutor(supertype, substitutor); + fillInDeepSubstitutor(supertype, substitutor, substitution); } } diff --git a/idea/src/org/jetbrains/jet/lang/types/Variance.java b/idea/src/org/jetbrains/jet/lang/types/Variance.java index 4f1cdd3f281..b384b839eea 100644 --- a/idea/src/org/jetbrains/jet/lang/types/Variance.java +++ b/idea/src/org/jetbrains/jet/lang/types/Variance.java @@ -38,6 +38,18 @@ public enum Variance { throw new IllegalStateException(); } + public Variance opposite() { + switch (this) { + case INVARIANT: + return INVARIANT; + case IN_VARIANCE: + return OUT_VARIANCE; + case OUT_VARIANCE: + return IN_VARIANCE; + } + throw new IllegalStateException("Impossible variance: " + this); + } + @Override public String toString() { return label; diff --git a/idea/src/org/jetbrains/jet/lang/types/inference/ConstraintSystem.java b/idea/src/org/jetbrains/jet/lang/types/inference/ConstraintSystem.java new file mode 100644 index 00000000000..7e42f7d2939 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/types/inference/ConstraintSystem.java @@ -0,0 +1,415 @@ +package org.jetbrains.jet.lang.types.inference; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; +import org.jetbrains.jet.lang.types.*; + +import java.util.Map; +import java.util.Set; + +/** + * @author abreslav + */ +public class ConstraintSystem { + +// private static final Supplier> SET_SUPPLIER = new Supplier>() { +// @Override +// public Set get() { +// return Sets.newHashSet(); +// } +// }; + + private static class LoopInTypeVariableConstraintsException extends RuntimeException { + private LoopInTypeVariableConstraintsException() { + } + + private LoopInTypeVariableConstraintsException(String message) { + super(message); + } + + private LoopInTypeVariableConstraintsException(String message, Throwable cause) { + super(message, cause); + } + + private LoopInTypeVariableConstraintsException(Throwable cause) { + super(cause); + } + } + + public static abstract class TypeValue { + private final Set upperBounds = Sets.newHashSet(); + private final Set lowerBounds = Sets.newHashSet(); + + @NotNull + public Set getUpperBounds() { + return upperBounds; + } + + @NotNull + public Set getLowerBounds() { + return lowerBounds; + } + + @Nullable + public abstract KnownType getValue(); + } + + private static class UnknownType extends TypeValue { + + private final TypeParameterDescriptor typeParameterDescriptor; + private final Variance positionVariance; + private KnownType value; + private boolean beingComputed = false; + + private UnknownType(TypeParameterDescriptor typeParameterDescriptor, Variance positionVariance) { + this.typeParameterDescriptor = typeParameterDescriptor; + this.positionVariance = positionVariance; + } + + @NotNull + public TypeParameterDescriptor getTypeParameterDescriptor() { + return typeParameterDescriptor; + } + + @Override + public KnownType getValue() { + if (beingComputed) { + throw new LoopInTypeVariableConstraintsException(); + } + if (value == null) { + JetTypeChecker typeChecker = JetTypeChecker.INSTANCE; + beingComputed = true; + try { + if (positionVariance == Variance.IN_VARIANCE) { + // maximal solution + throw new UnsupportedOperationException(); + } + else { + // minimal solution + + Set lowerBounds = getLowerBounds(); + if (!lowerBounds.isEmpty()) { + Set types = getTypes(lowerBounds); + + JetType commonSupertype = typeChecker.commonSupertype(types); + for (TypeValue upperBound : getUpperBounds()) { + if (!typeChecker.isSubtypeOf(commonSupertype, upperBound.getValue().getType())) { + value = null; + } + } + + System.out.println("minimal solution from lowerbounds for " + this + " is " + commonSupertype); + value = new KnownType(commonSupertype); + } + else { + Set upperBounds = getUpperBounds(); + Set types = getTypes(upperBounds); + JetType intersect = TypeUtils.intersect(typeChecker, types); + + value = new KnownType(intersect); + } + } + } + finally { + beingComputed = false; + } + } + + return value; + } + + private Set getTypes(Set lowerBounds) { + Set types = Sets.newHashSet(); + for (TypeValue lowerBound : lowerBounds) { + types.add(lowerBound.getValue().getType()); + } + return types; + } + + @Override + public String toString() { + return "?" + typeParameterDescriptor; + } + + } + + private static class KnownType extends TypeValue { + + private final JetType type; + + public KnownType(@NotNull JetType type) { + this.type = type; + } + + @NotNull + public JetType getType() { + return type; + } + + @Override + public KnownType getValue() { + return this; + } + + @Override + public String toString() { + return type.toString(); + } + } + + private final Map knownTypes = Maps.newHashMap(); + private final Map unknownTypes = Maps.newHashMap(); + private final JetTypeChecker typeChecker = JetTypeChecker.INSTANCE; + + @NotNull + private TypeValue getTypeValueFor(@NotNull JetType type) { + DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor(); + if (declarationDescriptor instanceof TypeParameterDescriptor) { + TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor; + UnknownType unknownType = unknownTypes.get(typeParameterDescriptor); + if (unknownType != null) { + return unknownType; + } + } + + KnownType typeValue = knownTypes.get(type); + if (typeValue == null) { + typeValue = new KnownType(type); + knownTypes.put(type, typeValue); + } + return typeValue; + } + + public void registerTypeVariable(@NotNull TypeParameterDescriptor typeParameterDescriptor, @NotNull Variance positionVariance) { + assert !unknownTypes.containsKey(typeParameterDescriptor); + UnknownType typeValue = new UnknownType(typeParameterDescriptor, positionVariance); + unknownTypes.put(typeParameterDescriptor, typeValue); + } + + @NotNull + private UnknownType getTypeVariable(TypeParameterDescriptor typeParameterDescriptor) { + UnknownType unknownType = unknownTypes.get(typeParameterDescriptor); + if (unknownType == null) { + throw new IllegalArgumentException("This type parameter is not an unknown in this constraint system"); + } + return unknownType; + } + + public void addSubtypingConstraint(JetType lower, JetType upper) { + TypeValue typeValueForLower = getTypeValueFor(lower); + TypeValue typeValueForUpper = getTypeValueFor(upper); + addSubtypingConstraintOnTypeValues(typeValueForLower, typeValueForUpper); + } + + private void addSubtypingConstraintOnTypeValues(TypeValue typeValueForLower, TypeValue typeValueForUpper) { + System.out.println(typeValueForLower + " :< " + typeValueForUpper); + typeValueForLower.getUpperBounds().add(typeValueForUpper); + typeValueForUpper.getLowerBounds().add(typeValueForLower); + } + + @NotNull + public Solution solve() { + // Expand custom bounds, e.g. List <: List + for (Map.Entry entry : Sets.newHashSet(knownTypes.entrySet())) { + JetType jetType = entry.getKey(); + KnownType typeValue = entry.getValue(); + + for (TypeValue upperBound : typeValue.getUpperBounds()) { + if (upperBound instanceof KnownType) { + KnownType knownBoundType = (KnownType) upperBound; + boolean ok = new TypeConstraintExpander().run(jetType, knownBoundType.getType()); + if (!ok) { + return new Solution(true); + } + } + } + + // Lower bounds? + + } + + // Fill in upper bounds from type parameter bounds + for (Map.Entry entry : Sets.newHashSet(unknownTypes.entrySet())) { + TypeParameterDescriptor typeParameterDescriptor = entry.getKey(); + UnknownType typeValue = entry.getValue(); + for (JetType upperBound : typeParameterDescriptor.getUpperBounds()) { + addSubtypingConstraintOnTypeValues(typeValue, getTypeValueFor(upperBound)); + } + } + + // effective bounds for each node + Set visited = Sets.newHashSet(); + for (KnownType knownType : knownTypes.values()) { + transitiveClosure(knownType, visited); + } + for (UnknownType unknownType : unknownTypes.values()) { + transitiveClosure(unknownType, visited); + } + + // Find inconsistencies + Solution solution = new Solution(false); + + for (UnknownType unknownType : unknownTypes.values()) { + check(unknownType, solution); + } + for (KnownType knownType : knownTypes.values()) { + check(knownType, solution); + } + + return solution; + } + + private void check(TypeValue typeValue, Solution solution) { + try { + KnownType resultingValue = typeValue.getValue(); + JetType type = solution.getSubstitutor().substitute(resultingValue.getType(), Variance.INVARIANT); // TODO + for (TypeValue upperBound : typeValue.getUpperBounds()) { + JetType boundingType = solution.getSubstitutor().substitute(upperBound.getValue().getType(), Variance.INVARIANT); + if (!typeChecker.isSubtypeOf(type, boundingType)) { // TODO + solution.registerError(); + System.out.println("Constraint violation: " + type + " :< " + boundingType); + } + } + for (TypeValue lowerBound : typeValue.getLowerBounds()) { + JetType boundingType = solution.getSubstitutor().substitute(lowerBound.getValue().getType(), Variance.INVARIANT); + if (!typeChecker.isSubtypeOf(boundingType, type)) { + solution.registerError(); + System.out.println("Constraint violation: " + boundingType + " :< " + type); + } + } + } + catch (LoopInTypeVariableConstraintsException e) { + solution.registerError(); + e.printStackTrace(); + } + } + + private void transitiveClosure(TypeValue current, Set visited) { + if (!visited.add(current)) { + return; + } + + for (TypeValue upperBound : Sets.newHashSet(current.getUpperBounds())) { + transitiveClosure(upperBound, visited); + Set upperBounds = upperBound.getUpperBounds(); + for (TypeValue transitiveBound : upperBounds) { + addSubtypingConstraintOnTypeValues(current, transitiveBound); + } + } + } + + public class Solution { + private final TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(new TypeSubstitutor.TypeSubstitution() { + @Override + public TypeProjection get(TypeConstructor key) { + DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor(); + if (declarationDescriptor instanceof TypeParameterDescriptor) { + TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor; + System.out.println(descriptor + " |-> " + getValue(descriptor)); + return new TypeProjection(getValue(descriptor)); + } + return null; + } + + @Override + public boolean isEmpty() { + return false; + } + }); + private boolean failed; + + public Solution(boolean failed) { + this.failed = failed; + } + + public void registerError() { + failed = true; + } + + public boolean isSuccessful() { + return !failed; + } + + @Nullable + public JetType getValue(TypeParameterDescriptor typeParameterDescriptor) { + KnownType value = getTypeVariable(typeParameterDescriptor).getValue(); + return value == null ? null : value.getType(); + } + + public TypeSubstitutor getSubstitutor() { + return typeSubstitutor; + } + + } + + private class TypeConstraintExpander extends JetTypeChecker.AbstractTypeCheckingProcedure { + + private boolean error = false; + + private StatusAction fail() { + error = true; + return StatusAction.ABORT_ALL; + } + + @Override + protected StatusAction startForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) { + return tryToAddConstraint(subtype, supertype); + } + + private StatusAction tryToAddConstraint(@NotNull JetType subtype, @NotNull JetType supertype) { + TypeValue subtypeValue = getTypeValueFor(subtype); + TypeValue supertypeValue = getTypeValueFor(supertype); + + if (someUnknown(subtypeValue, supertypeValue)) { + addSubtypingConstraintOnTypeValues(subtypeValue, supertypeValue); + } + return StatusAction.PROCEED; + +// // both types are known +// if (typeChecker.isSubtypeOf(subtype, supertype)) { +// return StatusAction.PROCEED; +// } +// return fail(); + } + + private boolean someUnknown(TypeValue subtypeValue, TypeValue supertypeValue) { + return subtypeValue instanceof UnknownType || supertypeValue instanceof UnknownType; + } + + @Override + protected StatusAction noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { + if (someUnknown(getTypeValueFor(subtype), getTypeValueFor(supertype))) { + return StatusAction.PROCEED; + } + return fail(); + } + + @Override + protected StatusAction equalTypesRequired(@NotNull JetType subArgumentType, @NotNull JetType superArgumentType) { + if (!subArgumentType.equals(superArgumentType)) { + return fail(); + } + return StatusAction.PROCEED; + } + + @Override + protected StatusAction varianceConflictFound(@NotNull TypeProjection subArgument, @NotNull TypeProjection superArgument) { + return fail(); + } + + @Override + protected StatusAction doneForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) { + return StatusAction.PROCEED; + } + + @Override + protected Boolean result() { + return !error; + } + } + +} \ No newline at end of file From 4571d94c820369c504e2b97f918f359bc0827588 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Mon, 22 Aug 2011 12:59:15 +0400 Subject: [PATCH 2/3] BindingTrace & Context refactored to heterogeneous containers --- idea/src/org/jetbrains/jet/JetNodeTypes.java | 1 + .../jet/codegen/ClassBodyCodegen.java | 7 +- .../jetbrains/jet/codegen/ClassCodegen.java | 7 +- .../jetbrains/jet/codegen/ClosureCodegen.java | 3 +- .../jet/codegen/ExpressionCodegen.java | 83 +- .../jet/codegen/FunctionCodegen.java | 3 +- .../jet/codegen/GenerationState.java | 3 +- .../codegen/ImplementationBodyCodegen.java | 31 +- .../jet/codegen/InterfaceBodyCodegen.java | 6 +- .../jetbrains/jet/codegen/JetTypeMapper.java | 22 +- .../jet/codegen/NamespaceCodegen.java | 5 +- .../jet/codegen/PropertyCodegen.java | 11 +- .../jet/lang/ErrorHandlerWithRegions.java | 101 -- .../jet/lang/cfg/JetControlFlowProcessor.java | 3 +- .../jet/lang/parsing/JetParsing.java | 9 + .../jet/lang/psi/JetAnnotationEntry.java | 11 +- .../psi/JetConstructorCalleeExpression.java | 31 + .../jet/lang/psi/JetDelegatorToSuperCall.java | 10 +- .../jet/lang/psi/JetReferenceExpression.java | 3 +- .../jet/lang/psi/JetSimpleNameExpression.java | 6 +- .../jet/lang/resolve/AnnotationResolver.java | 2 +- .../jet/lang/resolve/BindingContext.java | 112 +- .../jet/lang/resolve/BindingContextUtils.java | 19 + .../jet/lang/resolve/BindingTrace.java | 54 +- .../jet/lang/resolve/BindingTraceAdapter.java | 121 +-- .../jet/lang/resolve/BindingTraceContext.java | 373 +------ .../jet/lang/resolve/ChildBindingTrace.java | 254 ----- .../lang/resolve/ClassDescriptorResolver.java | 35 +- .../lang/resolve/TemporaryBindingTrace.java | 79 ++ .../jet/lang/resolve/TopDownAnalyzer.java | 52 +- .../jet/lang/resolve/TypeResolver.java | 12 +- .../resolve/java/JavaDescriptorResolver.java | 15 +- .../jetbrains/jet/lang/types/ErrorUtils.java | 4 +- .../jet/lang/types/JetTypeInferrer.java | 182 ++-- .../plugin/JetQuickDocumentationProvider.java | 7 +- .../actions/ShowExpressionTypeAction.java | 4 +- .../annotations/JetLineMarkerProvider.java | 23 +- .../jet/plugin/annotations/JetPsiChecker.java | 12 +- .../jet/util/BasicWritableSlice.java | 50 + idea/src/org/jetbrains/jet/util/ManyMap.java | 14 + .../org/jetbrains/jet/util/ManyMapImpl.java | 73 ++ .../org/jetbrains/jet/util/ManyMapKey.java | 45 + .../org/jetbrains/jet/util/ManyMapSlices.java | 175 ++++ .../org/jetbrains/jet/util/MapSupplier.java | 27 + .../jetbrains/jet/util/MutableManyMap.java | 11 + .../org/jetbrains/jet/util/ReadOnlySlice.java | 11 + .../jetbrains/jet/util/RemovableSlice.java | 8 + .../org/jetbrains/jet/util/RewritePolicy.java | 24 + .../org/jetbrains/jet/util/WritableSlice.java | 13 + idea/testData/psi/AnnotatedExpressions.txt | 18 +- idea/testData/psi/Attributes.txt | 197 ++-- idea/testData/psi/AttributesOnPatterns.txt | 54 +- idea/testData/psi/Attributes_ERR.txt | 179 ++-- idea/testData/psi/BabySteps.txt | 9 +- idea/testData/psi/BabySteps_ERR.txt | 9 +- idea/testData/psi/Constructors.txt | 50 +- idea/testData/psi/EOLsOnRollback.txt | 18 +- idea/testData/psi/Enums.txt | 77 +- idea/testData/psi/FunctionLiterals.txt | 27 +- idea/testData/psi/FunctionTypes.txt | 63 +- idea/testData/psi/Functions.txt | 126 ++- idea/testData/psi/Functions_ERR.txt | 54 +- idea/testData/psi/Imports_ERR.txt | 141 +-- idea/testData/psi/LocalDeclarations.txt | 27 +- idea/testData/psi/NamespaceBlock_ERR.txt | 77 +- idea/testData/psi/NamespaceModifiers.txt | 18 +- idea/testData/psi/Properties.txt | 18 +- .../psi/PropertiesFollowedByInitializers.txt | 9 +- idea/testData/psi/Properties_ERR.txt | 36 +- idea/testData/psi/QuotedIdentifiers.txt | 9 +- idea/testData/psi/ShortAnnotations.txt | 970 ++++++++++-------- idea/testData/psi/SimpleClassMembers.txt | 118 ++- idea/testData/psi/SimpleClassMembers_ERR.txt | 61 +- idea/testData/psi/TupleTypes.txt | 81 +- idea/testData/psi/TupleTypes_ERR.txt | 90 +- idea/testData/psi/TypeAnnotations.txt | 45 +- .../testData/psi/TypeParametersBeforeName.txt | 18 +- .../psi/examples/AnonymousObjects.txt | 9 +- idea/testData/psi/examples/BinaryTree.txt | 9 +- idea/testData/psi/examples/BitArith.txt | 18 +- idea/testData/psi/examples/Builder.txt | 36 +- idea/testData/psi/examples/Color.txt | 27 +- .../psi/examples/PolymorphicClassObjects.txt | 9 +- idea/testData/psi/examples/With.txt | 9 +- .../psi/examples/array/MutableArray.txt | 18 +- .../psi/examples/collections/ArrayList.txt | 9 +- .../psi/examples/collections/HashMap.txt | 27 +- .../psi/examples/collections/IList.txt | 9 +- .../psi/examples/collections/List.txt | 59 +- idea/testData/psi/examples/io/IOSamples.txt | 27 +- .../tests/org/jetbrains/jet/JetTestUtils.java | 229 +---- .../jet/resolve/ExpectedResolveData.java | 38 +- 92 files changed, 2632 insertions(+), 2667 deletions(-) delete mode 100644 idea/src/org/jetbrains/jet/lang/ErrorHandlerWithRegions.java create mode 100644 idea/src/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.java create mode 100644 idea/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java delete mode 100644 idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java create mode 100644 idea/src/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.java create mode 100644 idea/src/org/jetbrains/jet/util/BasicWritableSlice.java create mode 100644 idea/src/org/jetbrains/jet/util/ManyMap.java create mode 100644 idea/src/org/jetbrains/jet/util/ManyMapImpl.java create mode 100644 idea/src/org/jetbrains/jet/util/ManyMapKey.java create mode 100644 idea/src/org/jetbrains/jet/util/ManyMapSlices.java create mode 100644 idea/src/org/jetbrains/jet/util/MapSupplier.java create mode 100644 idea/src/org/jetbrains/jet/util/MutableManyMap.java create mode 100644 idea/src/org/jetbrains/jet/util/ReadOnlySlice.java create mode 100644 idea/src/org/jetbrains/jet/util/RemovableSlice.java create mode 100644 idea/src/org/jetbrains/jet/util/RewritePolicy.java create mode 100644 idea/src/org/jetbrains/jet/util/WritableSlice.java diff --git a/idea/src/org/jetbrains/jet/JetNodeTypes.java b/idea/src/org/jetbrains/jet/JetNodeTypes.java index 3fd8cddf4c3..a9add75e4e2 100644 --- a/idea/src/org/jetbrains/jet/JetNodeTypes.java +++ b/idea/src/org/jetbrains/jet/JetNodeTypes.java @@ -29,6 +29,7 @@ public interface JetNodeTypes { JetNodeType DELEGATOR_BY = new JetNodeType("DELEGATOR_BY", JetDelegatorByExpressionSpecifier.class); JetNodeType DELEGATOR_SUPER_CALL = new JetNodeType("DELEGATOR_SUPER_CALL", JetDelegatorToSuperCall.class); JetNodeType DELEGATOR_SUPER_CLASS = new JetNodeType("DELEGATOR_SUPER_CLASS", JetDelegatorToSuperClass.class); + JetNodeType CONSTRUCTOR_CALLEE = new JetNodeType("CONSTRUCTOR_CALLEE", JetConstructorCalleeExpression.class); JetNodeType VALUE_PARAMETER_LIST = new JetNodeType("VALUE_PARAMETER_LIST", JetParameterList.class); JetNodeType VALUE_PARAMETER = new JetNodeType("VALUE_PARAMETER", JetParameter.class); diff --git a/idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java b/idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java index 58a6fa5d7d4..6c2079241e9 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java @@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -29,7 +30,7 @@ public abstract class ClassBodyCodegen { public ClassBodyCodegen(JetClassOrObject aClass, ClassContext context, ClassVisitor v, GenerationState state) { this.state = state; - descriptor = state.getBindingContext().getClassDescriptor(aClass); + descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass); myClass = aClass; this.context = context; this.kind = context.getContextKind(); @@ -81,14 +82,14 @@ public abstract class ClassBodyCodegen { OwnerKind kind = context.getContextKind(); for (JetParameter p : getPrimaryConstructorParameters()) { if (p.getValOrVarNode() != null) { - PropertyDescriptor propertyDescriptor = state.getBindingContext().getPropertyDescriptor(p); + PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p); if (propertyDescriptor != null) { propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC); if (propertyDescriptor.isVar()) { propertyCodegen.generateDefaultSetter(propertyDescriptor, Opcodes.ACC_PUBLIC); } - if (!(kind instanceof OwnerKind.DelegateKind) && kind != OwnerKind.INTERFACE && state.getBindingContext().hasBackingField(propertyDescriptor)) { + if (!(kind instanceof OwnerKind.DelegateKind) && kind != OwnerKind.INTERFACE && state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) { v.visitField(Opcodes.ACC_PRIVATE, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null); } } diff --git a/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java b/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java index 4c3ca0a0eea..c7d6d88809f 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java @@ -2,6 +2,7 @@ package org.jetbrains.jet.codegen; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; @@ -30,7 +31,7 @@ public class ClassCodegen { } } - ClassDescriptor descriptor = state.getBindingContext().getClassDescriptor(aClass); + ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass); final ClassContext contextForInners = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION); for (JetDeclaration declaration : aClass.getDeclarations()) { if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) { @@ -40,13 +41,13 @@ public class ClassCodegen { } private void generateInterface(ClassContext parentContext, JetClassOrObject aClass) { - ClassDescriptor descriptor = state.getBindingContext().getClassDescriptor(aClass); + ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass); final ClassVisitor visitor = state.forClassInterface(descriptor); new InterfaceBodyCodegen(aClass, parentContext.intoClass(descriptor, OwnerKind.INTERFACE), visitor, state).generate(); } private void generateImplementation(ClassContext parentContext, JetClassOrObject aClass, OwnerKind kind) { - ClassDescriptor descriptor = state.getBindingContext().getClassDescriptor(aClass); + ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass); ClassVisitor v = kind == OwnerKind.IMPLEMENTATION ? state.forClassImplementation(descriptor) : state.forClassDelegatingImplementation(descriptor); diff --git a/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java index a10d3804c82..4de5e2ff34a 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java @@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.psi.JetFunctionLiteral; import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.types.JetType; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.MethodVisitor; @@ -83,7 +84,7 @@ public class ClosureCodegen { public GeneratedAnonymousClassDescriptor gen(JetFunctionLiteralExpression fun) { final Pair nameAndVisitor = state.forAnonymousSubclass(fun); - final FunctionDescriptor funDescriptor = (FunctionDescriptor) state.getBindingContext().getDeclarationDescriptor(fun); + final FunctionDescriptor funDescriptor = (FunctionDescriptor) state.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, fun); cv = nameAndVisitor.getSecond(); name = nameAndVisitor.getFirst(); diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 92b5774f673..99783414912 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -14,6 +14,7 @@ import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.types.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; @@ -166,7 +167,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitIfExpression(JetIfExpression expression) { - JetType expressionType = bindingContext.getExpressionType(expression); + JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression); Type asmType = typeMapper.mapType(expressionType); StackValue condition = generateIntermediateValue(expression.getCondition()); @@ -248,14 +249,14 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitForExpression(JetForExpression expression) { final JetExpression loopRange = expression.getLoopRange(); - final JetType expressionType = bindingContext.getExpressionType(loopRange); + final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, loopRange); Type loopRangeType = typeMapper.mapType(expressionType); if (loopRangeType.getSort() == Type.ARRAY) { new ForInArrayLoopGenerator(expression, loopRangeType).invoke(); } else { final DeclarationDescriptor descriptor = expressionType.getConstructor().getDeclarationDescriptor(); - final PsiElement declaration = bindingContext.getDeclarationPsiElement(descriptor); + final PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); if (declaration instanceof PsiClass) { final Project project = declaration.getProject(); final PsiClass iterable = JavaPsiFacade.getInstance(project).findClass("java.lang.Iterable", ProjectScope.getAllScope(project)); @@ -274,7 +275,7 @@ public class ExpressionCodegen extends JetVisitorVoid { private void generateForInIterable(JetForExpression expression, Type loopRangeType) { final JetParameter loopParameter = expression.getLoopParameter(); - final VariableDescriptor parameterDescriptor = bindingContext.getVariableDescriptor(loopParameter); + final VariableDescriptor parameterDescriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, loopParameter); JetType paramType = parameterDescriptor.getOutType(); Type asmParamType = typeMapper.mapType(paramType); @@ -335,7 +336,7 @@ public class ExpressionCodegen extends JetVisitorVoid { this.expression = expression; this.loopRangeType = loopRangeType; final JetParameter loopParameter = expression.getLoopParameter(); - this.parameterDescriptor = bindingContext.getVariableDescriptor(loopParameter); + this.parameterDescriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, loopParameter); } public void invoke() { @@ -490,7 +491,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitConstantExpression(JetConstantExpression expression) { - CompileTimeConstant compileTimeValue = bindingContext.getCompileTimeValue(expression); + CompileTimeConstant compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression); assert compileTimeValue != null; myStack.push(StackValue.constant(compileTimeValue.getValue(), expressionType(expression))); } @@ -541,7 +542,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression) { - if (bindingContext.isBlock(expression)) { + if ((boolean) bindingContext.get(BindingContext.BLOCK, expression)) { generateBlock(expression.getFunctionLiteral().getBodyExpression().getStatements()); } else { @@ -579,7 +580,7 @@ public class ExpressionCodegen extends JetVisitorVoid { for (JetElement statement : statements) { if (statement instanceof JetProperty) { - final VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor((JetProperty) statement); + final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, (JetProperty) statement); final Type type = typeMapper.mapType(variableDescriptor.getOutType()); myMap.enter(variableDescriptor, type.getSize()); } @@ -601,7 +602,7 @@ public class ExpressionCodegen extends JetVisitorVoid { for (JetElement statement : statements) { if (statement instanceof JetProperty) { JetProperty var = (JetProperty) statement; - VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor(var); + VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, var); Type outType = typeMapper.mapType(variableDescriptor.getOutType()); int index = myMap.leave(variableDescriptor); @@ -646,7 +647,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitSimpleNameExpression(JetSimpleNameExpression expression) { - DeclarationDescriptor descriptor = bindingContext.resolveReferenceExpression(expression); + DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression); if (descriptor instanceof NamespaceDescriptor) return; // No code to generate if (descriptor instanceof VariableAsFunctionDescriptor) { @@ -662,7 +663,7 @@ public class ExpressionCodegen extends JetVisitorVoid { final DeclarationDescriptor container = descriptor.getContainingDeclaration(); - PsiElement declaration = bindingContext.getDeclarationPsiElement(descriptor); + PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); if (declaration instanceof PsiField) { PsiField psiField = (PsiField) declaration; final String owner = JetTypeMapper.jvmName(psiField.getContainingClass()); @@ -686,7 +687,7 @@ public class ExpressionCodegen extends JetVisitorVoid { if (declaration instanceof JetParameter) { if (PsiTreeUtil.getParentOfType(expression, JetDelegationSpecifier.class) != null) { JetClass aClass = PsiTreeUtil.getParentOfType(expression, JetClass.class); - ConstructorDescriptor constructorDescriptor = bindingContext.getConstructorDescriptor(aClass); + ConstructorDescriptor constructorDescriptor = bindingContext.get(BindingContext.CONSTRUCTOR, aClass); List parameters = constructorDescriptor.getValueParameters(); for (ValueParameterDescriptor parameter : parameters) { if (parameter.getName().equals(descriptor.getName())) { @@ -700,7 +701,7 @@ public class ExpressionCodegen extends JetVisitorVoid { if (declaration instanceof JetObjectDeclarationName) { JetObjectDeclaration objectDeclaration = PsiTreeUtil.getParentOfType(declaration, JetObjectDeclaration.class); - ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(objectDeclaration); + ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, objectDeclaration); myStack.push(StackValue.field(typeMapper.jvmType(classDescriptor, OwnerKind.IMPLEMENTATION), typeMapper.jvmName(classDescriptor, OwnerKind.IMPLEMENTATION), "$instance", @@ -840,7 +841,7 @@ public class ExpressionCodegen extends JetVisitorVoid { if (intrinsic != null) { return intrinsic; } - PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(fd); + PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, fd); CallableMethod callableMethod; if (declarationPsiElement instanceof PsiMethod || declarationPsiElement instanceof JetNamedFunction) { @@ -860,7 +861,7 @@ public class ExpressionCodegen extends JetVisitorVoid { if (!(callee instanceof JetSimpleNameExpression)) { throw new UnsupportedOperationException("Don't know how to generate a call to " + callee); } - DeclarationDescriptor funDescriptor = bindingContext.resolveReferenceExpression((JetSimpleNameExpression) callee); + DeclarationDescriptor funDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) callee); if (funDescriptor == null) { throw new CompilationException("Cannot resolve: " + callee.getText()); } @@ -892,9 +893,9 @@ public class ExpressionCodegen extends JetVisitorVoid { private void setOwnerFromCall(CallableMethod callableMethod, JetCall expression) { if (expression.getParent() instanceof JetQualifiedExpression) { final JetExpression receiver = ((JetQualifiedExpression) expression.getParent()).getReceiverExpression(); - JetType expressionType = bindingContext.getExpressionType(receiver); + JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, receiver); DeclarationDescriptor declarationDescriptor = expressionType.getConstructor().getDeclarationDescriptor(); - PsiElement ownerDeclaration = bindingContext.getDeclarationPsiElement(declarationDescriptor); + PsiElement ownerDeclaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor); if (ownerDeclaration instanceof PsiClass) { callableMethod.setOwner(typeMapper.mapType(expressionType).getInternalName()); } @@ -1017,11 +1018,11 @@ public class ExpressionCodegen extends JetVisitorVoid { } public Type expressionType(JetExpression expr) { - return typeMapper.mapType(bindingContext.getExpressionType(expr)); + return typeMapper.mapType(bindingContext.get(BindingContext.EXPRESSION_TYPE, expr)); } public int indexOfLocal(JetReferenceExpression lhs) { - final DeclarationDescriptor declarationDescriptor = bindingContext.resolveReferenceExpression(lhs); + final DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, lhs); return lookupLocal(declarationDescriptor); } @@ -1036,8 +1037,8 @@ public class ExpressionCodegen extends JetVisitorVoid { private boolean resolvesToClassOrPackage(JetExpression receiver) { if (receiver instanceof JetReferenceExpression) { - DeclarationDescriptor declaration = bindingContext.resolveReferenceExpression((JetReferenceExpression) receiver); - PsiElement declarationElement = bindingContext.getDeclarationPsiElement(declaration); + DeclarationDescriptor declaration = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression) receiver); + PsiElement declarationElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declaration); if (declarationElement instanceof PsiClass) { return true; } @@ -1056,7 +1057,7 @@ public class ExpressionCodegen extends JetVisitorVoid { v.goTo(end); v.mark(ifnull); // null is already on stack here after the dup - JetType expressionType = bindingContext.getExpressionType(expression); + JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression); if (expressionType.equals(JetStandardClasses.getUnitType())) { v.pop(); } @@ -1076,7 +1077,7 @@ public class ExpressionCodegen extends JetVisitorVoid { v.pop(); v.aconst(null); v.mark(end); - myStack.push(StackValue.onStack(typeMapper.mapType(bindingContext.getExpressionType(expression)))); + myStack.push(StackValue.onStack(typeMapper.mapType(bindingContext.get(BindingContext.EXPRESSION_TYPE, expression)))); } @Override @@ -1106,7 +1107,7 @@ public class ExpressionCodegen extends JetVisitorVoid { generateElvis(expression); } else { - DeclarationDescriptor op = bindingContext.resolveReferenceExpression(expression.getOperationReference()); + DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference()); final Callable callable = resolveToCallable(op); if (callable instanceof IntrinsicMethod) { IntrinsicMethod intrinsic = (IntrinsicMethod) callable; @@ -1264,11 +1265,11 @@ public class ExpressionCodegen extends JetVisitorVoid { } private void generateAugmentedAssignment(JetBinaryExpression expression) { - DeclarationDescriptor op = bindingContext.resolveReferenceExpression(expression.getOperationReference()); + DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference()); final Callable callable = resolveToCallable(op); final JetExpression lhs = expression.getLeft(); Type lhsType = expressionType(lhs); - if (bindingContext.isVariableReassignment(expression)) { + if ((boolean) bindingContext.get(BindingContext.VARIABLE_REASSIGNMENT, expression)) { if (callable instanceof IntrinsicMethod) { StackValue value = generateIntermediateValue(lhs); // receiver value.dupReceiver(v, 0); // receiver receiver @@ -1330,7 +1331,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitPrefixExpression(JetPrefixExpression expression) { - DeclarationDescriptor op = bindingContext.resolveReferenceExpression(expression.getOperationSign()); + DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationSign()); final Callable callable = resolveToCallable(op); if (callable instanceof IntrinsicMethod) { IntrinsicMethod intrinsic = (IntrinsicMethod) callable; @@ -1350,12 +1351,12 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitPostfixExpression(JetPostfixExpression expression) { - DeclarationDescriptor op = bindingContext.resolveReferenceExpression(expression.getOperationSign()); + DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationSign()); if (op instanceof FunctionDescriptor) { final Type asmType = expressionType(expression); DeclarationDescriptor cls = op.getContainingDeclaration(); if (isNumberPrimitive(cls) && (op.getName().equals("inc") || op.getName().equals("dec"))) { - if (bindingContext.isStatement(expression)) { + if ((boolean) bindingContext.get(BindingContext.STATEMENT, expression)) { generateIncrement(op, asmType, expression.getBaseExpression()); } else { @@ -1402,7 +1403,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitProperty(JetProperty property) { - VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor(property); + VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, property); int index = lookupLocal(variableDescriptor); assert index >= 0; @@ -1416,14 +1417,14 @@ public class ExpressionCodegen extends JetVisitorVoid { } private void generateConstructorCall(JetCallExpression expression, JetSimpleNameExpression constructorReference) { - DeclarationDescriptor constructorDescriptor = bindingContext.resolveReferenceExpression(constructorReference); - final PsiElement declaration = bindingContext.getDeclarationPsiElement(constructorDescriptor); + DeclarationDescriptor constructorDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, constructorReference); + final PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, constructorDescriptor); Type type; if (declaration instanceof PsiMethod) { type = generateJavaConstructorCall(expression, (PsiMethod) declaration); } else if (constructorDescriptor instanceof ConstructorDescriptor) { - type = typeMapper.mapType(bindingContext.getExpressionType(expression), OwnerKind.IMPLEMENTATION); + type = typeMapper.mapType(bindingContext.get(BindingContext.EXPRESSION_TYPE, expression), OwnerKind.IMPLEMENTATION); if (type.getSort() == Type.ARRAY) { generateNewArray(expression, type); } @@ -1453,7 +1454,7 @@ public class ExpressionCodegen extends JetVisitorVoid { } public void pushTypeArgument(JetTypeProjection jetTypeArgument) { - JetType typeArgument = bindingContext.resolveTypeReference(jetTypeArgument.getTypeReference()); + JetType typeArgument = bindingContext.get(BindingContext.TYPE, jetTypeArgument.getTypeReference()); generateTypeInfo(typeArgument); } @@ -1493,7 +1494,7 @@ public class ExpressionCodegen extends JetVisitorVoid { myStack.push(StackValue.arrayElement(elementType)); } else { - final PsiElement declaration = bindingContext.resolveToDeclarationPsiElement(expression); + final PsiElement declaration = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, expression); final CallableMethod accessor; if (declaration instanceof PsiMethod) { accessor = JetTypeMapper.mapToCallableMethod((PsiMethod) declaration); @@ -1525,7 +1526,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Override public void visitThisExpression(JetThisExpression expression) { - final DeclarationDescriptor descriptor = bindingContext.resolveReferenceExpression(expression.getThisReference()); + final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getThisReference()); if (descriptor instanceof ClassDescriptor) { myStack.push(generateThisOrOuter((ClassDescriptor) descriptor)); } @@ -1560,7 +1561,7 @@ public class ExpressionCodegen extends JetVisitorVoid { Label clauseStart = new Label(); v.mark(clauseStart); - VariableDescriptor descriptor = bindingContext.getVariableDescriptor(clause.getCatchParameter()); + VariableDescriptor descriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, clause.getCatchParameter()); Type descriptorType = typeMapper.mapType(descriptor.getOutType()); myMap.enter(descriptor, 1); int index = lookupLocal(descriptor); @@ -1600,7 +1601,7 @@ public class ExpressionCodegen extends JetVisitorVoid { } else { JetTypeReference typeReference = expression.getRight(); - JetType jetType = bindingContext.resolveTypeReference(typeReference); + JetType jetType = bindingContext.get(BindingContext.TYPE, typeReference); DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor(); if (!(descriptor instanceof ClassDescriptor)) { throw new UnsupportedOperationException("don't know how to handle non-class types in as/as?"); @@ -1634,7 +1635,7 @@ public class ExpressionCodegen extends JetVisitorVoid { @Nullable Label nextEntry) { if (pattern instanceof JetTypePattern) { JetTypeReference typeReference = ((JetTypePattern) pattern).getTypeReference(); - JetType jetType = bindingContext.resolveTypeReference(typeReference); + JetType jetType = bindingContext.get(BindingContext.TYPE, typeReference); expressionToMatch.dupReceiver(v, 0); generateInstanceOf(expressionToMatch, jetType, false); StackValue value = StackValue.onStack(Type.BOOLEAN_TYPE); @@ -1657,7 +1658,7 @@ public class ExpressionCodegen extends JetVisitorVoid { } else if (pattern instanceof JetBindingPattern) { final JetProperty var = ((JetBindingPattern) pattern).getVariableDeclaration(); - final VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor(var); + final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, var); final Type varType = typeMapper.mapType(variableDescriptor.getOutType()); myMap.enter(variableDescriptor, varType.getSize()); expressionToMatch.dupReceiver(v, 0); @@ -1867,7 +1868,7 @@ public class ExpressionCodegen extends JetVisitorVoid { conditionValue = invokeFunction((JetCallExpression) call, (FunctionDescriptor) declarationDescriptor, true); } else if (call instanceof JetSimpleNameExpression) { - final DeclarationDescriptor descriptor = bindingContext.resolveReferenceExpression((JetSimpleNameExpression) call); + final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call); if (descriptor instanceof PropertyDescriptor) { v.load(subjectLocal, subjectType); conditionValue = intermediateValueForProperty((PropertyDescriptor) descriptor, false, false); diff --git a/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java index a7f11a8de4b..7918f500bdd 100644 --- a/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -4,6 +4,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -31,7 +32,7 @@ public class FunctionCodegen { public void gen(JetNamedFunction f) { Method method = state.getTypeMapper().mapToCallableMethod(f).getSignature(); - final FunctionDescriptor functionDescriptor = state.getBindingContext().getFunctionDescriptor(f); + final FunctionDescriptor functionDescriptor = state.getBindingContext().get(BindingContext.FUNCTION, f); generateMethod(f, method, functionDescriptor); } diff --git a/idea/src/org/jetbrains/jet/codegen/GenerationState.java b/idea/src/org/jetbrains/jet/codegen/GenerationState.java index acee32c2f09..ec7643dc3c4 100644 --- a/idea/src/org/jetbrains/jet/codegen/GenerationState.java +++ b/idea/src/org/jetbrains/jet/codegen/GenerationState.java @@ -102,7 +102,7 @@ public class GenerationState { public GeneratedAnonymousClassDescriptor generateObjectLiteral(JetObjectLiteralExpression literal, ExpressionCodegen context, ClassContext classContext) { Pair nameAndVisitor = forAnonymousSubclass(literal.getObjectDeclaration()); - final ClassContext objectContext = classContext.intoClass(getBindingContext().getClassDescriptor(literal.getObjectDeclaration()), OwnerKind.IMPLEMENTATION); + final ClassContext objectContext = classContext.intoClass(getBindingContext().get(BindingContext.CLASS, literal.getObjectDeclaration()), OwnerKind.IMPLEMENTATION); new ImplementationBodyCodegen(literal.getObjectDeclaration(), objectContext, nameAndVisitor.getSecond(), this).generate(); return new GeneratedAnonymousClassDescriptor(nameAndVisitor.first, new Method("", "()V"), false); @@ -122,4 +122,5 @@ public class GenerationState { } }); } + } diff --git a/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index aefc174ed42..e97de80ecdc 100644 --- a/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -5,6 +5,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lexer.JetTokens; import org.objectweb.asm.ClassVisitor; @@ -61,9 +62,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { JetDelegationSpecifier first = delegationSpecifiers.get(0); if (first instanceof JetDelegatorToSuperClass || first instanceof JetDelegatorToSuperCall) { - JetType superType = state.getBindingContext().resolveTypeReference(first.getTypeReference()); + JetType superType = state.getBindingContext().get(BindingContext.TYPE, first.getTypeReference()); ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); - final PsiElement declaration = state.getBindingContext().getDeclarationPsiElement(superClassDescriptor); + final PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor); if (declaration instanceof PsiClass && ((PsiClass) declaration).isInterface()) { return "java/lang/Object"; } @@ -146,7 +147,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } protected void generatePrimaryConstructor() { - ConstructorDescriptor constructorDescriptor = state.getBindingContext().getConstructorDescriptor((JetElement) myClass); + ConstructorDescriptor constructorDescriptor = state.getBindingContext().get(BindingContext.CONSTRUCTOR, (JetElement) myClass); if (constructorDescriptor == null && !(myClass instanceof JetObjectDeclaration) && !isEnum(myClass)) return; Method method; @@ -182,7 +183,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { // TODO correct calculation of super class String superClass = "java/lang/Object"; if (!specifiers.isEmpty()) { - final JetType superType = state.getBindingContext().resolveTypeReference(specifiers.get(0).getTypeReference()); + final JetType superType = state.getBindingContext().get(BindingContext.TYPE, specifiers.get(0).getTypeReference()); ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); if (superClassDescriptor.hasConstructors()) { superClass = getSuperClass(); @@ -215,7 +216,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { HashSet overridden = new HashSet(); for (JetDeclaration declaration : myClass.getDeclarations()) { if (declaration instanceof JetFunction) { - overridden.addAll(state.getBindingContext().getFunctionDescriptor((JetNamedFunction) declaration).getOverriddenFunctions()); + overridden.addAll(state.getBindingContext().get(BindingContext.FUNCTION, (JetNamedFunction) declaration).getOverriddenFunctions()); } } @@ -229,7 +230,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } if (specifier instanceof JetDelegatorToSuperCall) { - ConstructorDescriptor constructorDescriptor1 = state.getBindingContext().resolveSuperConstructor((JetDelegatorToSuperCall) specifier); + ConstructorDescriptor constructorDescriptor1 = (ConstructorDescriptor) state.getBindingContext().get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) specifier).getCalleeExpression().getConstructorReferenceExpression()); generateDelegatorToConstructorCall(iv, codegen, (JetDelegatorToSuperCall) specifier, constructorDescriptor1, n == 0, frameMap); } else if (specifier instanceof JetDelegatorByExpressionSpecifier) { @@ -237,7 +238,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } if (delegateOnStack) { - JetType superType = state.getBindingContext().resolveTypeReference(specifier.getTypeReference()); + JetType superType = state.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference()); ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); String delegateField = "$delegate_" + n; Type fieldType = JetTypeMapper.jetInterfaceType(superClassDescriptor); @@ -245,7 +246,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { v.visitField(Opcodes.ACC_PRIVATE, delegateField, fieldDesc, /*TODO*/null, null); iv.putfield(classname, delegateField, fieldDesc); - JetClass superClass = (JetClass) state.getBindingContext().getDeclarationPsiElement(superClassDescriptor); + JetClass superClass = (JetClass) state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor); final ClassContext delegateContext = context.intoClass(superClassDescriptor, new OwnerKind.DelegateKind(StackValue.field(fieldType, classname, delegateField, false), JetTypeMapper.jvmNameForInterface(superClassDescriptor))); @@ -298,7 +299,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { ConstructorFrameMap frameMap) { ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration(); boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION; - PsiElement declaration = state.getBindingContext().getDeclarationPsiElement(classDecl); + PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDecl); Type type; if (declaration instanceof PsiClass) { type = JetTypeMapper.psiClassType((PsiClass) declaration); @@ -348,7 +349,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } private void generateSecondaryConstructor(JetConstructor constructor) { - ConstructorDescriptor constructorDescriptor = state.getBindingContext().getConstructorDescriptor(constructor); + ConstructorDescriptor constructorDescriptor = state.getBindingContext().get(BindingContext.CONSTRUCTOR, constructor); if (constructorDescriptor == null) { throw new UnsupportedOperationException("failed to get descriptor for secondary constructor"); } @@ -365,7 +366,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { for (JetDelegationSpecifier initializer : constructor.getInitializers()) { if (initializer instanceof JetDelegatorToThisCall) { JetDelegatorToThisCall thisCall = (JetDelegatorToThisCall) initializer; - DeclarationDescriptor thisDescriptor = state.getBindingContext().resolveReferenceExpression(thisCall.getThisReference()); + DeclarationDescriptor thisDescriptor = state.getBindingContext().get(BindingContext.REFERENCE_TARGET, thisCall.getThisReference()); if (!(thisDescriptor instanceof ConstructorDescriptor)) { throw new UnsupportedOperationException("expected 'this' delegator to resolve to constructor"); } @@ -409,8 +410,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { protected void generateInitializers(ExpressionCodegen codegen, InstructionAdapter iv) { for (JetDeclaration declaration : myClass.getDeclarations()) { if (declaration instanceof JetProperty) { - final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration); - if (state.getBindingContext().hasBackingField(propertyDescriptor)) { + final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, (JetProperty) declaration); + if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) { final JetExpression initializer = ((JetProperty) declaration).getInitializer(); if (initializer != null) { iv.load(0, JetTypeMapper.TYPE_OBJECT); @@ -435,7 +436,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { propertyCodegen.gen((JetProperty) declaration); } else if (declaration instanceof JetFunction) { - if (!overriden.contains(state.getBindingContext().getFunctionDescriptor((JetNamedFunction) declaration))) { + if (!overriden.contains(state.getBindingContext().get(BindingContext.FUNCTION, (JetNamedFunction) declaration))) { functionCodegen.gen((JetNamedFunction) declaration); } } @@ -443,7 +444,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { for (JetParameter p : toClass.getPrimaryConstructorParameters()) { if (p.getValOrVarNode() != null) { - PropertyDescriptor propertyDescriptor = state.getBindingContext().getPropertyDescriptor(p); + PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p); if (propertyDescriptor != null) { propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC); if (propertyDescriptor.isVar()) { diff --git a/idea/src/org/jetbrains/jet/codegen/InterfaceBodyCodegen.java b/idea/src/org/jetbrains/jet/codegen/InterfaceBodyCodegen.java index a40f28684b6..2e3f4e0578f 100644 --- a/idea/src/org/jetbrains/jet/codegen/InterfaceBodyCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/InterfaceBodyCodegen.java @@ -47,9 +47,9 @@ public class InterfaceBodyCodegen extends ClassBodyCodegen { String superClassName = null; Set superInterfaces = new LinkedHashSet(); for (JetDelegationSpecifier specifier : delegationSpecifiers) { - JetType superType = bindingContext.resolveTypeReference(specifier.getTypeReference()); + JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); - PsiElement superPsi = bindingContext.getDeclarationPsiElement(superClassDescriptor); + PsiElement superPsi = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor); if (superPsi instanceof PsiClass) { PsiClass psiClass = (PsiClass) superPsi; @@ -120,7 +120,7 @@ public class InterfaceBodyCodegen extends ClassBodyCodegen { final JetDelegationSpecifier specifier = delegationSpecifiers.get(0); if (specifier instanceof JetDelegatorToSuperCall) { final JetDelegatorToSuperCall superCall = (JetDelegatorToSuperCall) specifier; - ConstructorDescriptor constructorDescriptor = state.getBindingContext().resolveSuperConstructor(superCall); + ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) state.getBindingContext().get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression()); CallableMethod method = state.getTypeMapper().mapToCallableMethod(constructorDescriptor, OwnerKind.IMPLEMENTATION); codegen.invokeMethodWithArguments(method, superCall); } diff --git a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 886c1ede092..ce26f8dc6dc 100644 --- a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -138,7 +138,7 @@ public class JetTypeMapper { } public String jvmName(ClassDescriptor jetClass, OwnerKind kind) { - PsiElement declaration = bindingContext.getDeclarationPsiElement(jetClass); + PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, jetClass); if (declaration instanceof PsiClass) { return jvmName((PsiClass) declaration); } @@ -146,7 +146,7 @@ public class JetTypeMapper { final PsiElement parent = declaration.getParent(); if (parent instanceof JetClassObject) { JetClass containingClass = PsiTreeUtil.getParentOfType(parent, JetClass.class); - final ClassDescriptor containingClassDescriptor = bindingContext.getClassDescriptor(containingClass); + final ClassDescriptor containingClassDescriptor = bindingContext.get(BindingContext.CLASS, containingClass); return jvmName(containingClassDescriptor, OwnerKind.INTERFACE) + "$$ClassObj"; } String className = classNamesForAnonymousClasses.get(declaration); @@ -159,12 +159,12 @@ public class JetTypeMapper { } public String jvmName(JetClassObject classObject) { - final ClassDescriptor descriptor = bindingContext.getClassDescriptor(classObject.getObjectDeclaration()); + final ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, classObject.getObjectDeclaration()); return jvmName(descriptor, OwnerKind.IMPLEMENTATION); } public boolean isInterface(ClassDescriptor jetClass, OwnerKind kind) { - PsiElement declaration = bindingContext.getDeclarationPsiElement(jetClass); + PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, jetClass); if (declaration instanceof JetObjectDeclaration) { return false; } @@ -372,14 +372,14 @@ public class JetTypeMapper { private Method mapSignature(JetNamedFunction f, List valueParameterTypes) { final JetTypeReference receiverTypeRef = f.getReceiverTypeRef(); - final JetType receiverType = receiverTypeRef == null ? null : bindingContext.resolveTypeReference(receiverTypeRef); + final JetType receiverType = receiverTypeRef == null ? null : bindingContext.get(BindingContext.TYPE, receiverTypeRef); final List parameters = f.getValueParameters(); List parameterTypes = new ArrayList(); if (receiverType != null) { parameterTypes.add(mapType(receiverType)); } for (JetParameter parameter : parameters) { - final Type type = mapType(bindingContext.resolveTypeReference(parameter.getTypeReference())); + final Type type = mapType(bindingContext.get(BindingContext.TYPE, parameter.getTypeReference())); valueParameterTypes.add(type); parameterTypes.add(type); } @@ -389,12 +389,12 @@ public class JetTypeMapper { final JetTypeReference returnTypeRef = f.getReturnTypeRef(); Type returnType; if (returnTypeRef == null) { - final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(f); + final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f); final JetType type = functionDescriptor.getReturnType(); returnType = mapType(type); } else { - returnType = mapType(bindingContext.resolveTypeReference(returnTypeRef)); + returnType = mapType(bindingContext.get(BindingContext.TYPE, returnTypeRef)); } return new Method(f.getName(), returnType, parameterTypes.toArray(new Type[parameterTypes.size()])); } @@ -407,7 +407,7 @@ public class JetTypeMapper { throw new UnsupportedOperationException("unknown declaration type " + declaration); } JetNamedFunction f = (JetNamedFunction) declaration; - final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(f); + final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f); final DeclarationDescriptor functionParent = functionDescriptor.getContainingDeclaration(); final List valueParameterTypes = new ArrayList(); Method descriptor = mapSignature(f, valueParameterTypes); @@ -561,7 +561,7 @@ public class JetTypeMapper { baseName = NamespaceCodegen.getJVMClassName(((JetNamespace) container).getFQName()); } else { - ClassDescriptor aClass = bindingContext.getClassDescriptor((JetClassOrObject) container); + ClassDescriptor aClass = bindingContext.get(BindingContext.CLASS, (JetClassOrObject) container); baseName = JetTypeMapper.jvmNameForInterface(aClass); } @@ -577,7 +577,7 @@ public class JetTypeMapper { public Collection allJvmNames(JetClassOrObject jetClass) { Set result = new HashSet(); - final ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetClass); + final ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetClass); if (classDescriptor != null) { result.add(jvmName(classDescriptor, OwnerKind.INTERFACE)); result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION)); diff --git a/idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java b/idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java index 32d81e65a4c..1b8ee6b5429 100644 --- a/idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java @@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen; import com.intellij.psi.PsiFile; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -33,7 +34,7 @@ public class NamespaceCodegen { } public void generate(JetNamespace namespace) { - final ClassContext context = ClassContext.STATIC.intoNamespace(state.getBindingContext().getNamespaceDescriptor(namespace)); + final ClassContext context = ClassContext.STATIC.intoNamespace(state.getBindingContext().get(BindingContext.NAMESPACE, namespace)); final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state); final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, state); @@ -78,7 +79,7 @@ public class NamespaceCodegen { if (declaration instanceof JetProperty) { final JetExpression initializer = ((JetProperty) declaration).getInitializer(); if (initializer != null && !(initializer instanceof JetConstantExpression)) { - final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration); + final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, (JetProperty) declaration); codegen.genToJVMStack(initializer); codegen.intermediateValueForProperty(descriptor, true, false).store(new InstructionAdapter(mv)); } diff --git a/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java b/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java index 44db94372f6..67a3da3e357 100644 --- a/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java @@ -5,6 +5,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lexer.JetTokens; import org.objectweb.asm.ClassVisitor; @@ -30,7 +31,7 @@ public class PropertyCodegen { } public void gen(JetProperty p) { - final VariableDescriptor descriptor = state.getBindingContext().getVariableDescriptor(p); + final VariableDescriptor descriptor = state.getBindingContext().get(BindingContext.VARIABLE, p); if (!(descriptor instanceof PropertyDescriptor)) { throw new UnsupportedOperationException("expect a property to have a property descriptor"); } @@ -67,12 +68,12 @@ public class PropertyCodegen { } private void generateBackingField(JetProperty p, PropertyDescriptor propertyDescriptor) { - if (state.getBindingContext().hasBackingField(propertyDescriptor)) { + if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) { Object value = null; final JetExpression initializer = p.getInitializer(); if (initializer != null) { if (initializer instanceof JetConstantExpression) { - CompileTimeConstant compileTimeValue = state.getBindingContext().getCompileTimeValue(initializer); + CompileTimeConstant compileTimeValue = state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, initializer); assert compileTimeValue != null; value = compileTimeValue.getValue(); } @@ -126,7 +127,7 @@ public class PropertyCodegen { } private void generateDefaultGetter(JetProperty p, JetDeclaration declaration) { - final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor(p); + final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, p); int flags = JetTypeMapper.getAccessModifiers(declaration, Opcodes.ACC_PUBLIC); generateDefaultGetter(propertyDescriptor, flags); } @@ -166,7 +167,7 @@ public class PropertyCodegen { } private void generateDefaultSetter(JetProperty p, JetDeclaration declaration) { - final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor(p); + final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, p); int flags = JetTypeMapper.getAccessModifiers(declaration, Opcodes.ACC_PUBLIC); generateDefaultSetter(propertyDescriptor, flags); } diff --git a/idea/src/org/jetbrains/jet/lang/ErrorHandlerWithRegions.java b/idea/src/org/jetbrains/jet/lang/ErrorHandlerWithRegions.java deleted file mode 100644 index 2455db0be78..00000000000 --- a/idea/src/org/jetbrains/jet/lang/ErrorHandlerWithRegions.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.jetbrains.jet.lang; - -import com.intellij.lang.ASTNode; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.psi.JetExpression; -import org.jetbrains.jet.lang.psi.JetReferenceExpression; -import org.jetbrains.jet.lang.resolve.AnalyzingUtils; -import org.jetbrains.jet.lang.types.JetType; - -import java.util.Stack; - -/** - * @author abreslav - */ -public class ErrorHandlerWithRegions extends ErrorHandler { - - public class DiagnosticsRegion { - private final CollectingErrorHandler errorHandler; - private boolean committed = false; - - private DiagnosticsRegion(CollectingErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - public CollectingErrorHandler getErrorHandler() { - assert !committed; - return errorHandler; - } - - public void commit() { - assert !committed; - AnalyzingUtils.applyHandler(parent, errorHandler.getDiagnostics()); - committed = true; - } - } - - private final ErrorHandler parent; - private final Stack workers; - private ErrorHandler worker; - - public ErrorHandlerWithRegions(ErrorHandler parent) { - this.parent = parent; - this.worker = parent; - this.workers = new Stack(); - } - - public void openRegion() { - CollectingErrorHandler newWorker = new CollectingErrorHandler(); - workers.push(newWorker); - worker = newWorker; - } - - public void closeAndCommitCurrentRegion() { - assert !workers.isEmpty(); - CollectingErrorHandler region = workers.pop(); - AnalyzingUtils.applyHandler(parent, region.getDiagnostics()); - - setWorker(); - } - - public DiagnosticsRegion closeAndReturnCurrentRegion() { - assert !workers.isEmpty(); - CollectingErrorHandler currentWorker = workers.pop(); - setWorker(); - return new DiagnosticsRegion(currentWorker); - } - - public void close() { - assert workers.isEmpty() : "Open regions remain: " + workers; - } - - private void setWorker() { - worker = workers.isEmpty() ? parent : workers.peek(); - } - - @Override - public void unresolvedReference(@NotNull JetReferenceExpression referenceExpression) { - worker.unresolvedReference(referenceExpression); - } - - @Override - public void typeMismatch(@NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull JetType actualType) { - worker.typeMismatch(expression, expectedType, actualType); - } - - @Override - public void redeclaration(@NotNull DeclarationDescriptor existingDescriptor, @NotNull DeclarationDescriptor redeclaredDescriptor) { - worker.redeclaration(existingDescriptor, redeclaredDescriptor); - } - - @Override - public void genericError(@NotNull ASTNode node, @NotNull String errorMessage) { - worker.genericError(node, errorMessage); - } - - @Override - public void genericWarning(@NotNull ASTNode node, @NotNull String message) { - worker.genericWarning(node, message); - } -} diff --git a/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index 999b1713bac..828d5394a46 100644 --- a/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.JetSemanticServices; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.types.JetTypeInferrer; import org.jetbrains.jet.lexer.JetTokens; @@ -85,7 +86,7 @@ public class JetControlFlowProcessor { } JetElement result = stack.peek(); - trace.recordLabelResolution(labelExpression, result); + trace.record(BindingContext.LABEL_TARGET, labelExpression, result); return result; } diff --git a/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java index 5f969141043..67b1913eea5 100644 --- a/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -351,9 +351,11 @@ public class JetParsing extends AbstractJetParsing { PsiBuilder.Marker attribute = mark(); + PsiBuilder.Marker reference = mark(); PsiBuilder.Marker typeReference = mark(); parseUserType(); typeReference.done(TYPE_REFERENCE); + reference.done(CONSTRUCTOR_CALLEE); parseTypeArgumentList(-1); @@ -723,7 +725,9 @@ public class JetParsing extends AbstractJetParsing { type = THIS_CALL; } else if (atSet(TYPE_REF_FIRST)) { + PsiBuilder.Marker reference = mark(); parseTypeRef(); + reference.done(CONSTRUCTOR_CALLEE); type = DELEGATOR_SUPER_CALL; } else { errorWithRecovery("Expecting constructor call (this(...)) or supertype initializer", TokenSet.create(LBRACE, COMMA)); @@ -1094,18 +1098,23 @@ public class JetParsing extends AbstractJetParsing { private void parseDelegationSpecifier() { PsiBuilder.Marker delegator = mark(); parseAnnotations(false); + + PsiBuilder.Marker reference = mark(); parseTypeRef(); if (at(BY_KEYWORD)) { + reference.drop(); advance(); // BY_KEYWORD createForByClause(myBuilder).myExpressionParsing.parseExpression(); delegator.done(DELEGATOR_BY); } else if (at(LPAR)) { + reference.done(CONSTRUCTOR_CALLEE); myExpressionParsing.parseValueArgumentList(); delegator.done(DELEGATOR_SUPER_CALL); } else { + reference.drop(); delegator.done(DELEGATOR_SUPER_CLASS); } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java b/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java index 8971900a36e..b5d430b2b89 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetAnnotationEntry.java @@ -29,13 +29,16 @@ public class JetAnnotationEntry extends JetElement implements JetCall { @Nullable @IfNotParsed public JetTypeReference getTypeReference() { - return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE); + JetConstructorCalleeExpression calleeExpression = getCalleeExpression(); + if (calleeExpression == null) { + return null; + } + return calleeExpression.getTypeReference(); } @Override - public JetExpression getCalleeExpression() { - // Make callee an expression instead of a type reference - throw new UnsupportedOperationException(); // TODO + public JetConstructorCalleeExpression getCalleeExpression() { + return (JetConstructorCalleeExpression) findChildByType(JetNodeTypes.CONSTRUCTOR_CALLEE); } @Override diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.java new file mode 100644 index 00000000000..fcd388862ea --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.java @@ -0,0 +1,31 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author abreslav + */ +public class JetConstructorCalleeExpression extends JetExpression { + public JetConstructorCalleeExpression(@NotNull ASTNode node) { + super(node); + } + + @Nullable @IfNotParsed + public JetTypeReference getTypeReference() { + return findChildByClass(JetTypeReference.class); + } + + @Nullable @IfNotParsed + public JetReferenceExpression getConstructorReferenceExpression() { + JetTypeReference typeReference = getTypeReference(); + if (typeReference == null) { + return null; + } + JetTypeElement typeElement = typeReference.getTypeElement(); + assert typeElement instanceof JetUserType; + return ((JetUserType) typeElement).getReferenceExpression(); + } + +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java b/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java index 0fee55e31ec..602cfcb63ab 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.java @@ -28,9 +28,8 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J @NotNull @Override - public JetExpression getCalleeExpression() { - // Change the AST so the the callee is an expression - throw new UnsupportedOperationException(); // TODO + public JetConstructorCalleeExpression getCalleeExpression() { + return (JetConstructorCalleeExpression) findChildByType(JetNodeTypes.CONSTRUCTOR_CALLEE); } @Nullable @@ -50,6 +49,11 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J return Collections.emptyList(); } + @Override + public JetTypeReference getTypeReference() { + return getCalleeExpression().getTypeReference(); + } + @NotNull @Override public List getTypeArguments() { diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetReferenceExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetReferenceExpression.java index 9699f0628ad..306bf6e8fb9 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetReferenceExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetReferenceExpression.java @@ -7,6 +7,7 @@ import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.BindingContextUtils; /** * @author abreslav @@ -19,7 +20,7 @@ public abstract class JetReferenceExpression extends JetExpression { protected PsiElement doResolve() { JetFile file = (JetFile) getContainingFile(); BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file); - PsiElement psiElement = bindingContext.resolveToDeclarationPsiElement(this); + PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, this); return psiElement == null ? file : psiElement; diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java index 39d08440360..68bc5722149 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java @@ -91,7 +91,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression { JetExpression receiverExpression = qualifiedExpression.getReceiverExpression(); JetFile file = (JetFile) getContainingFile(); BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file); - final JetType expressionType = bindingContext.getExpressionType(receiverExpression); + final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, receiverExpression); if (expressionType != null) { return collectLookupElements(bindingContext, expressionType.getMemberScope()); } @@ -99,7 +99,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression { else { JetFile file = (JetFile) getContainingFile(); BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file); - JetScope resolutionScope = bindingContext.getResolutionScope(JetSimpleNameExpression.this); + JetScope resolutionScope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, JetSimpleNameExpression.this); if (resolutionScope != null) { return collectLookupElements(bindingContext, resolutionScope); } @@ -119,7 +119,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression { private Object[] collectLookupElements(BindingContext bindingContext, JetScope scope) { List result = Lists.newArrayList(); for (final DeclarationDescriptor descriptor : scope.getAllDescriptors()) { - PsiElement declaration = bindingContext.getDeclarationPsiElement(descriptor.getOriginal()); + PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor.getOriginal()); LookupElementBuilder element = LookupElementBuilder.create(descriptor.getName()); String typeText = ""; String tailText = ""; diff --git a/idea/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java index 73bd83fa595..51f97050489 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java @@ -87,7 +87,7 @@ public class AnnotationResolver { for (JetAnnotationEntry annotation : annotations) { AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor(); result.add(annotationDescriptor); - trace.recordAnnotationResolution(annotation, annotationDescriptor); + trace.record(BindingContext.ANNOTATION, annotation, annotationDescriptor); } return result; } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java index 7373e96f0c6..ef21ee997f0 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java @@ -1,14 +1,13 @@ package org.jetbrains.jet.lang.resolve; import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.JetDiagnostic; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.util.*; import java.util.Collection; @@ -16,46 +15,93 @@ import java.util.Collection; * @author abreslav */ public interface BindingContext { - @Deprecated // "Tests only" - DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration); + WritableSlice ANNOTATION = ManyMapSlices.createSimpleSlice("ANNOTATION"); + WritableSlice> COMPILE_TIME_VALUE = ManyMapSlices.createSimpleSlice("COMPILE_TIME_VALUE"); + WritableSlice TYPE = ManyMapSlices.createSimpleSlice("TYPE"); + WritableSlice EXPRESSION_TYPE = new BasicWritableSlice("EXPRESSION_TYPE", RewritePolicy.DO_NOTHING); + WritableSlice REFERENCE_TARGET = new BasicWritableSlice("REFERENCE_TARGET", RewritePolicy.DO_NOTHING); + WritableSlice AUTOCAST = ManyMapSlices.createSimpleSlice("AUTOCAST"); + WritableSlice RESOLUTION_SCOPE = ManyMapSlices.createSimpleSlice("RESOLUTION_SCOPE"); - NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration); - ClassDescriptor getClassDescriptor(JetClassOrObject declaration); - TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration); - FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration); - ConstructorDescriptor getConstructorDescriptor(JetElement declaration); - AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry); + WritableSlice VARIABLE_REASSIGNMENT = ManyMapSlices.createSimpleSetSlice("VARIABLE_REASSIGNMENT"); + WritableSlice PROCESSED = ManyMapSlices.createSimpleSetSlice("PROCESSED"); + WritableSlice STATEMENT = ManyMapSlices.createRemovableSetSlice("STATEMENT"); - @Nullable - CompileTimeConstant getCompileTimeValue(JetExpression expression); + WritableSlice BACKING_FIELD_REQUIRED = new ManyMapSlices.SetSlice("BACKING_FIELD_REQUIRED", RewritePolicy.DO_NOTHING) { + @Override + public Boolean computeValue(ManyMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) { + backingFieldRequired = valueNotFound ? false : backingFieldRequired; + assert backingFieldRequired != null; + PsiElement declarationPsiElement = map.get(DESCRIPTOR_TO_DECLARATION, propertyDescriptor); + if (declarationPsiElement instanceof JetParameter) { + JetParameter jetParameter = (JetParameter) declarationPsiElement; + return jetParameter.getValOrVarNode() != null || + backingFieldRequired; + } + if (propertyDescriptor.getModifiers().isAbstract()) return false; + PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); + PropertySetterDescriptor setter = propertyDescriptor.getSetter(); + if (getter == null) { + return true; + } + else if (propertyDescriptor.isVar() && setter == null) { + return true; + } + else if (setter != null && !setter.hasBody() && !setter.getModifiers().isAbstract()) { + return true; + } + else if (!getter.hasBody() && !getter.getModifiers().isAbstract()) { + return true; + } + return backingFieldRequired; + } + }; - VariableDescriptor getVariableDescriptor(JetProperty declaration); - VariableDescriptor getVariableDescriptor(JetParameter declaration); + WritableSlice BLOCK = new ManyMapSlices.SetSlice("BLOCK", RewritePolicy.DO_NOTHING) { + @Override + public Boolean computeValue(ManyMap map, JetFunctionLiteralExpression expression, Boolean isBlock, boolean valueNotFound) { + isBlock = valueNotFound ? false : isBlock; + assert isBlock != null; + return isBlock && !expression.getFunctionLiteral().hasParameterSpecification(); + } + }; - PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter); - PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName); + ManyMapSlices.KeyNormalizer DECLARATION_DESCRIPTOR_NORMALIZER = new ManyMapSlices.KeyNormalizer() { + @Override + public DeclarationDescriptor normalize(DeclarationDescriptor declarationDescriptor) { + if (declarationDescriptor instanceof VariableAsFunctionDescriptor) { + VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) declarationDescriptor; + return descriptor.getVariableDescriptor().getOriginal(); + } + return declarationDescriptor.getOriginal(); + } + }; + ReadOnlySlice DESCRIPTOR_TO_DECLARATION = ManyMapSlices.sliceBuilder("DECLARATION_TO_DESCRIPTOR").setKeyNormalizer(DECLARATION_DESCRIPTOR_NORMALIZER).build(); - JetType getExpressionType(JetExpression expression); + WritableSlice NAMESPACE = ManyMapSlices.sliceBuilder("DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice CLASS = ManyMapSlices.sliceBuilder("CLASS").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice TYPE_PARAMETER = ManyMapSlices.sliceBuilder("TYPE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice FUNCTION = ManyMapSlices.sliceBuilder("FUNCTION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice CONSTRUCTOR = ManyMapSlices.sliceBuilder("CONSTRUCTOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice VARIABLE = ManyMapSlices.sliceBuilder("VARIABLE").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice VALUE_PARAMETER = ManyMapSlices.sliceBuilder("VALUE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice PROPERTY_ACCESSOR = ManyMapSlices.sliceBuilder("PROPERTY_ACCESSOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); - DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression); + // normalize value to getOriginal(value) + WritableSlice PRIMARY_CONSTRUCTOR_PARAMETER = ManyMapSlices.sliceBuilder("PRIMARY_CONSTRUCTOR_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); + WritableSlice OBJECT_DECLARATION = ManyMapSlices.sliceBuilder("OBJECT_DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build(); - JetType resolveTypeReference(JetTypeReference typeReference); - PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression); - PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor); + WritableSlice[] DECLARATIONS_TO_DESCRIPTORS = new WritableSlice[] { + NAMESPACE, CLASS, TYPE_PARAMETER, FUNCTION, CONSTRUCTOR, VARIABLE, VALUE_PARAMETER, PRIMARY_CONSTRUCTOR_PARAMETER, OBJECT_DECLARATION + }; - boolean isBlock(JetFunctionLiteralExpression expression); - boolean isStatement(JetExpression expression); - boolean hasBackingField(PropertyDescriptor propertyDescriptor); + ReadOnlySlice DECLARATION_TO_DESCRIPTOR = ManyMapSlices.sliceBuilder("DECLARATION_TO_DESCRIPTOR") + .setFurtherLookupSlices(DECLARATIONS_TO_DESCRIPTORS).build(); - boolean isVariableReassignment(JetExpression expression); - - ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall); - - @Nullable - JetType getAutoCastType(@NotNull JetExpression expression); - - @Nullable - JetScope getResolutionScope(@NotNull JetExpression expression); + WritableSlice LABEL_TARGET = ManyMapSlices.sliceBuilder("LABEL_TARGET").build(); + WritableSlice VALUE_PARAMETER_AS_PROPERTY = ManyMapSlices.sliceBuilder("VALUE_PARAMETER_AS_PROPERTY").build(); Collection getDiagnostics(); + + V get(ReadOnlySlice slice, K key); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java new file mode 100644 index 00000000000..17ea97a2e83 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -0,0 +1,19 @@ +package org.jetbrains.jet.lang.resolve; + +import com.intellij.psi.PsiElement; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.psi.JetReferenceExpression; + +/** + * @author abreslav + */ +public class BindingContextUtils { + public static PsiElement resolveToDeclarationPsiElement(BindingContext bindingContext, JetReferenceExpression referenceExpression) { + DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression); + if (declarationDescriptor == null) { + return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression); + } + return bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor); + } + +} diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java index b718ba1006d..e8669968c8e 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java @@ -1,56 +1,24 @@ package org.jetbrains.jet.lang.resolve; -import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.ErrorHandlerWithRegions; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.psi.*; -import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; -import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.ErrorHandler; +import org.jetbrains.jet.util.ReadOnlySlice; +import org.jetbrains.jet.util.WritableSlice; /** * @author abreslav */ public interface BindingTrace { - void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type); - - void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor); - - void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element); - - void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor); - - void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor); - - void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type); - - void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor); - - void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant value); - - void recordBlock(JetFunctionLiteralExpression expression); - - void recordStatement(@NotNull JetElement statement); - - void recordVariableReassignment(@NotNull JetExpression expression); - - void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope); - - void removeStatementRecord(@NotNull JetElement statement); - - void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor); - - void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type); - @NotNull - ErrorHandlerWithRegions getErrorHandler(); - - boolean isProcessed(@NotNull JetExpression expression); - - void markAsProcessed(@NotNull JetExpression expression); + ErrorHandler getErrorHandler(); BindingContext getBindingContext(); + + void record(WritableSlice slice, K key, V value); + + // Writes TRUE for a boolean value + void record(WritableSlice slice, K key); + + V get(ReadOnlySlice slice, K key); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceAdapter.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceAdapter.java index 4df6456f756..a0c691ec476 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceAdapter.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceAdapter.java @@ -1,112 +1,61 @@ package org.jetbrains.jet.lang.resolve; -import com.intellij.psi.PsiElement; +import com.google.common.collect.Maps; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.ErrorHandlerWithRegions; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.psi.*; -import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; -import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.ErrorHandler; +import org.jetbrains.jet.util.ReadOnlySlice; +import org.jetbrains.jet.util.WritableSlice; + +import java.util.Map; /** * @author abreslav */ public class BindingTraceAdapter implements BindingTrace { - private final BindingTrace originalTrace; - - @Override - public void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type) { - originalTrace.recordAutoCast(expression, type); + public interface RecordHandler { + void handleRecord(WritableSlice slice, K key, V value); } + private final BindingTrace originalTrace; + private Map handlers = Maps.newHashMap(); + public BindingTraceAdapter(BindingTrace originalTrace) { this.originalTrace = originalTrace; } - public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) { - originalTrace.recordExpressionType(expression, type); - } - - public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { - originalTrace.recordReferenceResolution(expression, descriptor); - } - - public void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element) { - originalTrace.recordLabelResolution(expression, element); - } - - public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor) { - originalTrace.recordDeclarationResolution(declaration, descriptor); - } - @Override - public void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor) { - originalTrace.recordValueParameterAsPropertyResolution(declaration, descriptor); - } - - public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) { - originalTrace.recordTypeResolution(typeReference, type); - } - - @Override - public void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor) { - originalTrace.recordAnnotationResolution(annotationEntry, annotationDescriptor); - } - - @Override - public void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant value) { - originalTrace.recordCompileTimeValue(expression, value); - } - - public void recordBlock(JetFunctionLiteralExpression expression) { - originalTrace.recordBlock(expression); - } - - @Override - public void recordStatement(@NotNull JetElement statement) { - originalTrace.recordStatement(statement); - } - - @Override - public void recordVariableReassignment(@NotNull JetExpression expression) { - originalTrace.recordVariableReassignment(expression); - } - - @Override - public void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor) { - originalTrace.requireBackingField(propertyDescriptor); - } - @NotNull - @Override - public ErrorHandlerWithRegions getErrorHandler() { + public ErrorHandler getErrorHandler() { return originalTrace.getErrorHandler(); } - @Override - public void removeStatementRecord(@NotNull JetElement statement) { - originalTrace.removeStatementRecord(statement); - } - - @Override - public void markAsProcessed(@NotNull JetExpression expression) { - originalTrace.markAsProcessed(expression); - } - - @Override - public boolean isProcessed(@NotNull JetExpression expression) { - return originalTrace.isProcessed(expression); - } - @Override public BindingContext getBindingContext() { return originalTrace.getBindingContext(); } @Override - public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) { - originalTrace.recordResolutionScope(expression, scope); + public void record(WritableSlice slice, K key, V value) { + originalTrace.record(slice, key, value); + RecordHandler recordHandler = handlers.get(slice); + if (recordHandler != null) { + recordHandler.handleRecord(slice, key, value); + } } -} + + @Override + public void record(WritableSlice slice, K key) { + record(slice, key, true); + } + + @Override + public V get(ReadOnlySlice slice, K key) { + return originalTrace.get(slice, key); + } + + public BindingTraceAdapter addHandler(@NotNull WritableSlice slice, @NotNull RecordHandler handler) { + handlers.put(slice, handler); + return this; + } + +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java index c20ecfc4aea..d919e31704f 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java @@ -1,238 +1,42 @@ package org.jetbrains.jet.lang.resolve; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.CollectingErrorHandler; -import org.jetbrains.jet.lang.ErrorHandlerWithRegions; +import org.jetbrains.jet.lang.ErrorHandler; import org.jetbrains.jet.lang.JetDiagnostic; -import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.psi.*; -import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; -import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.util.ManyMapImpl; +import org.jetbrains.jet.util.MutableManyMap; +import org.jetbrains.jet.util.ReadOnlySlice; +import org.jetbrains.jet.util.WritableSlice; -import java.util.*; +import java.util.Collection; +import java.util.List; /** * @author abreslav */ public class BindingTraceContext implements BindingTrace { - private final Map expressionTypes = new HashMap(); - private final Map resolutionResults = new HashMap(); - private final Map labelResolutionResults = new HashMap(); - private final Map types = new HashMap(); - private final Map descriptorToDeclarations = new HashMap(); - private final Map declarationsToDescriptors = new HashMap(); - private final Map constructorDeclarationsToDescriptors = new HashMap(); - private final Map namespaceDeclarationsToDescriptors = Maps.newHashMap(); - private final Map primaryConstructorParameterDeclarationsToPropertyDescriptors = Maps.newHashMap(); - private final Map autoCasts = Maps.newHashMap(); - private final Map resolutionScopes = Maps.newHashMap(); - - private final Set variableReassignments = Sets.newHashSet(); - - private final Set blocks = new HashSet(); - private final Set statements = new HashSet(); - private final Set backingFieldRequired = new HashSet(); - private final Set processed = Sets.newHashSet(); - private final List diagnostics = Lists.newArrayList(); - - private final ErrorHandlerWithRegions errorHandler = new ErrorHandlerWithRegions(new CollectingErrorHandler(diagnostics)); - private Map annotationDescriptos = Maps.newHashMap(); - private Map> compileTimeValues = Maps.newHashMap(); + private final ErrorHandler errorHandler = new CollectingErrorHandler(diagnostics); + private final MutableManyMap map = ManyMapImpl.create(); private final BindingContext bindingContext = new BindingContext() { - @Override - public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) { - if (declaration instanceof JetNamespace) { - JetNamespace namespace = (JetNamespace) declaration; - return getNamespaceDescriptor(namespace); - } - return declarationsToDescriptors.get(declaration); - } - - public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) { - return namespaceDeclarationsToDescriptors.get(declaration); - } - - @Override - public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) { - return (ClassDescriptor) declarationsToDescriptors.get((JetDeclaration) declaration); - } - - @Override - public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) { - return (TypeParameterDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) { - return (FunctionDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public VariableDescriptor getVariableDescriptor(JetProperty declaration) { - return (VariableDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public VariableDescriptor getVariableDescriptor(JetParameter declaration) { - return (VariableDescriptor) declarationsToDescriptors.get(declaration); - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) { - return primaryConstructorParameterDeclarationsToPropertyDescriptors.get(primaryConstructorParameter); - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) { - return (PropertyDescriptor) declarationsToDescriptors.get(objectDeclarationName); - } - - @Nullable - @Override - public ConstructorDescriptor getConstructorDescriptor(@NotNull JetElement declaration) { - return constructorDeclarationsToDescriptors.get(declaration); - } - - @Override - public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) { - return annotationDescriptos.get(annotationEntry); - } - - @Override - public CompileTimeConstant getCompileTimeValue(JetExpression expression) { - return compileTimeValues.get(expression); - } - - @Override - public JetType resolveTypeReference(JetTypeReference typeReference) { - return types.get(typeReference); - } - - @Override - public JetType getExpressionType(JetExpression expression) { - return expressionTypes.get(expression); - } - - @Override - public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) { - return resolutionResults.get(referenceExpression); - } - - @Override - public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) { - DeclarationDescriptor declarationDescriptor = resolveReferenceExpression(referenceExpression); - if (declarationDescriptor == null) { - return labelResolutionResults.get(referenceExpression); - } - return descriptorToDeclarations.get(getOriginal(declarationDescriptor)); - } - - @Override - public PsiElement getDeclarationPsiElement(@NotNull DeclarationDescriptor descriptor) { - return descriptorToDeclarations.get(getOriginal(descriptor)); - } - - @Override - public boolean isBlock(JetFunctionLiteralExpression expression) { - return !expression.getFunctionLiteral().hasParameterSpecification() && blocks.contains(expression); - } - - @Override - public boolean isStatement(@NotNull JetExpression expression) { - return statements.contains(expression); - } - - @Override - public boolean hasBackingField(@NotNull PropertyDescriptor propertyDescriptor) { - PsiElement declarationPsiElement = getDeclarationPsiElement(propertyDescriptor); - if (declarationPsiElement instanceof JetParameter) { - JetParameter jetParameter = (JetParameter) declarationPsiElement; - return jetParameter.getValOrVarNode() != null || - backingFieldRequired.contains(propertyDescriptor); - } - if (propertyDescriptor.getModifiers().isAbstract()) return false; - PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); - PropertySetterDescriptor setter = propertyDescriptor.getSetter(); - if (getter == null) { - return true; - } - else if (propertyDescriptor.isVar() && setter == null) { - return true; - } - else if (setter != null && !setter.hasBody() && !setter.getModifiers().isAbstract()) { - return true; - } - else if (!getter.hasBody() && !getter.getModifiers().isAbstract()) { - return true; - } - return backingFieldRequired.contains(propertyDescriptor); - } - - @Override - public boolean isVariableReassignment(JetExpression expression) { - return variableReassignments.contains(expression); - } - - public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) { - JetTypeReference typeReference = superCall.getTypeReference(); - if (typeReference == null) return null; - - JetTypeElement typeElement = typeReference.getTypeElement(); - if (!(typeElement instanceof JetUserType)) return null; - - DeclarationDescriptor descriptor = resolveReferenceExpression(((JetUserType) typeElement).getReferenceExpression()); - return descriptor instanceof ConstructorDescriptor ? (ConstructorDescriptor) descriptor : null; - } - - @Override - public JetType getAutoCastType(@NotNull JetExpression expression) { - return autoCasts.get(expression); - } - - @Override - public JetScope getResolutionScope(@NotNull JetExpression expression) { - return resolutionScopes.get(expression); - } - @Override public Collection getDiagnostics() { return diagnostics; } + @Override + public V get(ReadOnlySlice slice, K key) { + return BindingTraceContext.this.get(slice, key); + } }; - public BindingTraceContext() { - } - - public void destructiveMerge(BindingTraceContext other) { - safePutAll(expressionTypes, other.expressionTypes); - resolutionResults.putAll(other.resolutionResults); - safePutAll(labelResolutionResults, other.labelResolutionResults); - safePutAll(types, other.types); - safePutAll(descriptorToDeclarations, other.descriptorToDeclarations); - safePutAll(declarationsToDescriptors, other.declarationsToDescriptors); - safePutAll(constructorDeclarationsToDescriptors, other.constructorDeclarationsToDescriptors); - safePutAll(namespaceDeclarationsToDescriptors, other.namespaceDeclarationsToDescriptors); - safePutAll(primaryConstructorParameterDeclarationsToPropertyDescriptors, other.primaryConstructorParameterDeclarationsToPropertyDescriptors); - safePutAll(autoCasts, other.autoCasts); - safePutAll(resolutionScopes, other.resolutionScopes); - - blocks.addAll(other.blocks); - statements.addAll(other.statements); - backingFieldRequired.addAll(other.backingFieldRequired); - processed.addAll(other.processed); - - variableReassignments.addAll(other.variableReassignments); - - diagnostics.addAll(other.diagnostics); + @NotNull + @Override + public ErrorHandler getErrorHandler() { + return errorHandler; } @Override @@ -240,145 +44,18 @@ public class BindingTraceContext implements BindingTrace { return bindingContext; } - private void safePutAll(Map my, Map other) { - assert keySetIntersection(my, other).isEmpty() : keySetIntersection(my, other); - - my.putAll(other); - } - - private HashSet keySetIntersection(Map my, Map other) { - HashSet keySet = Sets.newHashSet(my.keySet()); - keySet.retainAll(other.keySet()); - return keySet; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @NotNull - public ErrorHandlerWithRegions getErrorHandler() { - return errorHandler; + @Override + public void record(WritableSlice slice, K key, V value) { + map.put(slice, key, value); } @Override - public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) { - safePut(expressionTypes, expression, type); + public void record(WritableSlice slice, K key) { + record(slice, key, true); } @Override - public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { - resolutionResults.put(expression, descriptor); + public V get(ReadOnlySlice slice, K key) { + return map.get(slice, key); } - - @Override - public void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element) { - safePut(labelResolutionResults, expression, element); - } - - @Override - public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) { - safePut(types, typeReference, type); - } - - @Override - public void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor) { - safePut(annotationDescriptos, annotationEntry, annotationDescriptor); - } - - @Override - public void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant value) { - safePut(compileTimeValues, expression, value, true); - } - - @Override - public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor) { - safePut(descriptorToDeclarations, getOriginal(descriptor), declaration); - descriptor.accept(new DeclarationDescriptorVisitor() { - @Override - public Void visitConstructorDescriptor(ConstructorDescriptor constructorDescriptor, PsiElement declaration) { - safePut(constructorDeclarationsToDescriptors, declaration, constructorDescriptor); - return null; - } - - @Override - public Void visitNamespaceDescriptor(NamespaceDescriptor descriptor, PsiElement declaration) { - safePut(namespaceDeclarationsToDescriptors, declaration, descriptor); - return null; - } - - public Void visitDeclarationDescriptor(DeclarationDescriptor descriptor, PsiElement declaration) { - safePut(declarationsToDescriptors, declaration, getOriginal(descriptor)); - return null; - } - }, declaration); - } - - @Override - public void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor) { - safePut(primaryConstructorParameterDeclarationsToPropertyDescriptors, declaration, (PropertyDescriptor) getOriginal(descriptor)); - safePut(descriptorToDeclarations, getOriginal(descriptor), declaration); - } - - private void safePut(Map map, K key, V value) { - safePut(map, key, value, false); - } - - private void safePut(Map map, K key, V value, boolean canBeEquals) { - V oldValue = map.put(key, value); - assert oldValue == null || oldValue == value || (!canBeEquals || oldValue.equals(value)) : - (key instanceof PsiElement ? key.toString() + " \"" + ((PsiElement) key).getText() + "\"" : key.toString()) + " -> " + oldValue + " and " + value; - } - - @Override - public void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor) { - backingFieldRequired.add(propertyDescriptor); - } - - @Override - public void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type) { - safePut(autoCasts, expression, type); - } - - @Override - public void recordBlock(JetFunctionLiteralExpression expression) { - blocks.add(expression); - } - - @Override - public void recordStatement(@NotNull JetElement statement) { - statements.add(statement); - } - - @Override - public void recordVariableReassignment(@NotNull JetExpression expression) { - variableReassignments.add(expression); - } - - @Override - public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) { - safePut(resolutionScopes, expression, scope); - } - - @Override - public void removeStatementRecord(@NotNull JetElement statement) { - statements.remove(statement); - } - - private DeclarationDescriptor getOriginal(DeclarationDescriptor declarationDescriptor) { - if (declarationDescriptor instanceof VariableAsFunctionDescriptor) { - VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) declarationDescriptor; - return descriptor.getVariableDescriptor().getOriginal(); - } - return declarationDescriptor.getOriginal(); - } - - @Override - public void markAsProcessed(@NotNull JetExpression expression) { - processed.add(expression); - } - - @Override - public boolean isProcessed(@NotNull JetExpression expression) { - return processed.contains(expression); - } - -} +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java b/idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java deleted file mode 100644 index 10888682477..00000000000 --- a/idea/src/org/jetbrains/jet/lang/resolve/ChildBindingTrace.java +++ /dev/null @@ -1,254 +0,0 @@ -package org.jetbrains.jet.lang.resolve; - -import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.JetDiagnostic; -import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.psi.*; -import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; -import org.jetbrains.jet.lang.types.JetType; - -import java.util.Collection; - -/** - * @author abreslav - */ -public class ChildBindingTrace extends BindingTraceContext { - - private final BindingContext parentBindingContext; - - private final BindingContext bindingContext = new BindingContext() { - @Override - @Deprecated - public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) { - DeclarationDescriptor value = ChildBindingTrace.super.getBindingContext().getDeclarationDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getDeclarationDescriptor(declaration); - } - - @Override - public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) { - NamespaceDescriptor value = ChildBindingTrace.super.getBindingContext().getNamespaceDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getNamespaceDescriptor(declaration); - } - - @Override - public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) { - ClassDescriptor value = ChildBindingTrace.super.getBindingContext().getClassDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getClassDescriptor(declaration); - } - - @Override - public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) { - TypeParameterDescriptor value = ChildBindingTrace.super.getBindingContext().getTypeParameterDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getTypeParameterDescriptor(declaration); - } - - @Override - public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) { - FunctionDescriptor value = ChildBindingTrace.super.getBindingContext().getFunctionDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getFunctionDescriptor(declaration); - } - - @Override - public ConstructorDescriptor getConstructorDescriptor(JetElement declaration) { - ConstructorDescriptor value = ChildBindingTrace.super.getBindingContext().getConstructorDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getConstructorDescriptor(declaration); - } - - @Override - public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) { - AnnotationDescriptor value = ChildBindingTrace.super.getBindingContext().getAnnotationDescriptor(annotationEntry); - if (value != null) { - return value; - } - return parentBindingContext.getAnnotationDescriptor(annotationEntry); - } - - @Override - @Nullable - public CompileTimeConstant getCompileTimeValue(JetExpression expression) { - return parentBindingContext.getCompileTimeValue(expression); - } - - @Override - public VariableDescriptor getVariableDescriptor(JetProperty declaration) { - VariableDescriptor value = ChildBindingTrace.super.getBindingContext().getVariableDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getVariableDescriptor(declaration); - } - - @Override - public VariableDescriptor getVariableDescriptor(JetParameter declaration) { - VariableDescriptor value = ChildBindingTrace.super.getBindingContext().getVariableDescriptor(declaration); - if (value != null) { - return value; - } - return parentBindingContext.getVariableDescriptor(declaration); - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) { - PropertyDescriptor value = ChildBindingTrace.super.getBindingContext().getPropertyDescriptor(primaryConstructorParameter); - if (value != null) { - return value; - } - return parentBindingContext.getPropertyDescriptor(primaryConstructorParameter); - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) { - PropertyDescriptor value = ChildBindingTrace.super.getBindingContext().getPropertyDescriptor(objectDeclarationName); - if (value != null) { - return value; - } - return parentBindingContext.getPropertyDescriptor(objectDeclarationName); - } - - @Override - public JetType getExpressionType(JetExpression expression) { - JetType value = ChildBindingTrace.super.getBindingContext().getExpressionType(expression); - if (value != null) { - return value; - } - return parentBindingContext.getExpressionType(expression); - } - - @Override - public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) { - DeclarationDescriptor value = ChildBindingTrace.super.getBindingContext().resolveReferenceExpression(referenceExpression); - if (value != null) { - return value; - } - return parentBindingContext.resolveReferenceExpression(referenceExpression); - } - - @Override - public JetType resolveTypeReference(JetTypeReference typeReference) { - JetType value = ChildBindingTrace.super.getBindingContext().resolveTypeReference(typeReference); - if (value != null) { - return value; - } - return parentBindingContext.resolveTypeReference(typeReference); - } - - @Override - public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) { - PsiElement value = ChildBindingTrace.super.getBindingContext().resolveToDeclarationPsiElement(referenceExpression); - if (value != null) { - return value; - } - return parentBindingContext.resolveToDeclarationPsiElement(referenceExpression); - } - - @Override - public PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor) { - PsiElement value = ChildBindingTrace.super.getBindingContext().getDeclarationPsiElement(descriptor); - if (value != null) { - return value; - } - return parentBindingContext.getDeclarationPsiElement(descriptor); - } - - @Override - public boolean isBlock(JetFunctionLiteralExpression expression) { - boolean value = ChildBindingTrace.super.getBindingContext().isBlock(expression); - if (!value) { - return value; - } - return parentBindingContext.isBlock(expression); - } - - @Override - public boolean isStatement(JetExpression expression) { - boolean value = ChildBindingTrace.super.getBindingContext().isStatement(expression); - if (!value) { - return value; - } - return parentBindingContext.isStatement(expression); - } - - @Override - public boolean hasBackingField(PropertyDescriptor propertyDescriptor) { - boolean value = ChildBindingTrace.super.getBindingContext().hasBackingField(propertyDescriptor); - if (!value) { - return value; - } - return parentBindingContext.hasBackingField(propertyDescriptor); - } - - @Override - public boolean isVariableReassignment(JetExpression expression) { - boolean value = ChildBindingTrace.super.getBindingContext().isVariableReassignment(expression); - if (!value) { - return value; - } - return parentBindingContext.isVariableReassignment(expression); - } - - @Override - public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) { - ConstructorDescriptor value = ChildBindingTrace.super.getBindingContext().resolveSuperConstructor(superCall); - if (value != null) { - return value; - } - return parentBindingContext.resolveSuperConstructor(superCall); - } - - @Override - @Nullable - public JetType getAutoCastType(@NotNull JetExpression expression) { - JetType value = ChildBindingTrace.super.getBindingContext().getAutoCastType(expression); - if (value != null) { - return value; - } - return parentBindingContext.getAutoCastType(expression); - } - - @Override - @Nullable - public JetScope getResolutionScope(@NotNull JetExpression expression) { - JetScope value = ChildBindingTrace.super.getBindingContext().getResolutionScope(expression); - if (value != null) { - return value; - } - return parentBindingContext.getResolutionScope(expression); - } - - @Override - public Collection getDiagnostics() { - // This deliberately returns only my own diagnostics - return ChildBindingTrace.super.getBindingContext().getDiagnostics(); - } - }; - - public ChildBindingTrace(BindingContext parent) { - this.parentBindingContext = parent; - } - - @Override - public BindingContext getBindingContext() { - return parentBindingContext; - } -} diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java index f7ee75d5290..7a94482da7f 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java @@ -51,7 +51,7 @@ public class ClassDescriptorResolver { annotationResolver.resolveAnnotations(scope, classElement.getModifierList()), JetPsiUtil.safeName(classElement.getName())); - trace.recordDeclarationResolution(classElement, classDescriptor); + trace.record(BindingContext.CLASS, classElement, classDescriptor); final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler()); @@ -134,7 +134,7 @@ public class ClassDescriptorResolver { JetPsiUtil.safeName(typeParameter.getName()), index ); - trace.recordDeclarationResolution(typeParameter, typeParameterDescriptor); + trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor); typeParameters.add(typeParameterDescriptor); index++; } @@ -142,7 +142,7 @@ public class ClassDescriptorResolver { descriptor.setOpen(classElement.hasModifier(JetTokens.OPEN_KEYWORD) || classElement.hasModifier(JetTokens.ABSTRACT_KEYWORD)); - trace.recordDeclarationResolution(classElement, descriptor); + trace.record(BindingContext.CLASS, classElement, descriptor); } public void resolveSupertypes(@NotNull JetClassOrObject jetClass, @NotNull MutableClassDescriptor descriptor) { @@ -151,7 +151,7 @@ public class ClassDescriptorResolver { // TODO : beautify if (jetClass instanceof JetEnumEntry) { JetClassOrObject parent = PsiTreeUtil.getParentOfType(jetClass, JetClassOrObject.class); - ClassDescriptor parentDescriptor = trace.getBindingContext().getClassDescriptor(parent); + ClassDescriptor parentDescriptor = trace.getBindingContext().get(BindingContext.CLASS, parent); if (parentDescriptor.getTypeConstructor().getParameters().isEmpty()) { defaultSupertype = parentDescriptor.getDefaultType(); } @@ -227,7 +227,7 @@ public class ClassDescriptorResolver { valueParameterDescriptors, returnType); - trace.recordDeclarationResolution(function, functionDescriptor); + trace.record(BindingContext.FUNCTION, function, functionDescriptor); return functionDescriptor; } @@ -272,7 +272,7 @@ public class ClassDescriptorResolver { ); // TODO : Default values??? - trace.recordDeclarationResolution(valueParameter, valueParameterDescriptor); + trace.record(BindingContext.VALUE_PARAMETER, valueParameter, valueParameterDescriptor); return valueParameterDescriptor; } @@ -299,7 +299,7 @@ public class ClassDescriptorResolver { ); // typeParameterDescriptor.addUpperBound(bound); extensibleScope.addTypeParameterDescriptor(typeParameterDescriptor); - trace.recordDeclarationResolution(typeParameter, typeParameterDescriptor); + trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor); return typeParameterDescriptor; } @@ -330,14 +330,14 @@ public class ClassDescriptorResolver { ClassifierDescriptor classifier = scope.getClassifier(referencedName); if (classifier != null) { trace.getErrorHandler().genericError(subjectTypeParameterName.getNode(), referencedName + " does not refer to a type parameter of " + declaration.getName()); - trace.recordReferenceResolution(subjectTypeParameterName, classifier); + trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, classifier); } else { trace.getErrorHandler().unresolvedReference(subjectTypeParameterName); } } else { - trace.recordReferenceResolution(subjectTypeParameterName, typeParameterDescriptor); + trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, typeParameterDescriptor); JetTypeReference boundTypeReference = constraint.getBoundTypeReference(); if (boundTypeReference != null) { JetType bound = resolveAndCheckUpperBoundType(boundTypeReference, scope, constraint.isClassObjectContraint()); @@ -430,7 +430,7 @@ public class ClassDescriptorResolver { JetPsiUtil.safeName(parameter.getName()), type, parameter.isMutable()); - trace.recordDeclarationResolution(parameter, variableDescriptor); + trace.record(BindingContext.VALUE_PARAMETER, parameter, variableDescriptor); return variableDescriptor; } @@ -449,7 +449,7 @@ public class ClassDescriptorResolver { JetPsiUtil.safeName(property.getName()), type, property.isVar()); - trace.recordDeclarationResolution(property, variableDescriptor); + trace.record(BindingContext.VARIABLE, property, variableDescriptor); return variableDescriptor; } @@ -472,7 +472,7 @@ public class ClassDescriptorResolver { JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration(); if (nameAsDeclaration != null) { - trace.recordDeclarationResolution(nameAsDeclaration, propertyDescriptor); + trace.record(BindingContext.OBJECT_DECLARATION, nameAsDeclaration, propertyDescriptor); } return propertyDescriptor; } @@ -520,7 +520,7 @@ public class ClassDescriptorResolver { resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor), resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor)); - trace.recordDeclarationResolution(property, propertyDescriptor); + trace.record(BindingContext.VARIABLE, property, propertyDescriptor); return propertyDescriptor; } @@ -612,7 +612,7 @@ public class ClassDescriptorResolver { MutableValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(setterDescriptor, parameter, 0, type); setterDescriptor.initialize(valueParameterDescriptor); } - trace.recordDeclarationResolution(setter, setterDescriptor); + trace.record(BindingContext.PROPERTY_ACCESSOR, setter, setterDescriptor); } return setterDescriptor; } @@ -633,7 +633,7 @@ public class ClassDescriptorResolver { getterDescriptor = new PropertyGetterDescriptor( resolveModifiers(getter.getModifierList(), DEFAULT_MODIFIERS), // TODO : default modifiers differ in different contexts propertyDescriptor, annotations, returnType, getter.getBodyExpression() != null); - trace.recordDeclarationResolution(getter, getterDescriptor); + trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor); } return getterDescriptor; } @@ -656,7 +656,7 @@ public class ClassDescriptorResolver { annotationResolver.resolveAnnotations(scope, modifierList), isPrimary ); - trace.recordDeclarationResolution(declarationToTrace, constructorDescriptor); + trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor); return constructorDescriptor.initialize( typeParameters, resolveValueParameters( @@ -704,7 +704,7 @@ public class ClassDescriptorResolver { isMutable ? type : null, type); propertyDescriptor.initialize(Collections.emptyList(), null, null); - trace.recordValueParameterAsPropertyResolution(parameter, propertyDescriptor); + trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor); return propertyDescriptor; } @@ -971,5 +971,4 @@ public class ClassDescriptorResolver { previousInstruction.accept(visitor); } } - } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.java b/idea/src/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.java new file mode 100644 index 00000000000..505a253ed44 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.java @@ -0,0 +1,79 @@ +package org.jetbrains.jet.lang.resolve; + +import com.google.common.collect.Lists; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.CollectingErrorHandler; +import org.jetbrains.jet.lang.ErrorHandler; +import org.jetbrains.jet.lang.JetDiagnostic; +import org.jetbrains.jet.util.*; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @author abreslav + */ +public class TemporaryBindingTrace implements BindingTrace { + private final BindingContext parentContext; + private final MutableManyMap map = ManyMapImpl.create(); + private final List diagnostics = Lists.newArrayList(); + private final ErrorHandler errorHandler = new CollectingErrorHandler(diagnostics); + + private final BindingContext bindingContext = new BindingContext() { + @Override + public Collection getDiagnostics() { + throw new UnsupportedOperationException(); // TODO + } + + @Override + public V get(ReadOnlySlice slice, K key) { + return TemporaryBindingTrace.this.get(slice, key); + } + }; + + public TemporaryBindingTrace(BindingContext parentContext) { + this.parentContext = parentContext; + } + + @Override + @NotNull + public ErrorHandler getErrorHandler() { + return errorHandler; + } + + @Override + public BindingContext getBindingContext() { + return bindingContext; + } + + @Override + public void record(WritableSlice slice, K key, V value) { + map.put(slice, key, value); + } + + @Override + public void record(WritableSlice slice, K key) { + record(slice, key, true); + } + + @Override + public V get(ReadOnlySlice slice, K key) { + if (map.containsKey(slice, key)) { + return map.get(slice, key); + } + return parentContext.get(slice, key); + } + + public void addAllMyDataTo(BindingTrace trace) { + for (Map.Entry, ?> entry : map) { + ManyMapKey manyMapKey = entry.getKey(); + Object value = entry.getValue(); + + //noinspection unchecked + trace.record(manyMapKey.getSlice(), manyMapKey.getKey(), value); + } + + AnalyzingUtils.applyHandler(trace.getErrorHandler(), diagnostics); + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index b6ad9bdfd55..182d8731119 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -16,6 +16,7 @@ import org.jetbrains.jet.lang.types.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetTypeInferrer; import org.jetbrains.jet.lexer.JetTokens; +import org.jetbrains.jet.util.WritableSlice; import java.util.*; @@ -47,34 +48,32 @@ public class TopDownAnalyzer { this.trace = bindingTrace; // This allows access to backing fields - this.traceForConstructors = new BindingTraceAdapter(bindingTrace) { + this.traceForConstructors = new BindingTraceAdapter(bindingTrace).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler() { @Override - public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { - super.recordReferenceResolution(expression, descriptor); + public void handleRecord(WritableSlice slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) { if (expression instanceof JetSimpleNameExpression) { JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression; if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) { - if (!trace.getBindingContext().hasBackingField((PropertyDescriptor) descriptor)) { + if (!trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) descriptor)) { TopDownAnalyzer.this.trace.getErrorHandler().genericError(expression.getNode(), "This property does not have a backing field"); } } } } - }; + }); // This tracks access to properties in order to register primary constructor parameters that yield real fields (JET-9) - this.traceForMembers = new BindingTraceAdapter(bindingTrace) { + this.traceForMembers = new BindingTraceAdapter(bindingTrace).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler() { @Override - public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { - super.recordReferenceResolution(expression, descriptor); + public void handleRecord(WritableSlice slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) { if (descriptor instanceof PropertyDescriptor) { PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor; if (primaryConstructorParameterProperties.contains(propertyDescriptor)) { - requireBackingField(propertyDescriptor); + traceForMembers.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor); } } } - }; + }); } @Deprecated // For JetStandardLibraryOnly @@ -129,8 +128,6 @@ public class TopDownAnalyzer { resolveFunctionAndPropertyHeaders(); // Constructor headers are resolved as well resolveBehaviorDeclarationBodies(); - - trace.getErrorHandler().close(); } private void collectNamespacesAndClassifiers( @@ -155,7 +152,7 @@ public class TopDownAnalyzer { ); namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler()).setDebugName("Namespace member scope")); owner.addNamespace(namespaceDescriptor); - trace.recordDeclarationResolution(namespace, namespaceDescriptor); + trace.record(BindingContext.NAMESPACE, namespace, namespaceDescriptor); } namespaceDescriptors.put(namespace, namespaceDescriptor); @@ -222,7 +219,7 @@ public class TopDownAnalyzer { }; visitClassOrObject(declaration, (Map) objects, owner, outerScope, mutableClassDescriptor); createPrimaryConstructor(mutableClassDescriptor); - trace.recordDeclarationResolution((PsiElement) declaration, mutableClassDescriptor); + trace.record(BindingContext.CLASS, declaration, mutableClassDescriptor); return mutableClassDescriptor; } @@ -312,7 +309,7 @@ public class TopDownAnalyzer { } if (classifierDescriptor != null) { - trace.recordReferenceResolution(referenceExpression, classifierDescriptor); + trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, classifierDescriptor); String aliasName = importDirective.getAliasName(); String importedClassifierName = aliasName != null ? aliasName : classifierDescriptor.getName(); @@ -356,7 +353,7 @@ public class TopDownAnalyzer { for (JetDelegationSpecifier delegationSpecifier : jetClass.getDelegationSpecifiers()) { JetTypeReference typeReference = delegationSpecifier.getTypeReference(); if (typeReference != null) { - JetType type = trace.getBindingContext().resolveTypeReference(typeReference); + JetType type = trace.getBindingContext().get(BindingContext.TYPE, typeReference); classDescriptorResolver.checkBounds(typeReference, type); } } @@ -364,7 +361,7 @@ public class TopDownAnalyzer { for (JetTypeParameter jetTypeParameter : jetClass.getTypeParameters()) { JetTypeReference extendsBound = jetTypeParameter.getExtendsBound(); if (extendsBound != null) { - JetType type = trace.getBindingContext().resolveTypeReference(extendsBound); + JetType type = trace.getBindingContext().get(BindingContext.TYPE, extendsBound); if (type != null) { classDescriptorResolver.checkBounds(extendsBound, type); } @@ -374,7 +371,7 @@ public class TopDownAnalyzer { for (JetTypeConstraint constraint : jetClass.getTypeConstaints()) { JetTypeReference extendsBound = constraint.getBoundTypeReference(); if (extendsBound != null) { - JetType type = trace.getBindingContext().resolveTypeReference(extendsBound); + JetType type = trace.getBindingContext().get(BindingContext.TYPE, extendsBound); if (type != null) { classDescriptorResolver.checkBounds(extendsBound, type); } @@ -534,7 +531,7 @@ public class TopDownAnalyzer { JetClass jetClass = entry.getKey(); if (classDescriptor.getUnsubstitutedPrimaryConstructor() == null) { for (PropertyDescriptor propertyDescriptor : classDescriptor.getProperties()) { - if (trace.getBindingContext().hasBackingField(propertyDescriptor)) { + if ((boolean) trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) { PsiElement nameIdentifier = jetClass.getNameIdentifier(); if (nameIdentifier != null) { trace.getErrorHandler().genericError(nameIdentifier.getNode(), @@ -572,7 +569,7 @@ public class TopDownAnalyzer { if (delegateExpression != null) { JetScope scope = scopeForConstructor == null ? descriptor.getScopeForMemberResolution() : scopeForConstructor; JetType type = typeInferrer.getType(scope, delegateExpression, false, JetTypeInferrer.NO_EXPECTED_TYPE); - JetType supertype = trace.getBindingContext().resolveTypeReference(specifier.getTypeReference()); + JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference()); if (type != null && !semanticServices.getTypeChecker().isSubtypeOf(type, supertype)) { // TODO : Convertible? trace.getErrorHandler().typeMismatch(delegateExpression, supertype, type); } @@ -597,7 +594,7 @@ public class TopDownAnalyzer { @Override public void visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier) { - JetType supertype = trace.getBindingContext().resolveTypeReference(specifier.getTypeReference()); + JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference()); if (supertype != null) { DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor(); if (declarationDescriptor instanceof ClassDescriptor) { @@ -747,7 +744,7 @@ public class TopDownAnalyzer { constructorScope.setThisType(descriptor.getContainingDeclaration().getDefaultType()); for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) { - JetParameter parameter = (JetParameter) trace.getBindingContext().getDeclarationPsiElement(valueParameterDescriptor); + JetParameter parameter = (JetParameter) trace.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, valueParameterDescriptor); if (parameter.getValOrVarNode() == null || !primary) { constructorScope.addVariableDescriptor(valueParameterDescriptor); } @@ -837,27 +834,26 @@ public class TopDownAnalyzer { } JetExpression initializer = property.getInitializer(); - if (!property.isVar() && initializer != null && !trace.getBindingContext().hasBackingField(propertyDescriptor)) { + if (!property.isVar() && initializer != null && !trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) { trace.getErrorHandler().genericError(initializer.getNode(), "Initializer is not allowed here because this property has no setter and no backing field either"); } } private BindingTraceAdapter createFieldTrackingTrace(final PropertyDescriptor propertyDescriptor) { - return new BindingTraceAdapter(traceForMembers) { + return new BindingTraceAdapter(traceForMembers).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler() { @Override - public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { - super.recordReferenceResolution(expression, descriptor); + public void handleRecord(WritableSlice slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) { if (expression instanceof JetSimpleNameExpression) { JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression; if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) { // This check may be considered redundant as long as $x is only accessible from accessors to $x if (descriptor == propertyDescriptor) { // TODO : original? - requireBackingField(propertyDescriptor); + traceForMembers.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor); // TODO: this trace? } } } } - }; + }); } private void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java index 7333f8dbc76..74afa4e7c20 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java @@ -31,14 +31,14 @@ public class TypeResolver { @NotNull public JetType resolveType(@NotNull final JetScope scope, @NotNull final JetTypeReference typeReference) { - JetType cachedType = trace.getBindingContext().resolveTypeReference(typeReference); + JetType cachedType = trace.getBindingContext().get(BindingContext.TYPE, typeReference); if (cachedType != null) return cachedType; final List annotations = annotationResolver.createAnnotationStubs(typeReference.getAnnotations()); JetTypeElement typeElement = typeReference.getTypeElement(); JetType type = resolveTypeElement(scope, annotations, typeElement, false); - trace.recordTypeResolution(typeReference, type); + trace.record(BindingContext.TYPE, typeReference, type); return type; } @@ -60,7 +60,7 @@ public class TypeResolver { if (classifierDescriptor instanceof TypeParameterDescriptor) { TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor; - trace.recordReferenceResolution(referenceExpression, typeParameterDescriptor); + trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, typeParameterDescriptor); result[0] = new JetTypeImpl( annotations, @@ -72,8 +72,8 @@ public class TypeResolver { } else if (classifierDescriptor instanceof ClassDescriptor) { ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptor; - - trace.recordReferenceResolution(referenceExpression, classifierDescriptor); + + trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, classifierDescriptor); TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor(); List arguments = resolveTypeProjections(scope, typeConstructor, type.getTypeArguments()); List parameters = typeConstructor.getParameters(); @@ -289,7 +289,7 @@ public class TypeResolver { NamespaceDescriptor namespace = scope.getNamespace(userType.getReferencedName()); if (namespace != null) { - trace.recordReferenceResolution(userType.getReferenceExpression(), namespace); + trace.record(BindingContext.REFERENCE_TARGET, userType.getReferenceExpression(), namespace); } return namespace; } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java index fef2d02116a..3c3b4dea8d2 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java @@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.types.*; import java.util.*; @@ -122,7 +123,7 @@ public class JavaDescriptorResolver { constructorDescriptor.initialize(typeParameters, Collections.emptyList()); constructorDescriptor.setReturnType(classDescriptor.getDefaultType()); classDescriptor.addConstructor(constructorDescriptor); - semanticServices.getTrace().recordDeclarationResolution(psiClass, constructorDescriptor); + semanticServices.getTrace().record(BindingContext.CONSTRUCTOR, psiClass, constructorDescriptor); } } else { @@ -134,11 +135,11 @@ public class JavaDescriptorResolver { constructorDescriptor.initialize(typeParameters, resolveParameterDescriptors(constructorDescriptor, constructor.getParameterList().getParameters())); constructorDescriptor.setReturnType(classDescriptor.getDefaultType()); classDescriptor.addConstructor(constructorDescriptor); - semanticServices.getTrace().recordDeclarationResolution(constructor, constructorDescriptor); + semanticServices.getTrace().record(BindingContext.CONSTRUCTOR, constructor, constructorDescriptor); } } - semanticServices.getTrace().recordDeclarationResolution(psiClass, classDescriptor); + semanticServices.getTrace().record(BindingContext.CLASS, psiClass, classDescriptor); return classDescriptor; } @@ -230,7 +231,7 @@ public class JavaDescriptorResolver { psiPackage.getName() ); namespaceDescriptor.setMemberScope(new JavaPackageScope(psiPackage.getQualifiedName(), namespaceDescriptor, semanticServices)); - semanticServices.getTrace().recordDeclarationResolution(psiPackage, namespaceDescriptor); + semanticServices.getTrace().record(BindingContext.NAMESPACE, psiPackage, namespaceDescriptor); return namespaceDescriptor; } @@ -241,7 +242,7 @@ public class JavaDescriptorResolver { psiClass.getName() ); namespaceDescriptor.setMemberScope(new JavaClassMembersScope(namespaceDescriptor, psiClass, semanticServices, true)); - semanticServices.getTrace().recordDeclarationResolution(psiClass, namespaceDescriptor); + semanticServices.getTrace().record(BindingContext.NAMESPACE, psiClass, namespaceDescriptor); return namespaceDescriptor; } @@ -280,7 +281,7 @@ public class JavaDescriptorResolver { field.getName(), isFinal ? null : type, type); - semanticServices.getTrace().recordDeclarationResolution(field, propertyDescriptor); + semanticServices.getTrace().record(BindingContext.VARIABLE, field, propertyDescriptor); fieldDescriptorCache.put(field, propertyDescriptor); return propertyDescriptor; } @@ -344,7 +345,7 @@ public class JavaDescriptorResolver { semanticServices.getDescriptorResolver().resolveParameterDescriptors(functionDescriptorImpl, parameters), semanticServices.getTypeTransformer().transformToType(returnType) ); - semanticServices.getTrace().recordDeclarationResolution(method, functionDescriptorImpl); + semanticServices.getTrace().record(BindingContext.FUNCTION, method, functionDescriptorImpl); FunctionDescriptor substitutedFunctionDescriptor = functionDescriptorImpl; if (method.getContainingClass() != psiClass) { substitutedFunctionDescriptor = functionDescriptorImpl.substitute(typeSubstitutorForGenericSuperclasses); diff --git a/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java index 39fb5ab35da..da723b2ce6d 100644 --- a/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -144,7 +144,7 @@ public class ErrorUtils { ); } - private static final JetType ERROR_PARAMETER_TYPE = createErrorType(""); + private static final JetType ERROR_PARAMETER_TYPE = createErrorType(""); private static List getValueParameters(FunctionDescriptor functionDescriptor, List argumentTypes) { List result = new ArrayList(); for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) { @@ -152,7 +152,7 @@ public class ErrorUtils { functionDescriptor, i, Collections.emptyList(), - "", + "", ERROR_PARAMETER_TYPE, ERROR_PARAMETER_TYPE, false, diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index efe39889cdc..a03f9500ca3 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -10,7 +10,6 @@ import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; -import org.jetbrains.jet.lang.ErrorHandlerWithRegions; import org.jetbrains.jet.lang.JetSemanticServices; import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider; import org.jetbrains.jet.lang.descriptors.*; @@ -20,13 +19,16 @@ import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver; import org.jetbrains.jet.lang.resolve.constants.ErrorValue; +import org.jetbrains.jet.lang.resolve.constants.StringValue; import org.jetbrains.jet.lang.types.inference.ConstraintSystem; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.resolve.DescriptorRenderer; -import org.jetbrains.jet.lang.resolve.constants.StringValue; +import org.jetbrains.jet.util.WritableSlice; import java.util.*; +import static org.jetbrains.jet.lang.resolve.BindingContext.STATEMENT; + /** * @author abreslav */ @@ -177,11 +179,11 @@ public class JetTypeInferrer { @Nullable public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, boolean preferBlock, @NotNull JetType expectedType) { - return typeInferrerVisitor.getType(expression, new TypeInferenceContext(trace, scope, this, preferBlock, DataFlowInfo.getEmpty(), expectedType, FORBIDDEN)); + return typeInferrerVisitor.getType(expression, new TypeInferenceContext(trace, scope, preferBlock, DataFlowInfo.getEmpty(), expectedType, FORBIDDEN)); } public JetType getTypeWithNamespaces(@NotNull final JetScope scope, @NotNull JetExpression expression, boolean preferBlock) { - return typeInferrerVisitorWithNamespaces.getType(expression, new TypeInferenceContext(trace, scope, this, preferBlock, DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, NO_EXPECTED_TYPE)); + return typeInferrerVisitorWithNamespaces.getType(expression, new TypeInferenceContext(trace, scope, preferBlock, DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, NO_EXPECTED_TYPE)); } @Nullable @@ -322,7 +324,7 @@ public class JetTypeInferrer { private void report(OverloadResolutionResult resolutionResult) { if (resolutionResult.isSuccess() || resolutionResult.singleFunction()) { - trace.recordReferenceResolution(referenceExpression, resolutionResult.getFunctionDescriptor()); + trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, resolutionResult.getFunctionDescriptor()); } if (reportErrors) { switch (resolutionResult.getResultCode()) { @@ -376,7 +378,7 @@ public class JetTypeInferrer { // return; // The function returns Nothing // } // for (Map.Entry entry : typeMap.entrySet()) { - // JetType actualType = entry.getValue(); + // JetType actualType = entry.castValue(); // JetElement element = entry.getKey(); // JetTypeChecker typeChecker = semanticServices.getTypeChecker(); // if (!typeChecker.isSubtypeOf(actualType, expectedReturnType)) { @@ -415,8 +417,8 @@ public class JetTypeInferrer { final boolean blockBody = function.hasBlockBody(); final TypeInferenceContext context = blockBody - ? new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), dataFlowInfo, NO_EXPECTED_TYPE, expectedReturnType) - : new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), dataFlowInfo, expectedReturnType, FORBIDDEN); + ? new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), dataFlowInfo, NO_EXPECTED_TYPE, expectedReturnType) + : new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), dataFlowInfo, expectedReturnType, FORBIDDEN); typeInferrerVisitor.getType(bodyExpression, context); @@ -485,14 +487,14 @@ public class JetTypeInferrer { JetExpression bodyExpression = function.getBodyExpression(); assert bodyExpression != null; JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(outerScope, functionDescriptor, trace); - typeInferrerVisitor.getType(bodyExpression, new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, FORBIDDEN)); + typeInferrerVisitor.getType(bodyExpression, new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, FORBIDDEN)); Collection returnedExpressions = new ArrayList(); Collection elementsReturningUnit = new ArrayList(); flowInformationProvider.collectReturnedInformation(function.asElement(), returnedExpressions, elementsReturningUnit); Map typeMap = new HashMap(); for (JetExpression returnedExpression : returnedExpressions) { - JetType cachedType = trace.getBindingContext().getExpressionType(returnedExpression); - trace.removeStatementRecord(returnedExpression); + JetType cachedType = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, returnedExpression); + trace.record(STATEMENT, returnedExpression, false); if (cachedType != null) { typeMap.put(returnedExpression, cachedType); } @@ -509,16 +511,16 @@ public class JetTypeInferrer { } TypeInferrerVisitorWithWritableScope blockLevelVisitor = newTypeInferrerVisitorWithWritableScope(scope); - TypeInferenceContext newContext = new TypeInferenceContext(trace, scope, this, true, context.dataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType); + TypeInferenceContext newContext = new TypeInferenceContext(trace, scope, true, context.dataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType); JetType result = null; for (Iterator iterator = block.iterator(); iterator.hasNext(); ) { JetElement statement = iterator.next(); - trace.recordStatement(statement); + trace.record(STATEMENT, statement); JetExpression statementExpression = (JetExpression) statement; //TODO constructor assert context.expectedType != FORBIDDEN : "" if (!iterator.hasNext() && context.expectedType != NO_EXPECTED_TYPE) { - newContext = new TypeInferenceContext(trace, scope, this, true, newContext.dataFlowInfo, context.expectedType, context.expectedReturnType); + newContext = new TypeInferenceContext(trace, scope, true, newContext.dataFlowInfo, context.expectedType, context.expectedReturnType); } result = blockLevelVisitor.getType(statementExpression, newContext); @@ -527,7 +529,7 @@ public class JetTypeInferrer { newDataFlowInfo = context.dataFlowInfo; } if (newDataFlowInfo != context.dataFlowInfo) { - newContext = new TypeInferenceContext(trace, scope, this, true, newDataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType); + newContext = new TypeInferenceContext(trace, scope, true, newDataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType); } blockLevelVisitor.resetResult(); // TODO : maybe it's better to recreate the visitors with the same scope? } @@ -784,7 +786,7 @@ public class JetTypeInferrer { if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) { DeclarationDescriptor declarationDescriptor = receiverType.getConstructor().getDeclarationDescriptor(); assert declarationDescriptor != null; - trace.recordReferenceResolution(referenceExpression, declarationDescriptor); + trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, declarationDescriptor); // TODO : more helpful message JetValueArgumentList argumentList = call.getValueArgumentList(); final String errorMessage = "Cannot find a constructor overload for class " + classDescriptor.getName() + " with these arguments"; @@ -851,7 +853,7 @@ public class JetTypeInferrer { if (!semanticServices.getTypeChecker().isSubtypeOf(enrichedType, context.expectedType)) { context.trace.getErrorHandler().typeMismatch(expression, context.expectedType, expressionType); } else { - context.trace.recordAutoCast(expression, context.expectedType); + context.trace.record(BindingContext.AUTOCAST, expression, context.expectedType); } return enrichedType; } @@ -879,7 +881,7 @@ public class JetTypeInferrer { VariableDescriptor variableDescriptor = null; if (receiverExpression instanceof JetSimpleNameExpression) { JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) receiverExpression; - DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().resolveReferenceExpression(nameExpression); + DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, nameExpression); if (declarationDescriptor instanceof VariableDescriptor) { variableDescriptor = (VariableDescriptor) declarationDescriptor; } @@ -907,7 +909,6 @@ public class JetTypeInferrer { private TypeInferenceContext( @NotNull BindingTrace trace, @NotNull JetScope scope, - @NotNull Services services, boolean preferBlock, @NotNull DataFlowInfo dataFlowInfo, @NotNull JetType expectedType, @@ -916,7 +917,7 @@ public class JetTypeInferrer { this.typeResolver = new TypeResolver(semanticServices, trace, true); this.classDescriptorResolver = semanticServices.getClassDescriptorResolver(trace); this.scope = scope; - this.services = services; + this.services = getServices(trace); this.preferBlock = preferBlock; this.dataFlowInfo = dataFlowInfo; this.expectedType = expectedType; @@ -925,19 +926,24 @@ public class JetTypeInferrer { } public TypeInferenceContext replaceDataFlowInfo(DataFlowInfo newDataFlowInfo) { - return new TypeInferenceContext(trace, scope, services, preferBlock, newDataFlowInfo, expectedType, expectedReturnType); + return new TypeInferenceContext(trace, scope, preferBlock, newDataFlowInfo, expectedType, expectedReturnType); } public TypeInferenceContext replaceExpectedType(@Nullable JetType newExpectedType) { if (newExpectedType == null) return replaceExpectedType(NO_EXPECTED_TYPE); if (expectedType == newExpectedType) return this; - return new TypeInferenceContext(trace, scope, services, preferBlock, dataFlowInfo, newExpectedType, expectedReturnType); + return new TypeInferenceContext(trace, scope, preferBlock, dataFlowInfo, newExpectedType, expectedReturnType); } public TypeInferenceContext replaceExpectedReturnType(@Nullable JetType newExpectedReturnType) { if (newExpectedReturnType == null) return replaceExpectedReturnType(NO_EXPECTED_TYPE); if (expectedReturnType == newExpectedReturnType) return this; - return new TypeInferenceContext(trace, scope, services, preferBlock, dataFlowInfo, expectedType, newExpectedReturnType); + return new TypeInferenceContext(trace, scope, preferBlock, dataFlowInfo, expectedType, newExpectedReturnType); + } + + public TypeInferenceContext replaceBindingTrace(@NotNull BindingTrace newTrace) { + if (newTrace == trace) return this; + return new TypeInferenceContext(newTrace, scope, preferBlock, dataFlowInfo, expectedType, expectedReturnType); } } @@ -952,31 +958,31 @@ public class JetTypeInferrer { @Nullable public JetType getType(@NotNull JetScope scope, @NotNull JetExpression expression, boolean preferBlock, TypeInferenceContext context) { - return getType(expression, new TypeInferenceContext(context.trace, scope, context.services, preferBlock, context.dataFlowInfo, context.expectedType, context.expectedReturnType)); + return getType(expression, new TypeInferenceContext(context.trace, scope, preferBlock, context.dataFlowInfo, context.expectedType, context.expectedReturnType)); } private JetType getTypeWithNewDataFlowInfo(JetScope scope, JetExpression expression, boolean preferBlock, @NotNull DataFlowInfo newDataFlowInfo, TypeInferenceContext context) { - return getType(expression, new TypeInferenceContext(context.trace, scope, context.services, preferBlock, newDataFlowInfo, context.expectedType, context.expectedReturnType)); + return getType(expression, new TypeInferenceContext(context.trace, scope, preferBlock, newDataFlowInfo, context.expectedType, context.expectedReturnType)); } @Nullable public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) { - if (context.trace.isProcessed(expression)) { - return context.trace.getBindingContext().getExpressionType(expression); + if (context.trace.get(BindingContext.PROCESSED, expression)) { + return context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression); } JetType result; try { result = expression.visit(this, context); // Some recursive definitions (object expressions) must put their types in the cache manually: - if (context.trace.isProcessed(expression)) { - return context.trace.getBindingContext().getExpressionType(expression); + if ((boolean) context.trace.get(BindingContext.PROCESSED, expression)) { + return context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression); } if (result instanceof DeferredType) { result = ((DeferredType) result).getActualType(); } if (result != null) { - context.trace.recordExpressionType(expression, result); + context.trace.record(BindingContext.EXPRESSION_TYPE, expression, result); if (JetStandardClasses.isNothing(result) && !result.isNullable()) { markDominatedExpressionsAsUnreachable(expression, context); } @@ -987,10 +993,10 @@ public class JetTypeInferrer { result = null; } - if (!context.trace.isProcessed(expression)) { - context.trace.recordResolutionScope(expression, context.scope); + if (!(boolean) context.trace.get(BindingContext.PROCESSED, expression)) { + context.trace.record(BindingContext.RESOLUTION_SCOPE, expression, context.scope); } - context.trace.markAsProcessed(expression); + context.trace.record(BindingContext.PROCESSED, expression); return result; } @@ -1038,7 +1044,7 @@ public class JetTypeInferrer { context.trace.getErrorHandler().unresolvedReference(expression); } else { - context.trace.recordReferenceResolution(expression, property); + context.trace.record(BindingContext.REFERENCE_TARGET, expression, property); return context.services.checkEnrichedType(property.getOutType(), expression, context); } } @@ -1047,7 +1053,7 @@ public class JetTypeInferrer { if (referencedName != null) { VariableDescriptor variable = context.scope.getVariable(referencedName); if (variable != null) { - context.trace.recordReferenceResolution(expression, variable); + context.trace.record(BindingContext.REFERENCE_TARGET, expression, variable); JetType result = variable.getOutType(); if (result == null) { context.trace.getErrorHandler().genericError(expression.getNode(), "This variable is not readable in this context"); @@ -1065,7 +1071,7 @@ public class JetTypeInferrer { else { context.trace.getErrorHandler().genericError(expression.getNode(), "Classifier " + classifier.getName() + " does not have a class object"); } - context.trace.recordReferenceResolution(expression, classifier); + context.trace.record(BindingContext.REFERENCE_TARGET, expression, classifier); return context.services.checkEnrichedType(result, expression, context); } else { @@ -1101,16 +1107,17 @@ public class JetTypeInferrer { if (namespace == null) { return null; } - context.trace.recordReferenceResolution(expression, namespace); + context.trace.record(BindingContext.REFERENCE_TARGET, expression, namespace); return namespace.getNamespaceType(); } @Override public JetType visitObjectLiteralExpression(final JetObjectLiteralExpression expression, final TypeInferenceContext context) { final JetType[] result = new JetType[1]; - TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, new BindingTraceAdapter(context.trace) { + BindingTraceAdapter.RecordHandler handler = new BindingTraceAdapter.RecordHandler() { + @Override - public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull final DeclarationDescriptor descriptor) { + public void handleRecord(WritableSlice slice, PsiElement declaration, final DeclarationDescriptor descriptor) { if (declaration == expression.getObjectDeclaration()) { JetType defaultType = new DeferredType(new LazyValue() { @Override @@ -1119,14 +1126,19 @@ public class JetTypeInferrer { } }); result[0] = defaultType; - if (!context.trace.isProcessed(expression)) { - recordExpressionType(expression, defaultType); - markAsProcessed(expression); + if (!context.trace.get(BindingContext.PROCESSED, expression)) { + context.trace.record(BindingContext.EXPRESSION_TYPE, expression, defaultType); + context.trace.record(BindingContext.PROCESSED, expression); } } - super.recordDeclarationResolution(declaration, descriptor); } - }); + }; + BindingTraceAdapter traceAdapter = new BindingTraceAdapter(context.trace); + for (WritableSlice slice : BindingContext.DECLARATIONS_TO_DESCRIPTORS) { + //noinspection unchecked + traceAdapter.addHandler(slice, handler); + } + TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, traceAdapter); topDownAnalyzer.processObject(context.scope, context.scope.getContainingDeclaration(), expression.getObjectDeclaration()); return context.services.checkType(result[0], expression, context); } @@ -1135,7 +1147,7 @@ public class JetTypeInferrer { public JetType visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, TypeInferenceContext context) { JetFunctionLiteral functionLiteral = expression.getFunctionLiteral(); if (context.preferBlock && !functionLiteral.hasParameterSpecification()) { - context.trace.recordBlock(expression); + context.trace.record(BindingContext.BLOCK, expression); return context.services.checkType(getBlockReturnedType(context.scope, functionLiteral.getBodyExpression(), context), expression, context); } @@ -1172,7 +1184,7 @@ public class JetTypeInferrer { JetType effectiveReceiverType = receiverTypeRef == null ? null : receiverType; functionDescriptor.initialize(effectiveReceiverType, Collections.emptyList(), valueParameterDescriptors, null); - context.trace.recordDeclarationResolution(expression, functionDescriptor); + context.trace.record(BindingContext.FUNCTION, expression, functionDescriptor); JetType returnType = NO_EXPECTED_TYPE; JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace); @@ -1235,7 +1247,7 @@ public class JetTypeInferrer { return null; } else { - context.trace.recordCompileTimeValue(expression, value); + context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, value); return context.services.checkType(value.getType(standardLibrary), expression, context); } } @@ -1369,22 +1381,22 @@ public class JetTypeInferrer { else { throw new UnsupportedOperationException(); // TODO } - context.trace.recordReferenceResolution(targetLabel, declarationDescriptor); - context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptor); + context.trace.record(BindingContext.REFERENCE_TARGET, targetLabel, declarationDescriptor); + context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptor); } else if (size == 0) { // This uses the info written by the control flow processor - PsiElement psiElement = context.trace.getBindingContext().resolveToDeclarationPsiElement(targetLabel); + PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(context.trace.getBindingContext(), targetLabel); if (psiElement instanceof JetFunctionLiteralExpression) { - DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().getDeclarationDescriptor(psiElement); + DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement); if (declarationDescriptor instanceof FunctionDescriptor) { thisType = ((FunctionDescriptor) declarationDescriptor).getReceiverType(); if (thisType == null) { thisType = JetStandardClasses.getNothingType(); } else { - context.trace.recordReferenceResolution(targetLabel, declarationDescriptor); - context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptor); + context.trace.record(BindingContext.REFERENCE_TARGET, targetLabel, declarationDescriptor); + context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptor); } } else { @@ -1404,7 +1416,7 @@ public class JetTypeInferrer { DeclarationDescriptor declarationDescriptorForUnqualifiedThis = context.scope.getDeclarationDescriptorForUnqualifiedThis(); if (declarationDescriptorForUnqualifiedThis != null) { - context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptorForUnqualifiedThis); + context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptorForUnqualifiedThis); } } @@ -1441,7 +1453,7 @@ public class JetTypeInferrer { result = thisType; } if (result != null) { - context.trace.recordExpressionType(expression.getThisReference(), result); + context.trace.record(BindingContext.EXPRESSION_TYPE, expression.getThisReference(), result); } } } @@ -1828,7 +1840,7 @@ public class JetTypeInferrer { // TODO : validate that DF makes sense for this variable: local, val, internal w/backing field, etc // Comparison to a non-null expression - JetType rhsType = context.trace.getBindingContext().getExpressionType(right); + JetType rhsType = context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, right); if (rhsType != null && !rhsType.isNullable()) { extendDataFlowWithNullComparison(operationToken, variableDescriptor, !conditionValue); return; @@ -1836,7 +1848,7 @@ public class JetTypeInferrer { VariableDescriptor rightVariable = context.services.getVariableDescriptorFromSimpleName(right, context); if (rightVariable != null) { - JetType lhsType = context.trace.getBindingContext().getExpressionType(left); + JetType lhsType = context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, left); if (lhsType != null && !lhsType.isNullable()) { extendDataFlowWithNullComparison(operationToken, rightVariable, !conditionValue); return; @@ -1929,7 +1941,7 @@ public class JetTypeInferrer { WritableScope writableScope = newWritableScopeImpl(context.scope, context.trace).setDebugName("do..while body scope"); conditionScope = writableScope; context.services.getBlockReturnedTypeWithWritableScope(writableScope, function.getFunctionLiteral().getBodyExpression().getStatements(), context); - context.trace.recordBlock(function); + context.trace.record(BindingContext.BLOCK, function); } else { getType(context.scope, body, true, context); } @@ -2159,11 +2171,15 @@ public class JetTypeInferrer { // TODO : functions as values JetExpression selectorExpression = expression.getSelectorExpression(); JetExpression receiverExpression = expression.getReceiverExpression(); - JetType receiverType = context.services.typeInferrerVisitorWithNamespaces.getType(receiverExpression, new TypeInferenceContext(context.trace, context.scope, context.services, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE)); + JetType receiverType = context.services.typeInferrerVisitorWithNamespaces.getType(receiverExpression, new TypeInferenceContext(context.trace, context.scope, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE)); if (receiverType == null) return null; - ErrorHandlerWithRegions errorHandler = context.trace.getErrorHandler(); - errorHandler.openRegion(); - JetType selectorReturnType = getSelectorReturnType(receiverType, selectorExpression, context); + + // Clean resolution: no autocasts + TemporaryBindingTrace cleanResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext()); + TypeInferenceContext cleanResolutionContext = context.replaceBindingTrace(cleanResolutionTrace); +// ErrorHandler errorHandler = context.trace.getErrorHandler(); +// errorHandler.openRegion(); + JetType selectorReturnType = getSelectorReturnType(receiverType, selectorExpression, cleanResolutionContext); //TODO move further if (expression.getOperationSign() == JetTokens.SAFE_ACCESS) { @@ -2172,37 +2188,41 @@ public class JetTypeInferrer { } } if (selectorReturnType != null) { - errorHandler.closeAndCommitCurrentRegion(); + cleanResolutionTrace.addAllMyDataTo(context.trace); } else { - ErrorHandlerWithRegions.DiagnosticsRegion regionToCommit = errorHandler.closeAndReturnCurrentRegion(); - - VariableDescriptor variableDescriptor = context.services.getVariableDescriptorFromSimpleName(receiverExpression, context); + VariableDescriptor variableDescriptor = cleanResolutionContext.services.getVariableDescriptorFromSimpleName(receiverExpression, context); + boolean somethingFound = false; if (variableDescriptor != null) { List possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor)); Collections.reverse(possibleTypes); + + TemporaryBindingTrace autocastResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext()); + TypeInferenceContext autocastResolutionContext = context.replaceBindingTrace(autocastResolutionTrace); for (JetType possibleType : possibleTypes) { - errorHandler.openRegion(); - selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, context); + selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, autocastResolutionContext); if (selectorReturnType != null) { - regionToCommit = errorHandler.closeAndReturnCurrentRegion(); - context.trace.recordAutoCast(receiverExpression, possibleType); + autocastResolutionTrace.record(BindingContext.AUTOCAST, receiverExpression, possibleType); + autocastResolutionTrace.addAllMyDataTo(context.trace); + somethingFound = true; break; } else { - errorHandler.closeAndReturnCurrentRegion(); + autocastResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext()); + autocastResolutionContext = context.replaceBindingTrace(autocastResolutionTrace); } } } - - regionToCommit.commit(); + if (!somethingFound) { + cleanResolutionTrace.addAllMyDataTo(context.trace); + } } JetType result; if (expression.getOperationSign() == JetTokens.QUEST) { if (selectorReturnType != null && !isBoolean(selectorReturnType) && selectorExpression != null) { // TODO : more comprehensible error message - errorHandler.typeMismatch(selectorExpression, semanticServices.getStandardLibrary().getBooleanType(), selectorReturnType); + context.trace.getErrorHandler().typeMismatch(selectorExpression, semanticServices.getStandardLibrary().getBooleanType(), selectorReturnType); } result = TypeUtils.makeNullable(receiverType); } @@ -2210,7 +2230,7 @@ public class JetTypeInferrer { result = selectorReturnType; } if (selectorExpression != null && result != null) { - context.trace.recordExpressionType(selectorExpression, result); + context.trace.record(BindingContext.EXPRESSION_TYPE, selectorExpression, result); } if (selectorReturnType != null) { // TODO : extensions to 'Any?' @@ -2238,7 +2258,7 @@ public class JetTypeInferrer { @Override public void visitReferenceExpression(JetReferenceExpression referenceExpression) { - DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().resolveReferenceExpression(referenceExpression); + DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, referenceExpression); if (declarationDescriptor instanceof FunctionDescriptor) { result[0] = (FunctionDescriptor) declarationDescriptor; } @@ -2344,7 +2364,7 @@ public class JetTypeInferrer { context.trace.getErrorHandler().genericError(operationSign.getNode(), name + " must return " + receiverType + " but returns " + returnType); } else { - context.trace.recordVariableReassignment(expression); + context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression); } // TODO : Maybe returnType? result = receiverType; @@ -2524,7 +2544,7 @@ public class JetTypeInferrer { @Nullable protected List getTypes(JetScope scope, List indexExpressions, TypeInferenceContext context) { List argumentTypes = new ArrayList(); - TypeInferenceContext newContext = new TypeInferenceContext(context.trace, scope, context.services, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE); + TypeInferenceContext newContext = new TypeInferenceContext(context.trace, scope, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE); for (JetExpression indexExpression : indexExpressions) { JetType type = context.services.typeInferrerVisitor.getType(indexExpression, newContext); if (type == null) { @@ -2655,7 +2675,7 @@ public class JetTypeInferrer { }); } if (value[0] != CompileTimeConstantResolver.OUT_OF_RANGE) { - context.trace.recordCompileTimeValue(expression, new StringValue(builder.toString())); + context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new StringValue(builder.toString())); } return context.services.checkType(semanticServices.getStandardLibrary().getStringType(), expression, contextWithExpectedType); } @@ -2703,7 +2723,7 @@ public class JetTypeInferrer { public JetType visitObjectDeclaration(JetObjectDeclaration declaration, TypeInferenceContext context) { TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, context.trace); topDownAnalyzer.processObject(scope, scope.getContainingDeclaration(), declaration); - ClassDescriptor classDescriptor = context.trace.getBindingContext().getClassDescriptor(declaration); + ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, declaration); if (classDescriptor != null) { PropertyDescriptor propertyDescriptor = context.classDescriptorResolver.resolveObjectDeclarationAsPropertyDescriptor(scope.getContainingDeclaration(), declaration, classDescriptor); scope.addVariableDescriptor(propertyDescriptor); @@ -2777,7 +2797,7 @@ public class JetTypeInferrer { String counterpartName = binaryOperationNames.get(assignmentOperationCounterparts.get(operationType)); JetType typeForBinaryCall = getTypeForBinaryCall(expression, counterpartName, scope, true, context); if (typeForBinaryCall != null) { - context.trace.recordVariableReassignment(expression); + context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression); } } return null; diff --git a/idea/src/org/jetbrains/jet/plugin/JetQuickDocumentationProvider.java b/idea/src/org/jetbrains/jet/plugin/JetQuickDocumentationProvider.java index fd521a5399b..2b1cc65b9bf 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetQuickDocumentationProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/JetQuickDocumentationProvider.java @@ -8,6 +8,7 @@ import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.resolve.DescriptorRenderer; /** @@ -26,13 +27,13 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider } if (ref != null) { BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache((JetFile) element.getContainingFile()); - DeclarationDescriptor declarationDescriptor = bindingContext.resolveReferenceExpression(ref); + DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ref); if (declarationDescriptor != null) { return render(declarationDescriptor); } - PsiElement psiElement = bindingContext.resolveToDeclarationPsiElement(ref); + PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, ref); if (psiElement != null) { - declarationDescriptor = bindingContext.getDeclarationDescriptor(psiElement); + declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement); if (declarationDescriptor != null) { return render(declarationDescriptor); } diff --git a/idea/src/org/jetbrains/jet/plugin/actions/ShowExpressionTypeAction.java b/idea/src/org/jetbrains/jet/plugin/actions/ShowExpressionTypeAction.java index 8c452841f10..7b13fb6aebd 100644 --- a/idea/src/org/jetbrains/jet/plugin/actions/ShowExpressionTypeAction.java +++ b/idea/src/org/jetbrains/jet/plugin/actions/ShowExpressionTypeAction.java @@ -36,7 +36,7 @@ public class ShowExpressionTypeAction extends AnAction { else { int offset = editor.getCaretModel().getOffset(); expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(offset), JetExpression.class); - while (expression != null && bindingContext.getExpressionType(expression) == null) { + while (expression != null && bindingContext.get(BindingContext.EXPRESSION_TYPE, expression) == null) { expression = PsiTreeUtil.getParentOfType(expression, JetExpression.class); } if (expression != null) { @@ -45,7 +45,7 @@ public class ShowExpressionTypeAction extends AnAction { } } if (expression != null) { - JetType type = bindingContext.getExpressionType(expression); + JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression); if (type != null) { HintManager.getInstance().showInformationHint(editor, type.toString()); } diff --git a/idea/src/org/jetbrains/jet/plugin/annotations/JetLineMarkerProvider.java b/idea/src/org/jetbrains/jet/plugin/annotations/JetLineMarkerProvider.java index 28c1dc6d058..aafe04c8cdb 100644 --- a/idea/src/org/jetbrains/jet/plugin/annotations/JetLineMarkerProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/annotations/JetLineMarkerProvider.java @@ -16,10 +16,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilBase; import com.intellij.ui.awt.RelativePoint; -import com.intellij.util.Function; -import com.intellij.util.Icons; -import com.intellij.util.PsiIconUtil; -import com.intellij.util.PsiNavigateUtil; +import com.intellij.util.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; @@ -49,14 +46,14 @@ public class JetLineMarkerProvider implements LineMarkerProvider { if (element instanceof JetClass) { JetClass jetClass = (JetClass) element; - ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetClass); + ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetClass); String text = classDescriptor == null ? "Unresolved" : DescriptorRenderer.HTML.render(classDescriptor); return createLineMarkerInfo(jetClass, text); } if (element instanceof JetProperty) { JetProperty jetProperty = (JetProperty) element; - final VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor(jetProperty); + final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, jetProperty); if (variableDescriptor instanceof PropertyDescriptor) { return createLineMarkerInfo(element, DescriptorRenderer.HTML.render(variableDescriptor)); } @@ -65,10 +62,10 @@ public class JetLineMarkerProvider implements LineMarkerProvider { if (element instanceof JetNamedFunction) { JetNamedFunction jetFunction = (JetNamedFunction) element; - final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(jetFunction); + final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, jetFunction); if (functionDescriptor == null) return null; final Set overriddenFunctions = functionDescriptor.getOverriddenFunctions(); - Icon icon = isMember(functionDescriptor) ? (overriddenFunctions.isEmpty() ? Icons.METHOD_ICON : OVERRIDING_FUNCTION) : Icons.FUNCTION_ICON; + Icon icon = isMember(functionDescriptor) ? (overriddenFunctions.isEmpty() ? PlatformIcons.METHOD_ICON : OVERRIDING_FUNCTION) : PlatformIcons.FUNCTION_ICON; return new LineMarkerInfo( jetFunction, jetFunction.getTextOffset(), icon, Pass.UPDATE_ALL, new Function() { @@ -97,7 +94,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider { if (overriddenFunctions.isEmpty()) return; final List list = Lists.newArrayList(); for (FunctionDescriptor overriddenFunction : overriddenFunctions) { - PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(overriddenFunction); + PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, overriddenFunction); list.add(declarationPsiElement); } if (list.isEmpty()) { @@ -118,7 +115,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider { public String getElementText(PsiElement element) { if (element instanceof JetNamedFunction) { JetNamedFunction function = (JetNamedFunction) element; - return DescriptorRenderer.HTML.render(bindingContext.getFunctionDescriptor(function)); + return DescriptorRenderer.HTML.render(bindingContext.get(BindingContext.FUNCTION, function)); } return super.getElementText(element); } @@ -134,18 +131,18 @@ public class JetLineMarkerProvider implements LineMarkerProvider { if (element instanceof JetNamespace) { return createLineMarkerInfo((JetNamespace) element, - DescriptorRenderer.HTML.render(bindingContext.getNamespaceDescriptor((JetNamespace) element))); + DescriptorRenderer.HTML.render(bindingContext.get(BindingContext.NAMESPACE, element))); } if (element instanceof JetObjectDeclaration && !(element.getParent() instanceof JetExpression)) { JetObjectDeclaration jetObjectDeclaration = (JetObjectDeclaration) element; return new LineMarkerInfo( - jetObjectDeclaration, jetObjectDeclaration.getTextOffset(), Icons.ANONYMOUS_CLASS_ICON, Pass.UPDATE_ALL, + jetObjectDeclaration, jetObjectDeclaration.getTextOffset(), PlatformIcons.ANONYMOUS_CLASS_ICON, Pass.UPDATE_ALL, new Function() { @Override public String fun(JetObjectDeclaration jetObjectDeclaration) { - ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetObjectDeclaration); + ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetObjectDeclaration); if (classDescriptor != null) { return DescriptorRenderer.HTML.renderAsObject(classDescriptor); } diff --git a/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java b/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java index c0032711bfa..c8d61556144 100644 --- a/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java +++ b/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java @@ -75,7 +75,7 @@ public class JetPsiChecker implements Annotator { private void markRedeclaration(DeclarationDescriptor redeclaration) { if (!redeclarations.add(redeclaration)) return; - PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(redeclaration); + PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, redeclaration); if (declarationPsiElement instanceof JetNamedDeclaration) { PsiElement nameIdentifier = ((JetNamedDeclaration) declarationPsiElement).getNameIdentifier(); assert nameIdentifier != null : declarationPsiElement.getText() + " has nameIdentifier 'null'"; @@ -106,7 +106,7 @@ public class JetPsiChecker implements Annotator { file.acceptChildren(new JetVisitorVoid() { @Override public void visitExpression(JetExpression expression) { - JetType autoCast = bindingContext.getAutoCastType(expression); + JetType autoCast = bindingContext.get(BindingContext.AUTOCAST, expression); if (autoCast != null) { holder.createInfoAnnotation(expression, "Automatically cast to " + autoCast).setTextAttributes(JetHighlighter.JET_AUTO_CAST_EXPRESSION); } @@ -135,9 +135,9 @@ public class JetPsiChecker implements Annotator { file.acceptChildren(new JetVisitorVoid() { @Override public void visitProperty(JetProperty property) { - VariableDescriptor propertyDescriptor = bindingContext.getVariableDescriptor(property); + VariableDescriptor propertyDescriptor = bindingContext.get(BindingContext.VARIABLE, property); if (propertyDescriptor instanceof PropertyDescriptor) { - if (bindingContext.hasBackingField((PropertyDescriptor) propertyDescriptor)) { + if ((boolean) bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) propertyDescriptor)) { putBackingfieldAnnotation(holder, property); } } @@ -145,8 +145,8 @@ public class JetPsiChecker implements Annotator { @Override public void visitParameter(JetParameter parameter) { - PropertyDescriptor propertyDescriptor = bindingContext.getPropertyDescriptor(parameter); - if (propertyDescriptor != null && bindingContext.hasBackingField(propertyDescriptor)) { + PropertyDescriptor propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter); + if (propertyDescriptor != null && bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) { putBackingfieldAnnotation(holder, parameter); } } diff --git a/idea/src/org/jetbrains/jet/util/BasicWritableSlice.java b/idea/src/org/jetbrains/jet/util/BasicWritableSlice.java new file mode 100644 index 00000000000..1b2da3c773c --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/BasicWritableSlice.java @@ -0,0 +1,50 @@ +package org.jetbrains.jet.util; + +/** +* @author abreslav +*/ +public class BasicWritableSlice implements WritableSlice { + + private final String debugName; + private final RewritePolicy rewritePolicy; + + public BasicWritableSlice(String debugName, RewritePolicy rewritePolicy) { + this.debugName = debugName; + this.rewritePolicy = rewritePolicy; + } + + @Override + public ManyMapKey makeKey(K key) { + return new ManyMapKey(this, key); + } + + // True to put, false to skip + @Override + public boolean check(K key, V value) { + assert key != null; + assert value != null; + return true; + } + + @Override + public void afterPut(MutableManyMap manyMap, K key, V value) { + // Do nothing + } + + @Override + public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) { + if (valueNotFound) assert value == null; + return value; + } + + + @Override + public RewritePolicy getRewritePolicy() { + return rewritePolicy; + } + + @Override + public String toString() { + return debugName; + } +} diff --git a/idea/src/org/jetbrains/jet/util/ManyMap.java b/idea/src/org/jetbrains/jet/util/ManyMap.java new file mode 100644 index 00000000000..e401c74d923 --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/ManyMap.java @@ -0,0 +1,14 @@ +package org.jetbrains.jet.util; + +import java.util.Map; + +/** + * @author abreslav + */ +public interface ManyMap extends Iterable, ?>> { + V get(ReadOnlySlice slice, K key); + + boolean containsKey(ReadOnlySlice slice, K key); + + +} diff --git a/idea/src/org/jetbrains/jet/util/ManyMapImpl.java b/idea/src/org/jetbrains/jet/util/ManyMapImpl.java new file mode 100644 index 00000000000..f4df65f2384 --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/ManyMapImpl.java @@ -0,0 +1,73 @@ +package org.jetbrains.jet.util; + +import com.google.common.collect.Maps; + +import java.util.Iterator; +import java.util.Map; + +/** +* @author abreslav +*/ +public class ManyMapImpl implements MutableManyMap { + + public static ManyMapImpl create() { + return new ManyMapImpl(Maps., Object>newLinkedHashMap()); + } + + public static ManyMapImpl create(Map, Object> map) { + return new ManyMapImpl(map); + } + + public static ManyMapImpl create(MapSupplier mapSupplier) { + return new ManyMapImpl(mapSupplier., Object>get()); + } + + private final Map, Object> map; + + private ManyMapImpl(Map, Object> map) { + this.map = map; + } + + @Override + public void put(WritableSlice slice, K key, V value) { + if (!slice.check(key, value)) { + return; + } + ManyMapKey manyMapKey = slice.makeKey(key); + if (slice.getRewritePolicy().rewriteProcessingNeeded(key)) { + if (map.containsKey(manyMapKey)) { + //noinspection unchecked + if (!slice.getRewritePolicy().processRewrite(slice, key, (V) map.get(manyMapKey), value)) { + return; + } + } + } + map.put(manyMapKey, value); + slice.afterPut(this, key, value); + } + + @Override + public V get(ReadOnlySlice slice, K key) { + ManyMapKey manyMapKey = slice.makeKey(key); + //noinspection unchecked + V value = (V) map.get(manyMapKey); + return slice.computeValue(this, key, value, value == null && !map.containsKey(manyMapKey)); + } + + @Override + public boolean containsKey(ReadOnlySlice slice, K key) { + return map.containsKey(slice.makeKey(key)); + } + + @Override + public V remove(RemovableSlice slice, K key) { + //noinspection unchecked + return (V) map.remove(slice.makeKey(key)); + } + + @Override + public Iterator, ?>> iterator() { + //noinspection unchecked + return (Iterator) map.entrySet().iterator(); + } +} diff --git a/idea/src/org/jetbrains/jet/util/ManyMapKey.java b/idea/src/org/jetbrains/jet/util/ManyMapKey.java new file mode 100644 index 00000000000..7f93575413a --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/ManyMapKey.java @@ -0,0 +1,45 @@ +package org.jetbrains.jet.util; + +import org.jetbrains.annotations.NotNull; + +/** +* @author abreslav +*/ +public final class ManyMapKey { + + private final WritableSlice slice; + private final K key; + + public ManyMapKey(@NotNull WritableSlice slice, K key) { + this.slice = slice; + this.key = key; + } + + public WritableSlice getSlice() { + return slice; + } + + public K getKey() { + return key; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ManyMapKey that = (ManyMapKey) o; + + if (key != null ? !key.equals(that.key) : that.key != null) return false; + if (!slice.equals(that.slice)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = slice.hashCode(); + result = 31 * result + (key != null ? key.hashCode() : 0); + return result; + } +} diff --git a/idea/src/org/jetbrains/jet/util/ManyMapSlices.java b/idea/src/org/jetbrains/jet/util/ManyMapSlices.java new file mode 100644 index 00000000000..192bec9224a --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/ManyMapSlices.java @@ -0,0 +1,175 @@ +package org.jetbrains.jet.util; + +import java.util.Arrays; +import java.util.List; + +/** + * @author abreslav + */ +public class ManyMapSlices { + + public static final RewritePolicy ONLY_REWRITE_TO_EQUAL = new RewritePolicy() { + @Override + public boolean rewriteProcessingNeeded(K key) { + return true; + } + + @Override + public boolean processRewrite(WritableSlice slice, K key, V oldValue, V newValue) { + assert (oldValue == null && newValue == null) || (oldValue != null && oldValue.equals(newValue)) + : "Rewrite at slice " + slice + " key: " + key + " old value: " + oldValue + " new value: " + newValue; + return true; + } + }; + + public interface KeyNormalizer { + + KeyNormalizer DO_NOTHING = new KeyNormalizer() { + @Override + public Object normalize(Object key) { + return key; + } + }; + K normalize(K key); + + } + + public static SliceBuilder sliceBuilder(String debugName) { + return new SliceBuilder(debugName, ONLY_REWRITE_TO_EQUAL); + } + + public static WritableSlice createSimpleSlice(String debugName) { + return new BasicWritableSlice(debugName, ONLY_REWRITE_TO_EQUAL); + } + + public static WritableSlice createSimpleSetSlice(String debugName) { + return createRemovableSetSlice(debugName); + } + public static RemovableSlice createRemovableSetSlice(String debugName) { + return new SetSlice(debugName, RewritePolicy.DO_NOTHING); + } + + public static class SliceBuilder { + private V defaultValue = null; + private List> furtherLookupSlices = null; + private WritableSlice opposite = null; + private KeyNormalizer keyNormalizer = null; + + private RewritePolicy rewritePolicy; + + private String debugName; + + private SliceBuilder(String debugName, RewritePolicy rewritePolicy) { + this.rewritePolicy = rewritePolicy; + this.debugName = debugName; + } + + public SliceBuilder setDefaultValue(V defaultValue) { + this.defaultValue = defaultValue; + return this; + } + + public SliceBuilder setFurtherLookupSlices(ReadOnlySlice... furtherLookupSlices) { + this.furtherLookupSlices = Arrays.asList(furtherLookupSlices); + return this; + } + + public SliceBuilder setOpposite(WritableSlice opposite) { + this.opposite = opposite; + return this; + } + + public SliceBuilder setKeyNormalizer(KeyNormalizer keyNormalizer) { + this.keyNormalizer = keyNormalizer; + return this; + } + + public RemovableSlice build() { + if (defaultValue != null) { + return new SliceWithOpposite(debugName, rewritePolicy, opposite, keyNormalizer) { + @Override + public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) { + if (valueNotFound) return defaultValue; + return super.computeValue(map, key, value, valueNotFound); + } + }; + } + if (furtherLookupSlices != null) { + return new SliceWithOpposite(debugName, rewritePolicy, opposite, keyNormalizer) { + @Override + public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) { + if (valueNotFound) { + for (ReadOnlySlice slice : furtherLookupSlices) { + if (map.containsKey(slice, key)) { + return map.get(slice, key); + } + } + return defaultValue; + } + return super.computeValue(map, key, value, valueNotFound); + } + }; + } + return new SliceWithOpposite(debugName, rewritePolicy, opposite, keyNormalizer); + } + + } + + public static class BasicRemovableSlice extends BasicWritableSlice implements RemovableSlice { + protected BasicRemovableSlice(String debugName, RewritePolicy rewritePolicy) { + super(debugName, rewritePolicy); + } + + } + + public static class SliceWithOpposite extends BasicRemovableSlice { + private final WritableSlice opposite; + + + private final KeyNormalizer keyNormalizer; + + public SliceWithOpposite(String debugName, RewritePolicy rewritePolicy) { + this(debugName, rewritePolicy, KeyNormalizer.DO_NOTHING); + } + + public SliceWithOpposite(String debugName, RewritePolicy rewritePolicy, KeyNormalizer keyNormalizer) { + this(debugName, rewritePolicy, null, keyNormalizer); + } + + public SliceWithOpposite(String debugName, RewritePolicy rewritePolicy, WritableSlice opposite, KeyNormalizer keyNormalizer) { + super(debugName, rewritePolicy); + this.opposite = opposite; + this.keyNormalizer = keyNormalizer; + } + + @Override + public void afterPut(MutableManyMap manyMap, K key, V value) { + if (opposite != null) { + manyMap.put(opposite, value, key); + } + } + @Override + public ManyMapKey makeKey(K key) { + if (keyNormalizer == null) { + return super.makeKey(key); + } + return super.makeKey(keyNormalizer.normalize(key)); + } + + } + + public static class SetSlice extends BasicRemovableSlice { + + + protected SetSlice(String debugName, RewritePolicy rewritePolicy) { + super(debugName, rewritePolicy); + } + @Override + public Boolean computeValue(ManyMap map, K key, Boolean value, boolean valueNotFound) { + if (valueNotFound) return false; + return super.computeValue(map, key, value, valueNotFound); + } + + } + +} diff --git a/idea/src/org/jetbrains/jet/util/MapSupplier.java b/idea/src/org/jetbrains/jet/util/MapSupplier.java new file mode 100644 index 00000000000..50b2a6c6483 --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/MapSupplier.java @@ -0,0 +1,27 @@ +package org.jetbrains.jet.util; + +import com.google.common.collect.Maps; + +import java.util.Map; + +/** +* @author abreslav +*/ +public interface MapSupplier { + + MapSupplier HASH_MAP_SUPPLIER = new MapSupplier() { + @Override + public Map get() { + return Maps.newHashMap(); + } + }; + + MapSupplier LINKED_HASH_MAP_SUPPLIER = new MapSupplier() { + @Override + public Map get() { + return Maps.newLinkedHashMap(); + } + }; + + Map get(); +} diff --git a/idea/src/org/jetbrains/jet/util/MutableManyMap.java b/idea/src/org/jetbrains/jet/util/MutableManyMap.java new file mode 100644 index 00000000000..8b9052e820e --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/MutableManyMap.java @@ -0,0 +1,11 @@ +package org.jetbrains.jet.util; + +/** + * @author abreslav + */ +public interface MutableManyMap extends ManyMap { + + void put(WritableSlice slice, K key, V value); + + V remove(RemovableSlice slice, K key); +} diff --git a/idea/src/org/jetbrains/jet/util/ReadOnlySlice.java b/idea/src/org/jetbrains/jet/util/ReadOnlySlice.java new file mode 100644 index 00000000000..55ea30e59fb --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/ReadOnlySlice.java @@ -0,0 +1,11 @@ +package org.jetbrains.jet.util; + +/** + * @author abreslav + */ +public interface ReadOnlySlice { + ManyMapKey makeKey(K key); + + V computeValue(ManyMap map, K key, V value, boolean valueNotFound); + +} diff --git a/idea/src/org/jetbrains/jet/util/RemovableSlice.java b/idea/src/org/jetbrains/jet/util/RemovableSlice.java new file mode 100644 index 00000000000..2dc1b3cfba4 --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/RemovableSlice.java @@ -0,0 +1,8 @@ +package org.jetbrains.jet.util; + +/** + * @author abreslav + */ +public interface RemovableSlice extends WritableSlice { + +} diff --git a/idea/src/org/jetbrains/jet/util/RewritePolicy.java b/idea/src/org/jetbrains/jet/util/RewritePolicy.java new file mode 100644 index 00000000000..3a5ffca57a3 --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/RewritePolicy.java @@ -0,0 +1,24 @@ +package org.jetbrains.jet.util; + +/** + * @author abreslav + */ +public interface RewritePolicy { + + RewritePolicy DO_NOTHING = new RewritePolicy() { + @Override + public boolean rewriteProcessingNeeded(K key) { + return false; + } + + @Override + public boolean processRewrite(WritableSlice slice, K key, V oldValue, V newValue) { + throw new UnsupportedOperationException(); + } + }; + + boolean rewriteProcessingNeeded(K key); + + // True to put, false to skip + boolean processRewrite(WritableSlice slice, K key, V oldValue, V newValue); +} diff --git a/idea/src/org/jetbrains/jet/util/WritableSlice.java b/idea/src/org/jetbrains/jet/util/WritableSlice.java new file mode 100644 index 00000000000..0551e8a662f --- /dev/null +++ b/idea/src/org/jetbrains/jet/util/WritableSlice.java @@ -0,0 +1,13 @@ +package org.jetbrains.jet.util; + +/** + * @author abreslav + */ +public interface WritableSlice extends ReadOnlySlice { + // True to put, false to skip + boolean check(K key, V value); + + void afterPut(MutableManyMap manyMap, K key, V value); + + RewritePolicy getRewritePolicy(); +} diff --git a/idea/testData/psi/AnnotatedExpressions.txt b/idea/testData/psi/AnnotatedExpressions.txt index 51d957f298f..ff61f69c15d 100644 --- a/idea/testData/psi/AnnotatedExpressions.txt +++ b/idea/testData/psi/AnnotatedExpressions.txt @@ -15,10 +15,11 @@ JetFile: AnnotatedExpressions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') REFERENCE_EXPRESSION @@ -31,10 +32,11 @@ JetFile: AnnotatedExpressions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') THIS_EXPRESSION diff --git a/idea/testData/psi/Attributes.txt b/idea/testData/psi/Attributes.txt index 2080a928b8c..55913b333cc 100644 --- a/idea/testData/psi/Attributes.txt +++ b/idea/testData/psi/Attributes.txt @@ -38,25 +38,26 @@ JetFile: Attributes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('B') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -70,68 +71,71 @@ JetFile: Attributes.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('ina') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ina') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE USER_TYPE USER_TYPE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + PsiElement(IDENTIFIER)('goo') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('goo') + PsiElement(IDENTIFIER)('doo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiElement(GT)('>') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('doo') + PsiElement(IDENTIFIER)('foo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') TYPE_PROJECTION TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') + PsiElement(IDENTIFIER)('bar') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('goo') PsiElement(GT)('>') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('goo') - PsiElement(GT)('>') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('df') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('df') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') PsiElement(in)('in') @@ -139,10 +143,11 @@ JetFile: Attributes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsdf') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsdf') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') PsiElement(out)('out') @@ -163,10 +168,11 @@ JetFile: Attributes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsdf') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsdf') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -180,19 +186,21 @@ JetFile: Attributes.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsdf') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsdf') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -209,19 +217,21 @@ JetFile: Attributes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsdf') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsdf') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -250,34 +260,37 @@ JetFile: Attributes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsd') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsd') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + PsiElement(IDENTIFIER)('b') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + PsiElement(IDENTIFIER)('f') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') + PsiElement(IDENTIFIER)('c') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') PsiElement(private)('private') diff --git a/idea/testData/psi/AttributesOnPatterns.txt b/idea/testData/psi/AttributesOnPatterns.txt index 10e9ac1afbd..a20e639e803 100644 --- a/idea/testData/psi/AttributesOnPatterns.txt +++ b/idea/testData/psi/AttributesOnPatterns.txt @@ -29,10 +29,11 @@ JetFile: AttributesOnPatterns.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PROPERTY @@ -53,10 +54,11 @@ JetFile: AttributesOnPatterns.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PROPERTY @@ -86,10 +88,11 @@ JetFile: AttributesOnPatterns.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(MUL)('*') @@ -107,10 +110,11 @@ JetFile: AttributesOnPatterns.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') INTEGER_CONSTANT @@ -129,10 +133,11 @@ JetFile: AttributesOnPatterns.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TYPE_REFERENCE @@ -153,10 +158,11 @@ JetFile: AttributesOnPatterns.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') REFERENCE_EXPRESSION diff --git a/idea/testData/psi/Attributes_ERR.txt b/idea/testData/psi/Attributes_ERR.txt index fe1a46d11c7..e9295b81795 100644 --- a/idea/testData/psi/Attributes_ERR.txt +++ b/idea/testData/psi/Attributes_ERR.txt @@ -44,25 +44,26 @@ JetFile: Attributes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('B') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -78,68 +79,71 @@ JetFile: Attributes_ERR.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('ina') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ina') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE USER_TYPE USER_TYPE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + PsiElement(IDENTIFIER)('goo') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('goo') + PsiElement(IDENTIFIER)('doo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiElement(GT)('>') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('doo') + PsiElement(IDENTIFIER)('foo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') TYPE_PROJECTION TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') + PsiElement(IDENTIFIER)('bar') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('goo') PsiElement(GT)('>') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('goo') - PsiElement(GT)('>') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('df') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('df') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') PsiElement(in)('in') @@ -147,32 +151,36 @@ JetFile: Attributes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsdf') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsdf') PsiWhiteSpace(' ') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('s') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('s') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('fd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('fd') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('d') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('d') PsiErrorElement:No commas needed to separate attributes PsiElement(COMMA)(',') PsiWhiteSpace(' ') @@ -208,34 +216,37 @@ JetFile: Attributes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsd') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsd') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + PsiElement(IDENTIFIER)('b') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + PsiElement(IDENTIFIER)('f') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') + PsiElement(IDENTIFIER)('c') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n') PsiElement(private)('private') diff --git a/idea/testData/psi/BabySteps.txt b/idea/testData/psi/BabySteps.txt index 0d6f0b46e64..7acbef60384 100644 --- a/idea/testData/psi/BabySteps.txt +++ b/idea/testData/psi/BabySteps.txt @@ -39,10 +39,11 @@ JetFile: BabySteps.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT diff --git a/idea/testData/psi/BabySteps_ERR.txt b/idea/testData/psi/BabySteps_ERR.txt index 3e73733e1f6..10f833378f0 100644 --- a/idea/testData/psi/BabySteps_ERR.txt +++ b/idea/testData/psi/BabySteps_ERR.txt @@ -39,10 +39,11 @@ JetFile: BabySteps_ERR.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT diff --git a/idea/testData/psi/Constructors.txt b/idea/testData/psi/Constructors.txt index 8f6190bcb22..399347a748b 100644 --- a/idea/testData/psi/Constructors.txt +++ b/idea/testData/psi/Constructors.txt @@ -41,18 +41,19 @@ JetFile: Constructors.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -100,18 +101,19 @@ JetFile: Constructors.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT diff --git a/idea/testData/psi/EOLsOnRollback.txt b/idea/testData/psi/EOLsOnRollback.txt index 7efa0f3a876..57452bcd20b 100644 --- a/idea/testData/psi/EOLsOnRollback.txt +++ b/idea/testData/psi/EOLsOnRollback.txt @@ -57,10 +57,11 @@ JetFile: EOLsOnRollback.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(var)('var') @@ -80,10 +81,11 @@ JetFile: EOLsOnRollback.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(val)('val') diff --git a/idea/testData/psi/Enums.txt b/idea/testData/psi/Enums.txt index bf1c8defbac..0d99c824222 100644 --- a/idea/testData/psi/Enums.txt +++ b/idea/testData/psi/Enums.txt @@ -37,10 +37,11 @@ JetFile: Enums.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Color') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Color') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -58,10 +59,11 @@ JetFile: Enums.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Color') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Color') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -79,10 +81,11 @@ JetFile: Enums.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Color') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Color') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -135,18 +138,19 @@ JetFile: Enums.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('List') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Nothing') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Nothing') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -202,18 +206,19 @@ JetFile: Enums.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('List') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiComment(BLOCK_COMMENT)('/*tail.size + 1*/') diff --git a/idea/testData/psi/FunctionLiterals.txt b/idea/testData/psi/FunctionLiterals.txt index 1345d185d8a..134e6ffc835 100644 --- a/idea/testData/psi/FunctionLiterals.txt +++ b/idea/testData/psi/FunctionLiterals.txt @@ -463,10 +463,11 @@ JetFile: FunctionLiterals.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('x') @@ -477,10 +478,11 @@ JetFile: FunctionLiterals.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('y') @@ -491,10 +493,11 @@ JetFile: FunctionLiterals.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('c') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('z') diff --git a/idea/testData/psi/FunctionTypes.txt b/idea/testData/psi/FunctionTypes.txt index 83484a56d85..1031efe47ac 100644 --- a/idea/testData/psi/FunctionTypes.txt +++ b/idea/testData/psi/FunctionTypes.txt @@ -20,10 +20,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TYPE_REFERENCE @@ -91,10 +92,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -149,10 +151,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -272,10 +275,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -673,10 +677,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') FUNCTION_TYPE @@ -711,10 +716,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') FUNCTION_TYPE @@ -753,10 +759,11 @@ JetFile: FunctionTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') FUNCTION_TYPE diff --git a/idea/testData/psi/Functions.txt b/idea/testData/psi/Functions.txt index a32f14bfeea..028974d83f7 100644 --- a/idea/testData/psi/Functions.txt +++ b/idea/testData/psi/Functions.txt @@ -14,10 +14,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') @@ -32,10 +33,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -54,10 +56,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -92,10 +95,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -168,10 +172,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') @@ -187,10 +192,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -210,10 +216,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -249,10 +256,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -329,10 +337,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') @@ -351,10 +360,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -377,10 +387,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -419,10 +430,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -491,10 +503,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -516,10 +529,11 @@ JetFile: Functions.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') FUNCTION_TYPE diff --git a/idea/testData/psi/Functions_ERR.txt b/idea/testData/psi/Functions_ERR.txt index 24c494ef142..03213365ddb 100644 --- a/idea/testData/psi/Functions_ERR.txt +++ b/idea/testData/psi/Functions_ERR.txt @@ -15,10 +15,11 @@ JetFile: Functions_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') @@ -40,10 +41,11 @@ JetFile: Functions_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -77,10 +79,11 @@ JetFile: Functions_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -123,10 +126,11 @@ JetFile: Functions_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -176,10 +180,11 @@ JetFile: Functions_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -232,10 +237,11 @@ JetFile: Functions_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') diff --git a/idea/testData/psi/Imports_ERR.txt b/idea/testData/psi/Imports_ERR.txt index b65a66108ad..f9832e87923 100644 --- a/idea/testData/psi/Imports_ERR.txt +++ b/idea/testData/psi/Imports_ERR.txt @@ -51,100 +51,109 @@ JetFile: Imports_ERR.jet PsiWhiteSpace(' ') MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - PsiWhiteSpace('\n') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('import') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') + PsiWhiteSpace('\n') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(DOT)('.') - PsiWhiteSpace('\n') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('import') + PsiElement(IDENTIFIER)('import') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + PsiWhiteSpace('\n') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('import') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiErrorElement:Type name expected + PsiElement(as)('as') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiErrorElement:Type name expected - PsiElement(as)('as') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('import') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('import') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiErrorElement:Type name expected - PsiElement(MUL)('*') + PsiErrorElement:Type name expected + PsiElement(MUL)('*') PsiWhiteSpace(' ') PsiErrorElement:Expecting namespace or top level declaration PsiElement(as)('as') PsiWhiteSpace(' ') MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiWhiteSpace('\n') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('import') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('bar') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiErrorElement:Type name expected - PsiElement(MUL)('*') + PsiWhiteSpace('\n') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('import') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Type name expected + PsiElement(MUL)('*') PsiWhiteSpace(' ') PsiErrorElement:Expecting namespace or top level declaration PsiElement(as)('as') diff --git a/idea/testData/psi/LocalDeclarations.txt b/idea/testData/psi/LocalDeclarations.txt index 6e4861e3263..67d9ad685fd 100644 --- a/idea/testData/psi/LocalDeclarations.txt +++ b/idea/testData/psi/LocalDeclarations.txt @@ -22,10 +22,11 @@ JetFile: LocalDeclarations.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(abstract)('abstract') @@ -47,10 +48,11 @@ JetFile: LocalDeclarations.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(class)('class') @@ -81,10 +83,11 @@ JetFile: LocalDeclarations.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(var)('var') diff --git a/idea/testData/psi/NamespaceBlock_ERR.txt b/idea/testData/psi/NamespaceBlock_ERR.txt index 0a28fe1b9bf..12e6c6278ae 100644 --- a/idea/testData/psi/NamespaceBlock_ERR.txt +++ b/idea/testData/psi/NamespaceBlock_ERR.txt @@ -22,48 +22,52 @@ JetFile: NamespaceBlock_ERR.jet NAMESPACE MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - PsiWhiteSpace('\n') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('import') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') + PsiWhiteSpace('\n') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(DOT)('.') - PsiWhiteSpace('\n') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('import') + PsiElement(IDENTIFIER)('import') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + PsiWhiteSpace('\n') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('import') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiErrorElement:Type name expected + PsiElement(as)('as') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiErrorElement:Type name expected - PsiElement(as)('as') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n\n') PsiElement(namespace)('namespace') PsiWhiteSpace(' ') @@ -255,10 +259,11 @@ JetFile: NamespaceBlock_ERR.jet CLASS MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('dsfgd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('dsfgd') PsiWhiteSpace('\n\n') PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/idea/testData/psi/NamespaceModifiers.txt b/idea/testData/psi/NamespaceModifiers.txt index d5954be35c1..c167504da98 100644 --- a/idea/testData/psi/NamespaceModifiers.txt +++ b/idea/testData/psi/NamespaceModifiers.txt @@ -6,10 +6,11 @@ JetFile: NamespaceModifiers.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(namespace)('namespace') @@ -23,10 +24,11 @@ JetFile: NamespaceModifiers.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(namespace)('namespace') diff --git a/idea/testData/psi/Properties.txt b/idea/testData/psi/Properties.txt index c51efa1e7d3..1cfc779d614 100644 --- a/idea/testData/psi/Properties.txt +++ b/idea/testData/psi/Properties.txt @@ -29,10 +29,11 @@ JetFile: Properties.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') @@ -65,10 +66,11 @@ JetFile: Properties.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') diff --git a/idea/testData/psi/PropertiesFollowedByInitializers.txt b/idea/testData/psi/PropertiesFollowedByInitializers.txt index c7a148781ba..d3171c40810 100644 --- a/idea/testData/psi/PropertiesFollowedByInitializers.txt +++ b/idea/testData/psi/PropertiesFollowedByInitializers.txt @@ -223,10 +223,11 @@ JetFile: PropertiesFollowedByInitializers.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(abstract)('abstract') diff --git a/idea/testData/psi/Properties_ERR.txt b/idea/testData/psi/Properties_ERR.txt index b4462bae6b3..b4a8fc99fb2 100644 --- a/idea/testData/psi/Properties_ERR.txt +++ b/idea/testData/psi/Properties_ERR.txt @@ -45,16 +45,18 @@ JetFile: Properties_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiErrorElement:Expecting ']' to close an attribute annotation PsiWhiteSpace(' ') @@ -81,10 +83,11 @@ JetFile: Properties_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') @@ -133,10 +136,11 @@ JetFile: Properties_ERR.jet PROPERTY MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace('\n\n') PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/idea/testData/psi/QuotedIdentifiers.txt b/idea/testData/psi/QuotedIdentifiers.txt index 91897a74b3b..ce428edd419 100644 --- a/idea/testData/psi/QuotedIdentifiers.txt +++ b/idea/testData/psi/QuotedIdentifiers.txt @@ -5,10 +5,11 @@ JetFile: QuotedIdentifiers.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('`return`') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('`return`') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/ShortAnnotations.txt b/idea/testData/psi/ShortAnnotations.txt index c369f5a501c..cf2cafe2284 100644 --- a/idea/testData/psi/ShortAnnotations.txt +++ b/idea/testData/psi/ShortAnnotations.txt @@ -2,75 +2,27 @@ JetFile: ShortAnnotations.jet NAMESPACE MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') - PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('aa') - PsiWhiteSpace('\n\n') - NAMESPACE - MODIFIER_LIST - ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('bar') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -83,6 +35,40 @@ JetFile: ShortAnnotations.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') + PsiWhiteSpace(' ') + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + NAMESPACE_NAME + PsiElement(IDENTIFIER)('aa') + PsiWhiteSpace('\n\n') + NAMESPACE + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -91,10 +77,32 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(namespace)('namespace') PsiWhiteSpace(' ') @@ -109,16 +117,18 @@ JetFile: ShortAnnotations.jet CLASS MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -127,18 +137,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -147,10 +158,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') @@ -161,16 +173,18 @@ JetFile: ShortAnnotations.jet OBJECT_DECLARATION MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -179,18 +193,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -199,10 +214,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(object)('object') PsiWhiteSpace(' ') @@ -212,16 +228,18 @@ JetFile: ShortAnnotations.jet FUN MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -230,18 +248,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -250,10 +269,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(fun)('fun') PsiWhiteSpace(' ') @@ -269,16 +289,18 @@ JetFile: ShortAnnotations.jet PROPERTY MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -287,18 +309,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -307,10 +330,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(val)('val') PsiWhiteSpace(' ') @@ -331,16 +355,18 @@ JetFile: ShortAnnotations.jet PROPERTY MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -349,18 +375,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -369,10 +396,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(var)('var') PsiWhiteSpace(' ') @@ -393,16 +421,18 @@ JetFile: ShortAnnotations.jet TYPEDEF MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -411,18 +441,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -431,10 +462,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(type)('type') PsiWhiteSpace(' ') @@ -462,16 +494,18 @@ JetFile: ShortAnnotations.jet CLASS_OBJECT MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -480,18 +514,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -500,10 +535,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') @@ -517,16 +553,18 @@ JetFile: ShortAnnotations.jet CLASS MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -535,18 +573,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -555,10 +594,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') @@ -569,16 +609,18 @@ JetFile: ShortAnnotations.jet OBJECT_DECLARATION MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -587,18 +629,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -607,10 +650,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(object)('object') PsiWhiteSpace(' ') @@ -620,16 +664,18 @@ JetFile: ShortAnnotations.jet FUN MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -638,18 +684,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -658,10 +705,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(fun)('fun') PsiWhiteSpace(' ') @@ -677,16 +725,18 @@ JetFile: ShortAnnotations.jet PROPERTY MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -695,18 +745,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -715,10 +766,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(val)('val') PsiWhiteSpace(' ') @@ -739,16 +791,18 @@ JetFile: ShortAnnotations.jet PROPERTY MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -757,18 +811,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -777,10 +832,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(var)('var') PsiWhiteSpace(' ') @@ -801,16 +857,18 @@ JetFile: ShortAnnotations.jet TYPEDEF MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -819,18 +877,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -839,10 +898,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(type)('type') PsiWhiteSpace(' ') @@ -860,16 +920,18 @@ JetFile: ShortAnnotations.jet CONSTRUCTOR MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -878,18 +940,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -898,10 +961,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(this)('this') VALUE_PARAMETER_LIST @@ -934,16 +998,18 @@ JetFile: ShortAnnotations.jet ANONYMOUS_INITIALIZER MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -952,18 +1018,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -972,10 +1039,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') BLOCK PsiElement(LBRACE)('{') @@ -1001,16 +1069,18 @@ JetFile: ShortAnnotations.jet PROPERTY MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -1019,18 +1089,19 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -1039,10 +1110,11 @@ JetFile: ShortAnnotations.jet PsiElement(RPAR)(')') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/idea/testData/psi/SimpleClassMembers.txt b/idea/testData/psi/SimpleClassMembers.txt index f29673fb7fa..8763cc9a78e 100644 --- a/idea/testData/psi/SimpleClassMembers.txt +++ b/idea/testData/psi/SimpleClassMembers.txt @@ -105,18 +105,19 @@ JetFile: SimpleClassMembers.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -260,10 +261,11 @@ JetFile: SimpleClassMembers.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Goo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Goo') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -344,18 +346,19 @@ JetFile: SimpleClassMembers.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -428,18 +431,19 @@ JetFile: SimpleClassMembers.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -478,18 +482,19 @@ JetFile: SimpleClassMembers.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -617,10 +622,11 @@ JetFile: SimpleClassMembers.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Goo') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Goo') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') diff --git a/idea/testData/psi/SimpleClassMembers_ERR.txt b/idea/testData/psi/SimpleClassMembers_ERR.txt index d7df8ddae92..5f9530a1671 100644 --- a/idea/testData/psi/SimpleClassMembers_ERR.txt +++ b/idea/testData/psi/SimpleClassMembers_ERR.txt @@ -36,10 +36,11 @@ JetFile: SimpleClassMembers_ERR.jet PsiWhiteSpace('\n ') MODIFIER_LIST ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('sdfsd') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('sdfsd') PsiWhiteSpace('\n ') PsiErrorElement:Expecting member declaration PsiElement(RBRACE)('}') @@ -107,19 +108,20 @@ JetFile: SimpleClassMembers_ERR.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiErrorElement:Expecting a '>' - + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiErrorElement:Expecting a '>' + VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -158,18 +160,19 @@ JetFile: SimpleClassMembers_ERR.jet PsiElement(COMMA)(',') PsiWhiteSpace(' ') DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT diff --git a/idea/testData/psi/TupleTypes.txt b/idea/testData/psi/TupleTypes.txt index f47f0dfd725..8ed6a23a10a 100644 --- a/idea/testData/psi/TupleTypes.txt +++ b/idea/testData/psi/TupleTypes.txt @@ -96,10 +96,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE @@ -116,10 +117,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') TUPLE_TYPE PsiElement(LPAR)('(') @@ -127,10 +129,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -148,10 +151,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE @@ -160,10 +164,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -175,10 +180,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') USER_TYPE REFERENCE_EXPRESSION @@ -195,10 +201,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE @@ -212,10 +219,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -232,10 +240,11 @@ JetFile: TupleTypes.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE diff --git a/idea/testData/psi/TupleTypes_ERR.txt b/idea/testData/psi/TupleTypes_ERR.txt index 5b926e044c1..5a2e46aa6eb 100644 --- a/idea/testData/psi/TupleTypes_ERR.txt +++ b/idea/testData/psi/TupleTypes_ERR.txt @@ -91,10 +91,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE @@ -111,10 +112,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') TUPLE_TYPE PsiElement(LPAR)('(') @@ -122,16 +124,18 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiWhiteSpace(' ') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('X') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('X') PsiErrorElement:Expecting ']' to close an attribute annotation PsiElement(RPAR)(')') @@ -146,10 +150,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE @@ -158,10 +163,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -173,10 +179,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') USER_TYPE REFERENCE_EXPRESSION @@ -193,10 +200,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE @@ -210,10 +218,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -230,10 +239,11 @@ JetFile: TupleTypes_ERR.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE diff --git a/idea/testData/psi/TypeAnnotations.txt b/idea/testData/psi/TypeAnnotations.txt index 2768a6f49b7..ad5453b1cf0 100644 --- a/idea/testData/psi/TypeAnnotations.txt +++ b/idea/testData/psi/TypeAnnotations.txt @@ -17,19 +17,21 @@ JetFile: TypeAnnotations.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -50,19 +52,21 @@ JetFile: TypeAnnotations.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE @@ -75,10 +79,11 @@ JetFile: TypeAnnotations.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TYPE_REFERENCE diff --git a/idea/testData/psi/TypeParametersBeforeName.txt b/idea/testData/psi/TypeParametersBeforeName.txt index 27eb886afbd..7f719787d19 100644 --- a/idea/testData/psi/TypeParametersBeforeName.txt +++ b/idea/testData/psi/TypeParametersBeforeName.txt @@ -34,10 +34,11 @@ JetFile: TypeParametersBeforeName.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') @@ -62,10 +63,11 @@ JetFile: TypeParametersBeforeName.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') USER_TYPE diff --git a/idea/testData/psi/examples/AnonymousObjects.txt b/idea/testData/psi/examples/AnonymousObjects.txt index 400ec360b6c..bab77c6c07b 100644 --- a/idea/testData/psi/examples/AnonymousObjects.txt +++ b/idea/testData/psi/examples/AnonymousObjects.txt @@ -25,10 +25,11 @@ JetFile: AnonymousObjects.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('MouseAdapter') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('MouseAdapter') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') diff --git a/idea/testData/psi/examples/BinaryTree.txt b/idea/testData/psi/examples/BinaryTree.txt index 726cdc87bc6..36008ffeaa0 100644 --- a/idea/testData/psi/examples/BinaryTree.txt +++ b/idea/testData/psi/examples/BinaryTree.txt @@ -244,10 +244,11 @@ JetFile: BinaryTree.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/BitArith.txt b/idea/testData/psi/examples/BitArith.txt index 78b27536eb5..bb961a436f6 100644 --- a/idea/testData/psi/examples/BitArith.txt +++ b/idea/testData/psi/examples/BitArith.txt @@ -561,10 +561,11 @@ JetFile: BitArith.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') @@ -593,10 +594,11 @@ JetFile: BitArith.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/Builder.txt b/idea/testData/psi/examples/Builder.txt index 4a5462bc384..3f34447a17d 100644 --- a/idea/testData/psi/examples/Builder.txt +++ b/idea/testData/psi/examples/Builder.txt @@ -16,10 +16,11 @@ JetFile: Builder.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('AntBuilder') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('AntBuilder') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') @@ -32,10 +33,11 @@ JetFile: Builder.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('lazy') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('lazy') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(val)('val') @@ -77,10 +79,11 @@ JetFile: Builder.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('lazy') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('lazy') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(val)('val') @@ -148,10 +151,11 @@ JetFile: Builder.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('lazy') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('lazy') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(val)('val') diff --git a/idea/testData/psi/examples/Color.txt b/idea/testData/psi/examples/Color.txt index 0dbf73d4402..76c5d33a5da 100644 --- a/idea/testData/psi/examples/Color.txt +++ b/idea/testData/psi/examples/Color.txt @@ -63,10 +63,11 @@ JetFile: Color.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Color') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Color') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -94,10 +95,11 @@ JetFile: Color.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Color') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Color') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -125,10 +127,11 @@ JetFile: Color.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Color') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Color') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT diff --git a/idea/testData/psi/examples/PolymorphicClassObjects.txt b/idea/testData/psi/examples/PolymorphicClassObjects.txt index bda7e5cbe59..dcc30974cee 100644 --- a/idea/testData/psi/examples/PolymorphicClassObjects.txt +++ b/idea/testData/psi/examples/PolymorphicClassObjects.txt @@ -25,10 +25,11 @@ JetFile: PolymorphicClassObjects.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/With.txt b/idea/testData/psi/examples/With.txt index 4bfd48cf261..25fdde079e5 100644 --- a/idea/testData/psi/examples/With.txt +++ b/idea/testData/psi/examples/With.txt @@ -5,10 +5,11 @@ JetFile: With.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('inline') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('inline') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/array/MutableArray.txt b/idea/testData/psi/examples/array/MutableArray.txt index 2adc65fefc5..9d0f964dcfa 100644 --- a/idea/testData/psi/examples/array/MutableArray.txt +++ b/idea/testData/psi/examples/array/MutableArray.txt @@ -35,10 +35,11 @@ JetFile: MutableArray.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') @@ -101,10 +102,11 @@ JetFile: MutableArray.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/collections/ArrayList.txt b/idea/testData/psi/examples/collections/ArrayList.txt index f795a60dbb7..769d27e1aa4 100644 --- a/idea/testData/psi/examples/collections/ArrayList.txt +++ b/idea/testData/psi/examples/collections/ArrayList.txt @@ -147,10 +147,11 @@ JetFile: ArrayList.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('IMutableIterator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('IMutableIterator') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') diff --git a/idea/testData/psi/examples/collections/HashMap.txt b/idea/testData/psi/examples/collections/HashMap.txt index 358402d0087..fa4d6ace61f 100644 --- a/idea/testData/psi/examples/collections/HashMap.txt +++ b/idea/testData/psi/examples/collections/HashMap.txt @@ -337,10 +337,11 @@ JetFile: HashMap.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('inline') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('inline') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') @@ -770,10 +771,11 @@ JetFile: HashMap.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('inline') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('inline') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') @@ -816,10 +818,11 @@ JetFile: HashMap.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('inline') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('inline') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/collections/IList.txt b/idea/testData/psi/examples/collections/IList.txt index 59733e48dac..e27ab630e52 100644 --- a/idea/testData/psi/examples/collections/IList.txt +++ b/idea/testData/psi/examples/collections/IList.txt @@ -48,10 +48,11 @@ JetFile: IList.jet ANNOTATION PsiElement(LBRACKET)('[') ANNOTATION_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('operator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('operator') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(fun)('fun') diff --git a/idea/testData/psi/examples/collections/List.txt b/idea/testData/psi/examples/collections/List.txt index aab7117b2e6..3fcf3bfc95b 100644 --- a/idea/testData/psi/examples/collections/List.txt +++ b/idea/testData/psi/examples/collections/List.txt @@ -58,18 +58,19 @@ JetFile: List.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('List') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Nothing') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Nothing') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -125,18 +126,19 @@ JetFile: List.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('List') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -234,10 +236,11 @@ JetFile: List.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('IIterator') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('IIterator') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') diff --git a/idea/testData/psi/examples/io/IOSamples.txt b/idea/testData/psi/examples/io/IOSamples.txt index 1195a118608..9f6e5596509 100644 --- a/idea/testData/psi/examples/io/IOSamples.txt +++ b/idea/testData/psi/examples/io/IOSamples.txt @@ -102,10 +102,11 @@ JetFile: IOSamples.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('ICloseable') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ICloseable') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -292,10 +293,11 @@ JetFile: IOSamples.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('JavaCloseableWrapper') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('JavaCloseableWrapper') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT @@ -563,10 +565,11 @@ JetFile: IOSamples.jet PsiWhiteSpace(' ') INITIALIZER_LIST DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('JavaCloseableWrapper') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('JavaCloseableWrapper') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT diff --git a/idea/tests/org/jetbrains/jet/JetTestUtils.java b/idea/tests/org/jetbrains/jet/JetTestUtils.java index 96e8bf142e6..794ff6f564a 100644 --- a/idea/tests/org/jetbrains/jet/JetTestUtils.java +++ b/idea/tests/org/jetbrains/jet/JetTestUtils.java @@ -1,18 +1,13 @@ package org.jetbrains.jet; -import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.ErrorHandler; -import org.jetbrains.jet.lang.ErrorHandlerWithRegions; import org.jetbrains.jet.lang.JetDiagnostic; -import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTrace; -import org.jetbrains.jet.lang.resolve.JetScope; -import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; -import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.util.ReadOnlySlice; +import org.jetbrains.jet.util.WritableSlice; import java.util.Collection; @@ -22,222 +17,46 @@ import java.util.Collection; public class JetTestUtils { public static final BindingTrace DUMMY_TRACE = new BindingTrace() { - @Override - public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) { - } - - @Override - public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { - } - - @Override - public void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element) { - } - - @Override - public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor) { - } - - @Override - public void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor) { - - } - - @Override - public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) { - } - - @Override - public void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor) { - - } - - @Override - public void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant value) { - - } - - @Override - public void recordBlock(JetFunctionLiteralExpression expression) { - } - - @Override - public void recordStatement(@NotNull JetElement statement) { - } - - @Override - public void recordVariableReassignment(@NotNull JetExpression expression) { - - } - - @Override - public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) { - } - - @Override - public void removeStatementRecord(@NotNull JetElement statement) { - } - - @Override - public void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor) { - } - - @Override - public void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type) { - - } - @NotNull @Override - public ErrorHandlerWithRegions getErrorHandler() { - return new ErrorHandlerWithRegions(new ErrorHandler() { + public ErrorHandler getErrorHandler() { + return new ErrorHandler() { @Override public void unresolvedReference(@NotNull JetReferenceExpression referenceExpression) { throw new IllegalStateException("Unresolved: " + referenceExpression.getText()); } - }); + }; } - @Override - public boolean isProcessed(@NotNull JetExpression expression) { - return false; - } - - @Override - public void markAsProcessed(@NotNull JetExpression expression) { - - } @Override public BindingContext getBindingContext() { return new BindingContext() { - @Override - public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public ConstructorDescriptor getConstructorDescriptor(JetElement declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public CompileTimeConstant getCompileTimeValue(JetExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public VariableDescriptor getVariableDescriptor(JetProperty declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public VariableDescriptor getVariableDescriptor(JetParameter declaration) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public JetType getExpressionType(JetExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) { - return null; - } - - @Override - public JetType resolveTypeReference(JetTypeReference typeReference) { - return null; - } - - @Override - public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public boolean isBlock(JetFunctionLiteralExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public boolean isStatement(JetExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public boolean hasBackingField(PropertyDescriptor propertyDescriptor) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public boolean isVariableReassignment(JetExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public JetType getAutoCastType(@NotNull JetExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - - @Override - public JetScope getResolutionScope(@NotNull JetExpression expression) { - throw new UnsupportedOperationException(); // TODO - } - @Override public Collection getDiagnostics() { throw new UnsupportedOperationException(); // TODO } + @Override + public V get(ReadOnlySlice slice, K key) { + return DUMMY_TRACE.get(slice, key); + } }; } + + @Override + public void record(WritableSlice slice, K key, V value) { + } + + @Override + public void record(WritableSlice slice, K key) { + } + + @Override + public V get(ReadOnlySlice slice, K key) { + if (slice == BindingContext.PROCESSED) return (V) Boolean.FALSE; + return null; + } }; } diff --git a/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java b/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java index 1e0c9566cc6..37d37903b6f 100644 --- a/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java +++ b/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java @@ -12,9 +12,15 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.types.*; +import org.jetbrains.jet.lang.resolve.BindingContextUtils; +import org.jetbrains.jet.lang.types.JetStandardLibrary; +import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.TypeConstructor; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -78,7 +84,7 @@ public class ExpectedResolveData { text = document.getText(); } - System.out.println("text = " + text); + System.out.println(text); } public void checkResult(JetFile file) { @@ -117,7 +123,7 @@ public class ExpectedResolveData { assertTrue( "Must have been unresolved: " + renderReferenceInContext(referenceExpression) + - " but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.resolveReferenceExpression(referenceExpression)), + " but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression)), unresolvedReferences.contains(referenceExpression)); continue; } @@ -125,8 +131,8 @@ public class ExpectedResolveData { assertTrue( "Must have been resolved to null: " + renderReferenceInContext(referenceExpression) + - " but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.resolveReferenceExpression(referenceExpression)), - bindingContext.getExpressionType(referenceExpression) == null + " but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression)), + bindingContext.get(BindingContext.EXPRESSION_TYPE, referenceExpression) == null ); continue; } @@ -144,12 +150,12 @@ public class ExpectedResolveData { DeclarationDescriptor expectedDescriptor = nameToDescriptor.get(name); JetTypeReference typeReference = getAncestorOfType(JetTypeReference.class, element); if (expectedDescriptor != null) { - DeclarationDescriptor actual = bindingContext.resolveReferenceExpression(reference); + DeclarationDescriptor actual = bindingContext.get(BindingContext.REFERENCE_TARGET, reference); assertSame("Expected: " + name, expectedDescriptor.getOriginal(), actual == null ? null : actual.getOriginal()); continue; } - JetType actualType = bindingContext.resolveTypeReference(typeReference); + JetType actualType = bindingContext.get(BindingContext.TYPE, typeReference); assertNotNull("Type " + name + " not resolved for reference " + name, actualType); ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(name.substring(5)); assertNotNull("Expected class not found: " + name); @@ -158,7 +164,7 @@ public class ExpectedResolveData { } assert expected != null : "No declaration for " + name; - PsiElement actual = bindingContext.resolveToDeclarationPsiElement(reference); + PsiElement actual = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, reference); String actualName = null; if (actual != null) { @@ -172,17 +178,17 @@ public class ExpectedResolveData { if (expected instanceof JetParameter || actual instanceof JetParameter) { DeclarationDescriptor expectedDescriptor; if (name.startsWith("$")) { - expectedDescriptor = bindingContext.getPropertyDescriptor((JetParameter) expected); + expectedDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, (JetParameter) expected); } else { - expectedDescriptor = bindingContext.getDeclarationDescriptor(expected); + expectedDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, expected); if (expectedDescriptor == null) { - expectedDescriptor = bindingContext.getConstructorDescriptor((JetElement) expected); + expectedDescriptor = bindingContext.get(BindingContext.CONSTRUCTOR, (JetElement) expected); } } - DeclarationDescriptor actualDescriptor = bindingContext.resolveReferenceExpression(reference); + DeclarationDescriptor actualDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, reference); if (actualDescriptor instanceof VariableAsFunctionDescriptor) { VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) actualDescriptor; actualDescriptor = descriptor.getVariableDescriptor(); @@ -206,7 +212,7 @@ public class ExpectedResolveData { PsiElement element = file.findElementAt(position); JetExpression expression = getAncestorOfType(JetExpression.class, element); - JetType expressionType = bindingContext.getExpressionType(expression); + JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression); TypeConstructor expectedTypeConstructor; if (typeName.startsWith("std::")) { ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(typeName.substring(5)); @@ -221,11 +227,11 @@ public class ExpectedResolveData { JetDeclaration declaration = getAncestorOfType(JetDeclaration.class, declElement); assertNotNull(declaration); if (declaration instanceof JetClass) { - ClassDescriptor classDescriptor = bindingContext.getClassDescriptor((JetClass) declaration); + ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, (JetClass) declaration); expectedTypeConstructor = classDescriptor.getTypeConstructor(); } else if (declaration instanceof JetTypeParameter) { - TypeParameterDescriptor typeParameterDescriptor = bindingContext.getTypeParameterDescriptor((JetTypeParameter) declaration); + TypeParameterDescriptor typeParameterDescriptor = bindingContext.get(BindingContext.TYPE_PARAMETER, (JetTypeParameter) declaration); expectedTypeConstructor = typeParameterDescriptor.getTypeConstructor(); } else { From b3b8a23f4e253b66ed0931beeb9b5cbf240c53f7 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Mon, 22 Aug 2011 18:36:41 +0400 Subject: [PATCH 3/3] Get rid of myStack holding intermediate StackValues and use functional style visitor instead. --- .../jetbrains/jet/codegen/ClassContext.java | 2 +- .../jet/codegen/ExpressionCodegen.java | 429 +++++++++--------- .../jet/codegen/FunctionCodegen.java | 36 +- .../org/jetbrains/jet/codegen/StackValue.java | 18 +- .../jet/codegen/intrinsics/ArraySize.java | 4 +- .../jet/codegen/intrinsics/BinaryOp.java | 11 +- .../jet/codegen/intrinsics/Concat.java | 16 +- .../jet/codegen/intrinsics/Increment.java | 4 +- .../codegen/intrinsics/IntrinsicMethod.java | 2 +- .../jetbrains/jet/codegen/intrinsics/Inv.java | 4 +- .../jetbrains/jet/codegen/intrinsics/Not.java | 6 +- .../jet/codegen/intrinsics/NumberCast.java | 4 +- .../jet/codegen/intrinsics/PsiMethodCall.java | 4 +- .../jet/codegen/intrinsics/RangeTo.java | 2 +- .../jet/codegen/intrinsics/TypeInfo.java | 2 +- .../jet/codegen/intrinsics/UnaryMinus.java | 4 +- .../jet/codegen/intrinsics/ValueTypeInfo.java | 2 +- 17 files changed, 259 insertions(+), 291 deletions(-) diff --git a/idea/src/org/jetbrains/jet/codegen/ClassContext.java b/idea/src/org/jetbrains/jet/codegen/ClassContext.java index 87e92d070f7..d553ca2774e 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClassContext.java +++ b/idea/src/org/jetbrains/jet/codegen/ClassContext.java @@ -37,7 +37,7 @@ public class ClassContext { } public StackValue getThisExpression() { - if (parentContext == null) return null; + if (parentContext == null) return StackValue.none(); thisWasUsed = true; if (thisExpression != null) return thisExpression; diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 99783414912..df9e10521d2 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -33,7 +33,7 @@ import java.util.*; * @author max * @author yole */ -public class ExpressionCodegen extends JetVisitorVoid { +public class ExpressionCodegen extends JetVisitor { private static final String CLASS_OBJECT = "java/lang/Object"; private static final String CLASS_STRING = "java/lang/String"; public static final String CLASS_STRING_BUILDER = "java/lang/StringBuilder"; @@ -59,7 +59,6 @@ public class ExpressionCodegen extends JetVisitorVoid { private final Stack