47 |
47 |
48 import com.sun.tools.javac.code.ClassFinder; |
48 import com.sun.tools.javac.code.ClassFinder; |
49 import com.sun.tools.javac.code.Symbol.Completer; |
49 import com.sun.tools.javac.code.Symbol.Completer; |
50 import com.sun.tools.javac.code.Symbol.CompletionFailure; |
50 import com.sun.tools.javac.code.Symbol.CompletionFailure; |
51 import com.sun.tools.javac.code.Symbol.ModuleSymbol; |
51 import com.sun.tools.javac.code.Symbol.ModuleSymbol; |
|
52 import com.sun.tools.javac.code.Symbol.PackageSymbol; |
52 import com.sun.tools.javac.comp.Enter; |
53 import com.sun.tools.javac.comp.Enter; |
53 import com.sun.tools.javac.tree.JCTree; |
54 import com.sun.tools.javac.tree.JCTree; |
54 import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
55 import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
55 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
56 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
56 import com.sun.tools.javac.util.Abort; |
57 import com.sun.tools.javac.util.Abort; |
57 import com.sun.tools.javac.util.Context; |
58 import com.sun.tools.javac.util.Context; |
58 import com.sun.tools.javac.util.ListBuffer; |
59 import com.sun.tools.javac.util.ListBuffer; |
|
60 import com.sun.tools.javac.util.Name; |
59 import com.sun.tools.javac.util.Position; |
61 import com.sun.tools.javac.util.Position; |
60 import jdk.javadoc.doclet.DocletEnvironment; |
62 import jdk.javadoc.doclet.DocletEnvironment; |
61 |
63 |
62 |
64 |
63 /** |
65 /** |
185 } |
187 } |
186 } |
188 } |
187 |
189 |
188 // Parse file objects provide via the DocumentationTool API |
190 // Parse file objects provide via the DocumentationTool API |
189 parse(fileObjects, classTrees, true); |
191 parse(fileObjects, classTrees, true); |
190 modules.enter(classTrees.toList(), null); |
192 |
191 |
193 modules.initModules(classTrees.toList(), Collections.emptySet(), Collections.emptySet()); |
192 syms.unnamedModule.complete(); // TEMP to force reading all named modules |
|
193 |
194 |
194 // Build up the complete list of any packages to be documented |
195 // Build up the complete list of any packages to be documented |
195 Location location = modules.multiModuleMode ? StandardLocation.MODULE_SOURCE_PATH |
196 Location location = modules.multiModuleMode ? StandardLocation.MODULE_SOURCE_PATH |
196 : toolEnv.fileManager.hasLocation(StandardLocation.SOURCE_PATH) ? StandardLocation.SOURCE_PATH |
197 : toolEnv.fileManager.hasLocation(StandardLocation.SOURCE_PATH) ? StandardLocation.SOURCE_PATH |
197 : StandardLocation.CLASS_PATH; |
198 : StandardLocation.CLASS_PATH; |
392 } |
393 } |
393 |
394 |
394 private Location getLocation(String packageName) throws IOException { |
395 private Location getLocation(String packageName) throws IOException { |
395 if (location == StandardLocation.MODULE_SOURCE_PATH) { |
396 if (location == StandardLocation.MODULE_SOURCE_PATH) { |
396 // TODO: handle invalid results better. |
397 // TODO: handle invalid results better. |
397 ModuleSymbol msym = syms.inferModule(names.fromString(packageName)); |
398 Name pack = names.fromString(packageName); |
398 if (msym == null) { |
399 |
399 return null; |
400 for (ModuleSymbol msym : modules.allModules()) { |
|
401 PackageSymbol p = syms.getPackage(msym, pack); |
|
402 if (p != null && !p.members().isEmpty()) { |
|
403 return fm.getModuleLocation(location, msym.name.toString()); |
|
404 } |
400 } |
405 } |
401 return fm.getModuleLocation(location, msym.name.toString()); |
406 |
|
407 return null; |
402 } else { |
408 } else { |
403 return location; |
409 return location; |
404 } |
410 } |
405 } |
411 } |
406 |
412 |