diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/persistence/annotations.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/persistence/annotations.xml new file mode 100644 index 000000000000..ae9ad0f65b75 --- /dev/null +++ b/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/persistence/annotations.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/lib/persistence/Test.java b/java/java-tests/testData/codeInsight/externalAnnotations/lib/persistence/Test.java new file mode 100644 index 000000000000..461e3747f6eb --- /dev/null +++ b/java/java-tests/testData/codeInsight/externalAnnotations/lib/persistence/Test.java @@ -0,0 +1,9 @@ +package persistence; + +import java.util.*; + +class Test { + String getString(Map.Entry entry) { + return null; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java index a227292ceaae..7d86c711b0e5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java @@ -21,9 +21,7 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiModifierListOwner; +import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.PsiTestUtil; @@ -176,4 +174,23 @@ public class AddAnnotationFixTest extends UsefulTestCase { assertFalse(deannotateFix.isAvailable(project, editor, file)); } + + public void testReadingOldPersistenceFormat() throws Throwable { + addLibrary(); + myFixture.configureByFiles("content/anno/persistence/annotations.xml"); + myFixture.configureByFiles("lib/persistence/Test.java"); + + + ExternalAnnotationsManager manager = ExternalAnnotationsManager.getInstance(myFixture.getProject()); + PsiMethod method = ((PsiJavaFile)myFixture.getFile()).getClasses()[0].getMethods()[0]; + PsiParameter parameter = method.getParameterList().getParameters()[0]; + + assertNotNull(manager.findExternalAnnotation(method, AnnotationUtil.NULLABLE)); + assertNotNull(manager.findExternalAnnotation(method, AnnotationUtil.NLS)); + assertEquals(2, manager.findExternalAnnotations(method).length); + + assertNotNull(manager.findExternalAnnotation(parameter, AnnotationUtil.NOT_NULL)); + assertNotNull(manager.findExternalAnnotation(parameter, AnnotationUtil.NON_NLS)); + assertEquals(2, manager.findExternalAnnotations(parameter).length); + } }