From 6a03ec3878e4fa923189773e752cdb8e0e35b757 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 27 May 2011 16:16:52 +0400 Subject: [PATCH] Tests fixed + 'this' is resolved to the corresponding declaration --- .../jetbrains/jet/codegen/JetTypeMapper.java | 3 +- .../lang/parsing/JetExpressionParsing.java | 3 + .../jet/lang/psi/JetSimpleNameExpression.java | 2 +- .../jet/lang/psi/JetThisExpression.java | 5 ++ .../lang/resolve/AbstractScopeAdapter.java | 4 ++ .../jet/lang/resolve/ChainedScope.java | 15 +++++ .../lang/resolve/ClassDescriptorResolver.java | 1 - .../jet/lang/resolve/DescriptorUtils.java | 33 +++++++++++ .../jetbrains/jet/lang/resolve/JetScope.java | 3 + .../jet/lang/resolve/JetScopeImpl.java | 5 ++ .../jet/lang/resolve/SubstitutingScope.java | 7 +++ .../jet/lang/resolve/WritableScopeImpl.java | 8 +++ .../resolve/java/JavaClassMembersScope.java | 5 ++ .../jetbrains/jet/lang/types/ErrorUtils.java | 5 ++ .../jet/lang/types/JetTypeInferrer.java | 25 +++++--- idea/testData/psi/AnnotatedExpressions.txt | 3 +- idea/testData/psi/Labels.txt | 24 +++++--- idea/testData/psi/Properties.txt | 3 +- idea/testData/psi/SimpleExpressions.txt | 6 +- idea/testData/psi/examples/BinaryTree.txt | 15 +++-- idea/testData/psi/examples/BitArith.txt | 3 +- .../psi/examples/PolymorphicClassObjects.txt | 3 +- idea/testData/psi/examples/UnionFind.txt | 3 +- .../psi/examples/collections/ArrayList.txt | 3 +- .../psi/examples/collections/HashMap.txt | 9 ++- .../psi/examples/collections/List.txt | 6 +- .../examples/priorityqueues/BinaryHeap.txt | 57 ++++++++++++------- idea/testData/resolve/Classifiers.jet | 9 ++- .../tests/org/jetbrains/jet/JetTestUtils.java | 1 + 29 files changed, 211 insertions(+), 58 deletions(-) create mode 100644 idea/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java diff --git a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 71c516ba0c2..701a18f0740 100644 --- a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import jet.typeinfo.TypeInfo; +import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -125,7 +126,7 @@ public class JetTypeMapper { return mapType(jetType, OwnerKind.INTERFACE); } - public Type mapType(final JetType jetType, OwnerKind kind) { + public Type mapType(@NotNull final JetType jetType, OwnerKind kind) { if (jetType.equals(JetStandardClasses.getUnitType()) || jetType.equals(JetStandardClasses.getNothingType())) { return Type.VOID_TYPE; } diff --git a/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java index 9fa7a6a3919..c8d070b14fa 100644 --- a/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -1520,7 +1520,10 @@ public class JetExpressionParsing extends AbstractJetParsing { private void parseThisExpression() { assert _at(THIS_KEYWORD); PsiBuilder.Marker mark = mark(); + + PsiBuilder.Marker thisReference = mark(); advance(); // THIS_KEYWORD + thisReference.done(REFERENCE_EXPRESSION); parseLabel(); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java index 3943a329724..09a3b7643af 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java @@ -15,7 +15,7 @@ import org.jetbrains.jet.lexer.JetTokens; * @author max */ public class JetSimpleNameExpression extends JetReferenceExpression { - public static final TokenSet REFERENCE_TOKENS = TokenSet.orSet(JetTokens.LABELS, TokenSet.create(JetTokens.IDENTIFIER, JetTokens.FIELD_IDENTIFIER)); + public static final TokenSet REFERENCE_TOKENS = TokenSet.orSet(JetTokens.LABELS, TokenSet.create(JetTokens.IDENTIFIER, JetTokens.FIELD_IDENTIFIER, JetTokens.THIS_KEYWORD)); public JetSimpleNameExpression(@NotNull ASTNode node) { super(node); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetThisExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetThisExpression.java index f7d3a7c6abe..87214721ecb 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetThisExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetThisExpression.java @@ -24,4 +24,9 @@ public class JetThisExpression extends JetLabelQualifiedExpression { return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE); } + @NotNull + public JetReferenceExpression getThisReference() { + return (JetReferenceExpression) findChildByType(JetNodeTypes.REFERENCE_EXPRESSION); + } + } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.java b/idea/src/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.java index e12f17d9a6a..f71ad7d28c0 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.java @@ -57,4 +57,8 @@ public abstract class AbstractScopeAdapter implements JetScope { return getWorkerScope().getPropertyByFieldReference(fieldName); } + @Override + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + return getWorkerScope().getDeclarationDescriptorForUnqualifiedThis(); + } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ChainedScope.java b/idea/src/org/jetbrains/jet/lang/resolve/ChainedScope.java index 1aae583dc43..9a154c70daa 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ChainedScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ChainedScope.java @@ -92,4 +92,19 @@ public class ChainedScope implements JetScope { } return null; } + + @Override + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + if (DescriptorUtils.definesItsOwnThis(getContainingDeclaration())) { + return getContainingDeclaration(); + } + + for (JetScope jetScope : scopeChain) { + DeclarationDescriptor containingDeclaration = jetScope.getContainingDeclaration(); + if (DescriptorUtils.definesItsOwnThis(containingDeclaration)) { + return containingDeclaration; + } + } + return null; + } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java index a66cfa3bbb2..c7b33c7b745 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java @@ -174,7 +174,6 @@ public class ClassDescriptorResolver { WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, trace.getErrorHandler()); innerScope.addLabeledDeclaration(functionDescriptor); - List typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters()); JetType receiverType = null; diff --git a/idea/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java b/idea/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java new file mode 100644 index 00000000000..3fdd90e670e --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java @@ -0,0 +1,33 @@ +package org.jetbrains.jet.lang.resolve; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.*; + +/** + * @author abreslav + */ +public class DescriptorUtils { + public static boolean definesItsOwnThis(@NotNull DeclarationDescriptor descriptor) { + return descriptor.accept(new DeclarationDescriptorVisitor() { + @Override + public Boolean visitDeclarationDescriptor(DeclarationDescriptor descriptor, Void data) { + return false; + } + + @Override + public Boolean visitFunctionDescriptor(FunctionDescriptor descriptor, Void data) { + return descriptor.getReceiverType() != null; + } + + @Override + public Boolean visitClassDescriptor(ClassDescriptor descriptor, Void data) { + return true; + } + + @Override + public Boolean visitPropertyDescriptor(PropertyDescriptor descriptor, Void data) { + return descriptor.getReceiverType() != null; + } + }, null); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java b/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java index 2306644bb08..a13a4ea16cd 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java @@ -46,4 +46,7 @@ public interface JetScope { */ @Nullable PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName); + + @Nullable + DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis(); } \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java b/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java index c22c745e844..eee50eca2e5 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java @@ -48,4 +48,9 @@ public abstract class JetScopeImpl implements JetScope { public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) { return null; } + + @Override + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + return null; + } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java b/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java index baf1625a26e..af1783429bd 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java @@ -1,6 +1,7 @@ package org.jetbrains.jet.lang.resolve; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.types.*; @@ -79,4 +80,10 @@ public class SubstitutingScope implements JetScope { public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) { throw new UnsupportedOperationException(); // TODO } + + @Override + @Nullable + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + return workerScope.getDeclarationDescriptorForUnqualifiedThis(); + } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/WritableScopeImpl.java b/idea/src/org/jetbrains/jet/lang/resolve/WritableScopeImpl.java index a9295fcf212..a6bf2db9b3c 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/WritableScopeImpl.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/WritableScopeImpl.java @@ -45,6 +45,14 @@ public class WritableScopeImpl extends WritableScopeWithImports { return ownerDeclarationDescriptor; } + @Override + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + if (DescriptorUtils.definesItsOwnThis(ownerDeclarationDescriptor)) { + return ownerDeclarationDescriptor; + } + return super.getDeclarationDescriptorForUnqualifiedThis(); + } + @NotNull private Map> getLabelsToDescriptors() { if (labelsToDescriptors == null) { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java index af73e5d911c..d8cbe10362f 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java @@ -47,6 +47,11 @@ public class JavaClassMembersScope implements JetScope { return null; } + @Override + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + throw new UnsupportedOperationException(); + } + @Override public ClassifierDescriptor getClassifier(@NotNull String name) { ClassifierDescriptor classifierDescriptor = classifiers.get(name); diff --git a/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java index c17a9950a81..b5c63b9c916 100644 --- a/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/idea/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -59,6 +59,11 @@ public class ErrorUtils { return null; // TODO : review } + @Override + public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() { + return ERROR_CLASS; // TODO : review + } + }; private static final FunctionGroup ERROR_FUNCTION_GROUP = new FunctionGroup() { diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 773b4e76270..229a3a40818 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -933,28 +933,34 @@ public class JetTypeInferrer { if (labelName != null) { Collection declarationsByLabel = scope.getDeclarationsByLabel(labelName); int size = declarationsByLabel.size(); + final JetSimpleNameExpression targetLabel = expression.getTargetLabel(); + assert targetLabel != null; if (size == 1) { DeclarationDescriptor declarationDescriptor = declarationsByLabel.iterator().next(); if (declarationDescriptor instanceof ClassDescriptor) { ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor; thisType = classDescriptor.getDefaultType(); - trace.recordReferenceResolution(expression.getTargetLabel(), classDescriptor); + trace.recordReferenceResolution(targetLabel, classDescriptor); + trace.recordReferenceResolution(expression.getThisReference(), classDescriptor); } else { throw new UnsupportedOperationException(); // TODO } } else if (size == 0) { - trace.getErrorHandler().unresolvedReference(expression.getTargetLabel()); + trace.getErrorHandler().unresolvedReference(targetLabel); } else { - JetSimpleNameExpression labelElement = expression.getTargetLabel(); - assert labelElement != null; - trace.getErrorHandler().genericError(labelElement.getNode(), "Ambiguous label"); + trace.getErrorHandler().genericError(targetLabel.getNode(), "Ambiguous label"); } } else { thisType = scope.getThisType(); + + DeclarationDescriptor declarationDescriptorForUnqualifiedThis = scope.getDeclarationDescriptorForUnqualifiedThis(); + if (declarationDescriptorForUnqualifiedThis != null) { + trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptorForUnqualifiedThis); + } } if (thisType != null) { @@ -989,6 +995,9 @@ public class JetTypeInferrer { } else { result = thisType; } + if (result != null) { + trace.recordExpressionType(expression.getThisReference(), result); + } } } } @@ -1407,9 +1416,9 @@ public class JetTypeInferrer { else { result = selectorReturnType; } -// if (selectorExpression != null && result != null) { -// trace.recordExpressionType(selectorExpression, result); -// } + if (selectorExpression != null && result != null) { + trace.recordExpressionType(selectorExpression, result); + } } } diff --git a/idea/testData/psi/AnnotatedExpressions.txt b/idea/testData/psi/AnnotatedExpressions.txt index 3ab88e58209..43a7ec5594f 100644 --- a/idea/testData/psi/AnnotatedExpressions.txt +++ b/idea/testData/psi/AnnotatedExpressions.txt @@ -38,6 +38,7 @@ JetFile: AnnotatedExpressions.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/Labels.txt b/idea/testData/psi/Labels.txt index ab9aff54e8f..8f84afa425d 100644 --- a/idea/testData/psi/Labels.txt +++ b/idea/testData/psi/Labels.txt @@ -385,28 +385,33 @@ JetFile: Labels.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace('\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') LABEL_QUALIFIER LABEL_REFERENCE PsiElement(AT)('@') PsiWhiteSpace('\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') LABEL_QUALIFIER LABEL_REFERENCE PsiElement(LABEL_IDENTIFIER)('@a') PsiWhiteSpace('\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') LABEL_QUALIFIER LABEL_REFERENCE PsiElement(ATAT)('@@') PsiWhiteSpace('\n\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(LT)('<') TYPE_REFERENCE USER_TYPE @@ -415,7 +420,8 @@ JetFile: Labels.jet PsiElement(GT)('>') PsiWhiteSpace('\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') LABEL_QUALIFIER LABEL_REFERENCE PsiElement(AT)('@') @@ -427,7 +433,8 @@ JetFile: Labels.jet PsiElement(GT)('>') PsiWhiteSpace('\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') LABEL_QUALIFIER LABEL_REFERENCE PsiElement(LABEL_IDENTIFIER)('@a') @@ -439,7 +446,8 @@ JetFile: Labels.jet PsiElement(GT)('>') PsiWhiteSpace('\n ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') LABEL_QUALIFIER LABEL_REFERENCE PsiElement(ATAT)('@@') diff --git a/idea/testData/psi/Properties.txt b/idea/testData/psi/Properties.txt index cada06eaa00..8011b4cd5db 100644 --- a/idea/testData/psi/Properties.txt +++ b/idea/testData/psi/Properties.txt @@ -768,7 +768,8 @@ JetFile: Properties.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('size') diff --git a/idea/testData/psi/SimpleExpressions.txt b/idea/testData/psi/SimpleExpressions.txt index 97f525a2ff6..6e5c056148c 100644 --- a/idea/testData/psi/SimpleExpressions.txt +++ b/idea/testData/psi/SimpleExpressions.txt @@ -261,7 +261,8 @@ JetFile: SimpleExpressions.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(COMMA)(',') PsiWhiteSpace('\n ') VALUE_PARAMETER @@ -277,7 +278,8 @@ JetFile: SimpleExpressions.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(LT)('<') TYPE_REFERENCE USER_TYPE diff --git a/idea/testData/psi/examples/BinaryTree.txt b/idea/testData/psi/examples/BinaryTree.txt index a550a3bfef3..6b67228916b 100644 --- a/idea/testData/psi/examples/BinaryTree.txt +++ b/idea/testData/psi/examples/BinaryTree.txt @@ -180,7 +180,8 @@ JetFile: BinaryTree.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('compare') @@ -286,7 +287,8 @@ JetFile: BinaryTree.jet PsiElement(LPAR)('(') VALUE_ARGUMENT THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(COMMA)(',') PsiWhiteSpace(' ') VALUE_ARGUMENT @@ -1897,7 +1899,8 @@ JetFile: BinaryTree.jet PsiElement(IDENTIFIER)('BinaryTree') PsiElement(DOT)('.') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('version') @@ -2475,7 +2478,8 @@ JetFile: BinaryTree.jet PsiElement(IDENTIFIER)('BinaryTree') PsiElement(DOT)('.') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('version') @@ -2520,7 +2524,8 @@ JetFile: BinaryTree.jet PsiElement(IDENTIFIER)('BinaryTree') PsiElement(DOT)('.') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('version') diff --git a/idea/testData/psi/examples/BitArith.txt b/idea/testData/psi/examples/BitArith.txt index 97a62fdee77..31041265802 100644 --- a/idea/testData/psi/examples/BitArith.txt +++ b/idea/testData/psi/examples/BitArith.txt @@ -499,7 +499,8 @@ JetFile: BitArith.jet BINARY_EXPRESSION BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(IDENTIFIER)('and') diff --git a/idea/testData/psi/examples/PolymorphicClassObjects.txt b/idea/testData/psi/examples/PolymorphicClassObjects.txt index af916c0e519..0f6b406c866 100644 --- a/idea/testData/psi/examples/PolymorphicClassObjects.txt +++ b/idea/testData/psi/examples/PolymorphicClassObjects.txt @@ -363,7 +363,8 @@ JetFile: PolymorphicClassObjects.jet PsiWhiteSpace(' ') LOOP_RANGE THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(RPAR)(')') PsiWhiteSpace(' ') BODY diff --git a/idea/testData/psi/examples/UnionFind.txt b/idea/testData/psi/examples/UnionFind.txt index 2bdfe60746e..e145b6423f5 100644 --- a/idea/testData/psi/examples/UnionFind.txt +++ b/idea/testData/psi/examples/UnionFind.txt @@ -388,7 +388,8 @@ JetFile: UnionFind.jet BINARY_EXPRESSION BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(PERC)('%') diff --git a/idea/testData/psi/examples/collections/ArrayList.txt b/idea/testData/psi/examples/collections/ArrayList.txt index eb757b554b7..997df3f7c86 100644 --- a/idea/testData/psi/examples/collections/ArrayList.txt +++ b/idea/testData/psi/examples/collections/ArrayList.txt @@ -350,7 +350,8 @@ JetFile: ArrayList.jet PsiElement(IDENTIFIER)('ArrayList') PsiElement(DOT)('.') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') CALL_EXPRESSION REFERENCE_EXPRESSION diff --git a/idea/testData/psi/examples/collections/HashMap.txt b/idea/testData/psi/examples/collections/HashMap.txt index a4ff6f08621..e44b6f58ef9 100644 --- a/idea/testData/psi/examples/collections/HashMap.txt +++ b/idea/testData/psi/examples/collections/HashMap.txt @@ -44,7 +44,8 @@ JetFile: HashMap.jet PsiElement(LPAR)('(') BINARY_WITH_TYPE THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(as)('as') @@ -138,7 +139,8 @@ JetFile: HashMap.jet PsiElement(LPAR)('(') BINARY_WITH_TYPE THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(as)('as') @@ -373,7 +375,8 @@ JetFile: HashMap.jet PsiElement(LPAR)('(') VALUE_ARGUMENT THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') CLASS diff --git a/idea/testData/psi/examples/collections/List.txt b/idea/testData/psi/examples/collections/List.txt index 970e2fbc219..61a1d9fcd16 100644 --- a/idea/testData/psi/examples/collections/List.txt +++ b/idea/testData/psi/examples/collections/List.txt @@ -202,7 +202,8 @@ JetFile: List.jet PsiWhiteSpace(' ') BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(EQEQ)('==') @@ -256,7 +257,8 @@ JetFile: List.jet PsiElement(IDENTIFIER)('List') PsiElement(DOT)('.') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace('\n\n ') PROPERTY MODIFIER_LIST diff --git a/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt b/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt index 2db7592495f..9eea2a5f1cf 100644 --- a/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt +++ b/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt @@ -138,7 +138,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('compare') @@ -152,7 +153,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('data') @@ -254,7 +256,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('compare') @@ -268,7 +271,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('data') @@ -297,7 +301,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('data') @@ -343,7 +348,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('comparator') @@ -393,7 +399,8 @@ JetFile: BinaryHeap.jet CONDITION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('isEmpty') @@ -942,7 +949,8 @@ JetFile: BinaryHeap.jet PsiElement(LPAR)('(') BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(MINUS)('-') @@ -979,7 +987,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(MUL)('*') @@ -1015,7 +1024,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(MUL)('*') @@ -1067,7 +1077,8 @@ JetFile: BinaryHeap.jet INDICES PsiElement(LBRACKET)('[') THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n ') PROPERTY_ACCESSOR @@ -1117,7 +1128,8 @@ JetFile: BinaryHeap.jet PsiElement(LPAR)('(') BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(LT)('<') @@ -1137,7 +1149,8 @@ JetFile: BinaryHeap.jet PsiElement(LPAR)('(') BINARY_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(GTEQ)('>=') @@ -1209,7 +1222,8 @@ JetFile: BinaryHeap.jet PsiElement(LPAR)('(') VALUE_ARGUMENT THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(COMMA)(',') PsiWhiteSpace(' ') VALUE_ARGUMENT @@ -1274,7 +1288,8 @@ JetFile: BinaryHeap.jet PsiWhiteSpace(' ') ARRAY_ACCESS_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') INDICES PsiElement(LBRACKET)('[') REFERENCE_EXPRESSION @@ -1284,7 +1299,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION ARRAY_ACCESS_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') INDICES PsiElement(LBRACKET)('[') REFERENCE_EXPRESSION @@ -1296,7 +1312,8 @@ JetFile: BinaryHeap.jet PsiWhiteSpace(' ') ARRAY_ACCESS_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') INDICES PsiElement(LBRACKET)('[') REFERENCE_EXPRESSION @@ -1306,7 +1323,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION ARRAY_ACCESS_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') INDICES PsiElement(LBRACKET)('[') REFERENCE_EXPRESSION @@ -1356,7 +1374,8 @@ JetFile: BinaryHeap.jet BINARY_EXPRESSION DOT_QUALIFIED_EXPRESSION THIS_EXPRESSION - PsiElement(this)('this') + REFERENCE_EXPRESSION + PsiElement(this)('this') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('size') diff --git a/idea/testData/resolve/Classifiers.jet b/idea/testData/resolve/Classifiers.jet index d9dfa80d85e..026ba3a96e1 100644 --- a/idea/testData/resolve/Classifiers.jet +++ b/idea/testData/resolve/Classifiers.jet @@ -2,8 +2,13 @@ namespace qualified_this { ~qtA~class A(val a:Int) { ~qtB~class B() { - val x = this`qtB`@B - val y = this`qtA`@A + val x = `qtB`this`qtB`@B + val y = `qtA`this`qtA`@A + val z = `qtB`this + ~xx~val Int.xx = `xx`this : Int + ~xx()~fun Int.xx() { + `xx()`this : Int + } } } } diff --git a/idea/tests/org/jetbrains/jet/JetTestUtils.java b/idea/tests/org/jetbrains/jet/JetTestUtils.java index 7bc454cc2d0..bc6651ad18c 100644 --- a/idea/tests/org/jetbrains/jet/JetTestUtils.java +++ b/idea/tests/org/jetbrains/jet/JetTestUtils.java @@ -178,6 +178,7 @@ public class JetTestUtils { public Collection getDiagnostics() { throw new UnsupportedOperationException(); // TODO } + }; } };