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

View File

@ -499,8 +499,9 @@ class ClassGraph {
}
}
externalTableEnd();
if (url != null)
if (url != null) {
w.print(", URL=\"" + url + "\"");
}
nodeProperties(opt);
// If needed, add a note for this node
@ -672,8 +673,9 @@ class ClassGraph {
}
// Handle missing classes:
Options opt = optionProvider.getOptionsFor(className);
if (opt.matchesHideExpression(className))
if (opt.matchesHideExpression(className)) {
continue;
}
w.println(linePrefix + "// " + className);
w.print(linePrefix + info.name + "[label=");
externalTableStart(opt, className, classToUrl(className));
@ -731,7 +733,7 @@ class ClassGraph {
}
// 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) {
String destAdornment = fri.multiple ? "*" : "";
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
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))) {
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
* directed relation
*/
Map<Name, RelationPattern> relatedClasses = new HashMap<>();
Map<String, RelationPattern> relatedClasses = new HashMap<>();
ClassInfo(boolean h) {
hidden = h;
@ -53,16 +53,16 @@ class ClassInfo {
}
public void addRelation(Name dest, RelationType rt, RelationDirection d) {
RelationPattern ri = relatedClasses.get(dest);
RelationPattern ri = relatedClasses.get(dest.toString());
if (ri == null) {
ri = new RelationPattern(RelationDirection.NONE);
relatedClasses.put(dest, ri);
relatedClasses.put(dest.toString(), ri);
}
ri.addRelation(rt, d);
}
public RelationPattern getRelation(CharSequence dest) {
return relatedClasses.get(dest);
return relatedClasses.get(dest.toString());
}
/** Start numbering from zero. */

View File

@ -61,7 +61,7 @@ public class ContextView implements OptionProvider {
this.centerOptions.nodeFillColor = "lemonChiffon";
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;
if (!matcher.matches(name)) {
opt = hideOptions;
} else if (name.equals(cd.getQualifiedName())) {
} else if (name.equals(cd.getSimpleName())) {
opt = centerOptions;
} else {
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
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
List<Pattern> hidePatterns = new ArrayList<>();
@ -975,28 +975,37 @@ public class Options implements Cloneable, OptionProvider {
* @param packageListUrl
*/
private void addApiDocRoots(String packageListUrl) {
tryFetch(null, packageListUrl);
}
private void tryFetch(String docUrl, String packageListUrl) {
BufferedReader br = null;
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, packageListUrl);
}
} catch (IOException e) {
System.err.println("Errors happened while accessing the package-list file at " + packageListUrl);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
String finalDocUrl = docUrl == null ? null : fixApiDocRoot(docUrl);
for (String suffix : List.of("package-list", "element-list")) {
try {
URL url = new URL(packageListUrl + suffix);
br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = br.readLine()) != null) {
if (!line.startsWith("module:")) {
line = line + ".";
Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*");
apiDocMap.put(pattern, finalDocUrl == null ? packageListUrl : finalDocUrl);
}
}
break;
} 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
*/
private void addApiDocRootsOffline(String docUrl, String packageListUrl) {
BufferedReader br = null;
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) {
}
}
}
tryFetch(docUrl, packageListUrl);
}
/**

View File

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