diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetAnnotationStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetAnnotationStub.java index aafbc4ead5a..2a975505f84 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetAnnotationStub.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetAnnotationStub.java @@ -20,5 +20,5 @@ import com.intellij.psi.stubs.StubElement; import org.jetbrains.jet.lang.psi.JetAnnotationEntry; public interface PsiJetAnnotationStub extends StubElement { - String getText(); + String getShortName(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetAnnotationElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetAnnotationElementType.java index 4542df78241..34a2ef316c4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetAnnotationElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetAnnotationElementType.java @@ -24,7 +24,7 @@ import com.intellij.psi.stubs.StubOutputStream; import com.intellij.util.io.StringRef; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetAnnotationEntry; +import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.stubs.PsiJetAnnotationStub; import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetAnnotationStubImpl; @@ -48,12 +48,23 @@ public class JetAnnotationElementType extends JetStubElementType implements PsiJetAnnotationStub { - private final StringRef text; + private final StringRef shortName; - public PsiJetAnnotationStubImpl(StubElement parent, IStubElementType elementType, String text) { - this(parent, elementType, StringRef.fromString(text)); + public PsiJetAnnotationStubImpl(StubElement parent, IStubElementType elementType, @NotNull String shortName) { + this(parent, elementType, StringRef.fromString(shortName)); } - public PsiJetAnnotationStubImpl(StubElement parent, IStubElementType elementType, StringRef text) { + public PsiJetAnnotationStubImpl(StubElement parent, IStubElementType elementType, StringRef shortName) { super(parent, elementType); - this.text = text; + this.shortName = shortName; } @Override - public String getText() { - return text.getString(); + public String getShortName() { + return shortName.getString(); } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("PsiJetAnnotationStubImpl["); - builder.append("text=").append(getText()); + builder.append("shortName=").append(getShortName()); builder.append("]"); return builder.toString(); } diff --git a/idea/src/org/jetbrains/jet/plugin/search/KotlinAnnotatedElementsSearcher.java b/idea/src/org/jetbrains/jet/plugin/search/KotlinAnnotatedElementsSearcher.java index bb7bcbd80e0..d61b3f06fe1 100644 --- a/idea/src/org/jetbrains/jet/plugin/search/KotlinAnnotatedElementsSearcher.java +++ b/idea/src/org/jetbrains/jet/plugin/search/KotlinAnnotatedElementsSearcher.java @@ -95,6 +95,7 @@ public class KotlinAnnotatedElementsSearcher extends AnnotatedElementsSearcher { return true; } + /* Return all elements annotated with given annotation name. Aliases don't work now. */ private static Collection getJetAnnotationCandidates(final PsiClass annClass, final SearchScope useScope) { return ApplicationManager.getApplication().runReadAction(new Computable>() { @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java b/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java index a7232793d7c..bb303807ae7 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java @@ -91,6 +91,6 @@ public class StubIndexServiceImpl implements StubIndexService { @Override public void indexAnnotation(PsiJetAnnotationStub stub, IndexSink sink) { - sink.occurrence(JetIndexKeys.ANNOTATIONS_KEY, stub.getText()); + sink.occurrence(JetIndexKeys.ANNOTATIONS_KEY, stub.getShortName()); } } diff --git a/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java b/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java index 4d069e8d66f..33fa5101ded 100644 --- a/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java @@ -168,7 +168,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase { doBuildTest("Deprecated class Test {}", "PsiJetFileStubImpl[package=]\n" + " CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[text=Deprecated]\n" + + " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + " TYPE_PARAMETER_LIST:PsiJetTypeParameterListStubImpl\n"); } @@ -176,7 +176,24 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase { doBuildTest("Deprecated fun foo() {}", "PsiJetFileStubImpl[package=]\n" + " FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[text=Deprecated]\n" + + " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + + " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); + } + + public void testQualifiedAnnotationOnFunction() { + doBuildTest("java.lang.Deprecated fun foo() {}", + "PsiJetFileStubImpl[package=]\n" + + " FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" + + " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + + " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); + } + + public void testManyAnnotationsOnFunction() { + doBuildTest("[Deprecated Override] fun foo() {}", + "PsiJetFileStubImpl[package=]\n" + + " FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" + + " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + + " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Override]\n" + " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); }