23 * have any questions. |
23 * have any questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javadoc; |
26 package com.sun.tools.javadoc; |
27 |
27 |
|
28 import java.util.EnumSet; |
|
29 import javax.tools.JavaFileObject; |
|
30 |
28 import com.sun.tools.javac.code.Symbol.PackageSymbol; |
31 import com.sun.tools.javac.code.Symbol.PackageSymbol; |
29 import com.sun.tools.javac.file.JavacFileManager; |
|
30 import com.sun.tools.javac.file.ZipArchive.ZipFileObject; |
|
31 import com.sun.tools.javac.file.Old199; |
|
32 import com.sun.tools.javac.file.ZipFileIndexArchive; |
|
33 import com.sun.tools.javac.jvm.ClassReader; |
32 import com.sun.tools.javac.jvm.ClassReader; |
34 import com.sun.tools.javac.util.Context; |
33 import com.sun.tools.javac.util.Context; |
35 |
|
36 import java.io.File; |
|
37 import java.util.EnumSet; |
|
38 import javax.tools.JavaFileObject; |
|
39 |
34 |
40 /** Javadoc uses an extended class reader that records package.html entries |
35 /** Javadoc uses an extended class reader that records package.html entries |
41 * @author Neal Gafter |
36 * @author Neal Gafter |
42 */ |
37 */ |
43 class JavadocClassReader extends ClassReader { |
38 class JavadocClassReader extends ClassReader { |
80 /** |
75 /** |
81 * Override extraFileActions to check for package documentation |
76 * Override extraFileActions to check for package documentation |
82 */ |
77 */ |
83 @Override |
78 @Override |
84 protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) { |
79 protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) { |
85 CharSequence fileName = Old199.getName(fo); |
80 if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML)) |
86 if (docenv != null && fileName.equals("package.html")) { |
81 docenv.getPackageDoc(pack).setDocPath(fo); |
87 if (fo instanceof ZipFileObject) { |
|
88 ZipFileObject zfo = (ZipFileObject) fo; |
|
89 String zipName = zfo.getZipName(); |
|
90 String entryName = zfo.getZipEntryName(); |
|
91 int lastSep = entryName.lastIndexOf("/"); |
|
92 String classPathName = entryName.substring(0, lastSep + 1); |
|
93 docenv.getPackageDoc(pack).setDocPath(zipName, classPathName); |
|
94 } |
|
95 else if (fo instanceof ZipFileIndexArchive.ZipFileIndexFileObject) { |
|
96 ZipFileIndexArchive.ZipFileIndexFileObject zfo = (ZipFileIndexArchive.ZipFileIndexFileObject) fo; |
|
97 String zipName = zfo.getZipName(); |
|
98 String entryName = zfo.getZipEntryName(); |
|
99 if (File.separatorChar != '/') { |
|
100 entryName = entryName.replace(File.separatorChar, '/'); |
|
101 } |
|
102 |
|
103 int lastSep = entryName.lastIndexOf("/"); |
|
104 String classPathName = entryName.substring(0, lastSep + 1); |
|
105 docenv.getPackageDoc(pack).setDocPath(zipName, classPathName); |
|
106 } |
|
107 else { |
|
108 File fileDir = new File(Old199.getPath(fo)).getParentFile(); |
|
109 docenv.getPackageDoc(pack).setDocPath(fileDir.getAbsolutePath()); |
|
110 } |
|
111 } |
|
112 } |
82 } |
113 } |
83 } |