remove reporter diagnostic / fix class graph / make javase api 9 default / fix package-list and element-list api fetch

This commit is contained in:
Laurent SCHOELENS 2023-03-27 14:52:04 +02:00
parent 27d7821666
commit de056154bd
6 changed files with 54 additions and 67 deletions

30
pom.xml
View File

@ -110,19 +110,19 @@
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version> <version>3.5.0</version>
<configuration> <configuration>
<tags> <tags>
<tag> <tag>
<name>depend</name> <name>depend</name>
<placement>X</placement> <placement>X</placement>
</tag> </tag>
<tag> <tag>
<name>hidden</name> <name>hidden</name>
<placement>X</placement> <placement>X</placement>
</tag> </tag>
<tag> <tag>
<name>opt</name> <name>opt</name>
<placement>X</placement> <placement>X</placement>
</tag> </tag>
</tags> </tags>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet> <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletPath>${project.build.directory}${file.separator}${project.build.finalName}.jar</docletPath> <docletPath>${project.build.directory}${file.separator}${project.build.finalName}.jar</docletPath>
@ -134,12 +134,10 @@
<option>--hide="java.*"</option> <option>--hide="java.*"</option>
<option>--collpackages=</option> <option>--collpackages=</option>
<option>-qualify</option> <option>-qualify</option>
<option>-all</option>
<option>-postfixpackage</option> <option>-postfixpackage</option>
<option>-nodefontsize 9</option> <option>-nodefontsize 9</option>
<option>-nodefontpackagesize 7</option> <option>-nodefontpackagesize 7</option>
<option>--link="https://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/"</option> <option>--link="https://docs.oracle.com/javase/9/docs/api/"</option>
<option>--link="https://download.oracle.com/javase/7/docs/api/"</option>
</additionalOptions> </additionalOptions>
<detectJavaApiLink>false</detectJavaApiLink> <detectJavaApiLink>false</detectJavaApiLink>
<useStandardDocletOptions>true</useStandardDocletOptions> <useStandardDocletOptions>true</useStandardDocletOptions>

View File

@ -499,8 +499,9 @@ class ClassGraph {
} }
} }
externalTableEnd(); externalTableEnd();
if (url != null) if (url != null) {
w.print(", URL=\"" + url + "\""); w.print(", URL=\"" + url + "\"");
}
nodeProperties(opt); nodeProperties(opt);
// If needed, add a note for this node // If needed, add a note for this node
@ -672,8 +673,9 @@ class ClassGraph {
} }
// Handle missing classes: // Handle missing classes:
Options opt = optionProvider.getOptionsFor(className); Options opt = optionProvider.getOptionsFor(className);
if (opt.matchesHideExpression(className)) if (opt.matchesHideExpression(className)) {
continue; continue;
}
w.println(linePrefix + "// " + className); w.println(linePrefix + "// " + className);
w.print(linePrefix + info.name + "[label="); w.print(linePrefix + info.name + "[label=");
externalTableStart(opt, className, classToUrl(className)); externalTableStart(opt, className, classToUrl(className));
@ -731,7 +733,7 @@ class ClassGraph {
} }
// if source and dest are not already linked, add a dependency // if source and dest are not already linked, add a dependency
RelationPattern rp = getClassInfo(c, true).getRelation(fri.cd.toString()); RelationPattern rp = getClassInfo(c, true).getRelation(fri.cd.getQualifiedName());
if (rp == null) { if (rp == null) {
String destAdornment = fri.multiple ? "*" : ""; String destAdornment = fri.multiple ? "*" : "";
relation(opt, opt.inferRelationshipType, c, fri.cd, "", "", destAdornment); relation(opt, opt.inferRelationshipType, c, fri.cd, "", "", destAdornment);
@ -828,7 +830,7 @@ class ClassGraph {
} }
// if source and dest are not already linked, add a dependency // if source and dest are not already linked, add a dependency
RelationPattern rp = getClassInfo(c, true).getRelation(fc.toString()); RelationPattern rp = getClassInfo(c, true).getRelation(fc.getQualifiedName());
if (rp == null || rp.matchesOne(new RelationPattern(RelationDirection.OUT))) { if (rp == null || rp.matchesOne(new RelationPattern(RelationDirection.OUT))) {
relation(opt, RelationType.DEPEND, c, fc, "", "", ""); relation(opt, RelationType.DEPEND, c, fc, "", "", "");
} }

View File

@ -44,7 +44,7 @@ class ClassInfo {
* classes linked with a bi-directional relation , and the ones referred by a * classes linked with a bi-directional relation , and the ones referred by a
* directed relation * directed relation
*/ */
Map<Name, RelationPattern> relatedClasses = new HashMap<>(); Map<String, RelationPattern> relatedClasses = new HashMap<>();
ClassInfo(boolean h) { ClassInfo(boolean h) {
hidden = h; hidden = h;
@ -53,16 +53,16 @@ class ClassInfo {
} }
public void addRelation(Name dest, RelationType rt, RelationDirection d) { public void addRelation(Name dest, RelationType rt, RelationDirection d) {
RelationPattern ri = relatedClasses.get(dest); RelationPattern ri = relatedClasses.get(dest.toString());
if (ri == null) { if (ri == null) {
ri = new RelationPattern(RelationDirection.NONE); ri = new RelationPattern(RelationDirection.NONE);
relatedClasses.put(dest, ri); relatedClasses.put(dest.toString(), ri);
} }
ri.addRelation(rt, d); ri.addRelation(rt, d);
} }
public RelationPattern getRelation(CharSequence dest) { public RelationPattern getRelation(CharSequence dest) {
return relatedClasses.get(dest); return relatedClasses.get(dest.toString());
} }
/** Start numbering from zero. */ /** Start numbering from zero. */

View File

@ -61,7 +61,7 @@ public class ContextView implements OptionProvider {
this.centerOptions.nodeFillColor = "lemonChiffon"; this.centerOptions.nodeFillColor = "lemonChiffon";
this.centerOptions.showQualified = false; this.centerOptions.showQualified = false;
this.matcher = new ContextMatcher(root, Pattern.compile(Pattern.quote(cd.getQualifiedName().toString())), myGlobalOptions, true); this.matcher = new ContextMatcher(root, Pattern.compile(Pattern.quote(cd.toString())), myGlobalOptions, true);
} }
@ -103,7 +103,7 @@ public class ContextView implements OptionProvider {
Options opt; Options opt;
if (!matcher.matches(name)) { if (!matcher.matches(name)) {
opt = hideOptions; opt = hideOptions;
} else if (name.equals(cd.getQualifiedName())) { } else if (name.equals(cd.getSimpleName())) {
opt = centerOptions; opt = centerOptions;
} else { } else {
opt = globalOptions; opt = globalOptions;

View File

@ -589,7 +589,7 @@ public class Options implements Cloneable, OptionProvider {
// reused often, especially in UmlGraphDoc, worth creating just once and reusing // reused often, especially in UmlGraphDoc, worth creating just once and reusing
private static final Pattern allPattern = Pattern.compile(".*"); private static final Pattern allPattern = Pattern.compile(".*");
protected static final String DEFAULT_EXTERNAL_APIDOC = "http://docs.oracle.com/javase/7/docs/api/"; protected static final String DEFAULT_EXTERNAL_APIDOC = "https://docs.oracle.com/javase/9/docs/api/";
// instance fields // instance fields
List<Pattern> hidePatterns = new ArrayList<>(); List<Pattern> hidePatterns = new ArrayList<>();
@ -975,28 +975,37 @@ public class Options implements Cloneable, OptionProvider {
* @param packageListUrl * @param packageListUrl
*/ */
private void addApiDocRoots(String packageListUrl) { private void addApiDocRoots(String packageListUrl) {
tryFetch(null, packageListUrl);
}
private void tryFetch(String docUrl, String packageListUrl) {
BufferedReader br = null; BufferedReader br = null;
packageListUrl = fixApiDocRoot(packageListUrl); packageListUrl = fixApiDocRoot(packageListUrl);
try { String finalDocUrl = docUrl == null ? null : fixApiDocRoot(docUrl);
URL url = new URL(packageListUrl + "package-list"); for (String suffix : List.of("package-list", "element-list")) {
br = new BufferedReader(new InputStreamReader(url.openStream())); try {
String line; URL url = new URL(packageListUrl + suffix);
while ((line = br.readLine()) != null) { br = new BufferedReader(new InputStreamReader(url.openStream()));
line = line + "."; String line;
Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*"); while ((line = br.readLine()) != null) {
apiDocMap.put(pattern, packageListUrl); if (!line.startsWith("module:")) {
} line = line + ".";
} catch (IOException e) { Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*");
System.err.println("Errors happened while accessing the package-list file at " + packageListUrl); apiDocMap.put(pattern, finalDocUrl == null ? packageListUrl : finalDocUrl);
} finally { }
if (br != null) { }
try { break;
br.close(); } catch (IOException e) {
} catch (IOException e) { System.err.println("Errors happened while accessing the " + suffix + " file at " + packageListUrl);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
}
} }
} }
} }
} }
/** /**
@ -1008,27 +1017,7 @@ public class Options implements Cloneable, OptionProvider {
* @param packageListUrl folder containing the package-list * @param packageListUrl folder containing the package-list
*/ */
private void addApiDocRootsOffline(String docUrl, String packageListUrl) { private void addApiDocRootsOffline(String docUrl, String packageListUrl) {
BufferedReader br = null; tryFetch(docUrl, packageListUrl);
packageListUrl = fixApiDocRoot(packageListUrl);
try {
URL url = new URL(packageListUrl + "package-list");
br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = br.readLine()) != null) {
line = line + ".";
Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*");
apiDocMap.put(pattern, fixApiDocRoot(docUrl));
}
} catch (IOException e) {
System.err.println("Unable to access the package-list file at " + packageListUrl);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
}
}
}
} }
/** /**

View File

@ -123,7 +123,6 @@ public class UmlGraphDoc implements Doclet {
continue; continue;
} }
if (!packages.contains(packageDoc.getSimpleName())) { if (!packages.contains(packageDoc.getSimpleName())) {
reporter.print(Diagnostic.Kind.WARNING, "Package processed " + packageDoc.getQualifiedName());
packages.add(packageDoc.getSimpleName()); packages.add(packageDoc.getSimpleName());
OptionProvider view = new PackageView(outputFolder, packageDoc, root, opt); OptionProvider view = new PackageView(outputFolder, packageDoc, root, opt);
UmlGraph.buildGraph(reporter, root, opt, view, packageDoc); UmlGraph.buildGraph(reporter, root, opt, view, packageDoc);
@ -151,7 +150,6 @@ public class UmlGraphDoc implements Doclet {
ContextView view = null; ContextView view = null;
for (TypeElement classDoc : classDocs) { for (TypeElement classDoc : classDocs) {
reporter.print(Diagnostic.Kind.WARNING, "Class processed " + classDoc.getQualifiedName());
try { try {
if (view == null) { if (view == null) {
view = new ContextView(outputFolder, classDoc, root, opt); view = new ContextView(outputFolder, classDoc, root, opt);