diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationImpl.java index 3cdc7dfaa82b..e42d4b8d459b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,23 +44,27 @@ public class ClsAnnotationImpl extends ClsRepositoryPsiElement 0 ? annotationText.substring(1, index) : annotationText.substring(1); + return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, refText); } }; myParameterList = new AtomicNotNullLazyValue() { @NotNull @Override protected ClsAnnotationParameterListImpl compute() { - PsiAnnotationParameterList paramList = PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class); - return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, paramList.getAttributes()); + PsiNameValuePair[] attrs = getStub().getText().indexOf('(') > 0 + ? PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class).getAttributes() + : PsiNameValuePair.EMPTY_ARRAY; + return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, attrs); } }; } @Override public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) { - buffer.append("@").append(myReferenceElement.getValue().getCanonicalText()); + buffer.append('@').append(myReferenceElement.getValue().getCanonicalText()); appendText(getParameterList(), indentLevel, buffer); } diff --git a/java/java-tests/testData/psi/cls/tree/KeywordAnnotatedClass.class b/java/java-tests/testData/psi/cls/tree/KeywordAnnotatedClass.class new file mode 100644 index 000000000000..7dbe64039001 Binary files /dev/null and b/java/java-tests/testData/psi/cls/tree/KeywordAnnotatedClass.class differ diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsPsiTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsPsiTest.java new file mode 100644 index 000000000000..2cd4c2c4bd61 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/ClsPsiTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi; + +import com.intellij.openapi.application.ex.PathManagerEx; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.impl.compiled.ClsFileImpl; +import com.intellij.testFramework.LightIdeaTestCase; + +public class ClsPsiTest extends LightIdeaTestCase { + public void testKeywordAnnotatedClass() { + PsiModifierList modList = getFile().getClasses()[0].getModifierList(); + assertNotNull(modList); + assertEquals("@pkg.native", modList.getAnnotations()[0].getText()); + } + + private PsiJavaFile getFile() { + return getFile(getTestName(false)); + } + + private static PsiJavaFile getFile(String name) { + String path = PathManagerEx.getTestDataPath() + "/psi/cls/tree/" + name + ".class"; + VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); + assertNotNull(path, file); + PsiFile clsFile = PsiManager.getInstance(getProject()).findFile(file); + assertTrue(String.valueOf(clsFile), clsFile instanceof ClsFileImpl); + return (PsiJavaFile)clsFile; + } +} \ No newline at end of file