Stub for annotations: write shortName instead getText

This commit is contained in:
Natalia.Ukhorskaya
2012-10-04 13:57:44 +04:00
parent 8e89cf40b7
commit a5b43cbbae
6 changed files with 45 additions and 15 deletions
@@ -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<? extends PsiElement> getJetAnnotationCandidates(final PsiClass annClass, final SearchScope useScope) {
return ApplicationManager.getApplication().runReadAction(new Computable<Collection<? extends PsiElement>>() {
@Override
@@ -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());
}
}
@@ -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");
}