@@ -60,7 +60,9 @@ public enum AnnotationFileType {
6060 /** Ajava file being parsed as if it is a stub file. */
6161 AJAVA_AS_STUB ,
6262 /** Ajava file provided on command line. */
63- AJAVA ;
63+ AJAVA ,
64+ /** External annotations (IntelliJ annotations.xml format). */
65+ EXTERNAL_ANNOTATIONS ;
6466
6567 /**
6668 * Returns true if this represents a stub file.
@@ -70,7 +72,7 @@ public enum AnnotationFileType {
7072 public boolean isStub () {
7173 return switch (this ) {
7274 case JDK_STUB , BUILTIN_STUB , COMMAND_LINE_STUB , AJAVA_AS_STUB -> true ;
73- case AJAVA -> false ;
75+ case AJAVA , EXTERNAL_ANNOTATIONS -> false ;
7476 default -> throw new BugInCF ("unhandled case " + this );
7577 };
7678 }
@@ -83,7 +85,7 @@ public boolean isStub() {
8385 public boolean isBuiltIn () {
8486 return switch (this ) {
8587 case JDK_STUB , BUILTIN_STUB -> true ;
86- case COMMAND_LINE_STUB , AJAVA_AS_STUB , AJAVA -> false ;
88+ case COMMAND_LINE_STUB , AJAVA_AS_STUB , AJAVA , EXTERNAL_ANNOTATIONS -> false ;
8789 default -> throw new BugInCF ("unhandled case " + this );
8890 };
8991 }
@@ -96,7 +98,7 @@ public boolean isBuiltIn() {
9698 public boolean isCommandLine () {
9799 return switch (this ) {
98100 case JDK_STUB , BUILTIN_STUB -> false ;
99- case COMMAND_LINE_STUB , AJAVA_AS_STUB , AJAVA -> true ;
101+ case COMMAND_LINE_STUB , AJAVA_AS_STUB , AJAVA , EXTERNAL_ANNOTATIONS -> true ;
100102 default -> throw new BugInCF ("unhandled case " + this );
101103 };
102104 }
@@ -400,11 +402,14 @@ private static boolean isAnnotationFile(File f, AnnotationFileType fileType) {
400402 * otherwise
401403 */
402404 private static boolean isAnnotationFile (String path , AnnotationFileType fileType ) {
405+ if (fileType == AnnotationFileType .EXTERNAL_ANNOTATIONS ) {
406+ return path .endsWith ("annotations.xml" );
407+ }
403408 return path .endsWith (fileType .isStub () ? ".astub" : ".ajava" );
404409 }
405410
406- private static boolean isJar (File f ) {
407- return f .isFile () && f .getName ().endsWith (".jar" );
411+ private static boolean isJarOrZip (File f ) {
412+ return f .isFile () && ( f .getName ().endsWith (".jar" ) || f . getName (). endsWith ( ".zip" ) );
408413 }
409414
410415 /**
@@ -427,12 +432,12 @@ private static void addAnnotationFilesToList(
427432 File location , List <AnnotationFileResource > resources , AnnotationFileType fileType ) {
428433 if (isAnnotationFile (location , fileType )) {
429434 resources .add (new FileAnnotationFileResource (location ));
430- } else if (isJar (location )) {
435+ } else if (isJarOrZip (location )) {
431436 JarFile file ;
432437 try {
433438 file = new JarFile (location );
434439 } catch (IOException e ) {
435- System .err .println ("AnnotationFileUtil: could not process JAR file : " + location );
440+ System .err .println ("AnnotationFileUtil: could not process archive : " + location );
436441 return ;
437442 }
438443 Enumeration <JarEntry > entries = file .entries ();
0 commit comments