mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
6794582: javadoc should read files using a FileManager
Reviewed-by: darcy, bpatel
This commit is contained in:
parent
19b769a375
commit
981f025a85
13 changed files with 301 additions and 225 deletions
|
@ -26,17 +26,16 @@
|
|||
package com.sun.tools.javadoc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Position;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* This class holds the information from one run of javadoc.
|
||||
|
@ -308,10 +307,13 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
|||
* Return the path of the overview file and null if it does not exist.
|
||||
* @return the path of the overview file and null if it does not exist.
|
||||
*/
|
||||
private String getOverviewPath() {
|
||||
private JavaFileObject getOverviewPath() {
|
||||
for (String[] opt : options) {
|
||||
if (opt[0].equals("-overview")) {
|
||||
return opt[1];
|
||||
if (env.fileManager instanceof StandardJavaFileManager) {
|
||||
StandardJavaFileManager fm = (StandardJavaFileManager) env.fileManager;
|
||||
return fm.getJavaFileObjects(opt[1]).iterator().next();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -323,7 +325,7 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
|||
protected String documentation() {
|
||||
if (documentation == null) {
|
||||
int cnt = options.length();
|
||||
String overviewPath = getOverviewPath();
|
||||
JavaFileObject overviewPath = getOverviewPath();
|
||||
if (overviewPath == null) {
|
||||
// no doc file to be had
|
||||
documentation = "";
|
||||
|
@ -331,11 +333,11 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
|||
// read from file
|
||||
try {
|
||||
documentation = readHTMLDocumentation(
|
||||
new FileInputStream(overviewPath),
|
||||
overviewPath.openInputStream(),
|
||||
overviewPath);
|
||||
} catch (IOException exc) {
|
||||
documentation = "";
|
||||
env.error(null, "javadoc.File_Read_Error", overviewPath);
|
||||
env.error(null, "javadoc.File_Read_Error", overviewPath.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +349,7 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
|||
* no position is available.
|
||||
*/
|
||||
public SourcePosition position() {
|
||||
String path;
|
||||
JavaFileObject path;
|
||||
return ((path = getOverviewPath()) == null) ?
|
||||
null :
|
||||
SourcePositionImpl.make(path, Position.NOPOS, null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue