author | pmuthuswamy |
Tue, 25 Sep 2018 12:36:45 +0530 | |
changeset 51861 | f7d40158eb2f |
parent 48654 | 36f58bd6269f |
child 52644 | 43efb4ca6d6c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
48295
diff
changeset
|
2 |
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.util; |
10 | 27 |
|
14258 | 28 |
import java.io.*; |
29 |
import java.net.*; |
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.Map; |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
32 |
import java.util.TreeMap; |
10 | 33 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
34 |
import javax.lang.model.element.Element; |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
35 |
import javax.lang.model.element.ModuleElement; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
36 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
37 |
import javax.tools.Diagnostic; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
38 |
import javax.tools.DocumentationTool; |
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
39 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
40 |
import jdk.javadoc.doclet.Reporter; |
45417 | 41 |
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
10 | 42 |
|
43 |
/** |
|
44 |
* Process and manage "-link" and "-linkoffline" to external packages. The |
|
45 |
* options "-link" and "-linkoffline" both depend on the fact that Javadoc now |
|
46 |
* generates "package-list"(lists all the packages which are getting |
|
47 |
* documented) file in the current or the destination directory, while |
|
48 |
* generating the documentation. |
|
49 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
50 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
51 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
52 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
53 |
* deletion without notice.</b> |
10 | 54 |
* |
55 |
* @author Atul M Dambalkar |
|
56 |
* @author Robert Field |
|
57 |
*/ |
|
58 |
public class Extern { |
|
59 |
||
60 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
61 |
* Map element names onto Extern Item objects. |
10 | 62 |
* Lazily initialized. |
63 |
*/ |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
64 |
private Map<String, Item> moduleItems = new HashMap<>(); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
65 |
private Map<String, Map<String, Item>> packageItems = new HashMap<>(); |
10 | 66 |
|
67 |
/** |
|
68 |
* The global configuration information for this run. |
|
69 |
*/ |
|
45417 | 70 |
private final BaseConfiguration configuration; |
10 | 71 |
|
72 |
/** |
|
73 |
* True if we are using -linkoffline and false if -link is used instead. |
|
74 |
*/ |
|
75 |
private boolean linkoffline = false; |
|
76 |
||
77 |
/** |
|
78 |
* Stores the info for one external doc set |
|
79 |
*/ |
|
80 |
private class Item { |
|
81 |
||
82 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
83 |
* Element name, found in the "element-list" file in the {@link path}. |
10 | 84 |
*/ |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
85 |
final String elementName; |
10 | 86 |
|
87 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
88 |
* The URL or the directory path at which the element documentation will be |
10 | 89 |
* avaliable. |
90 |
*/ |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
91 |
final DocPath path; |
10 | 92 |
|
93 |
/** |
|
94 |
* If given path is directory path then true else if it is a URL then false. |
|
95 |
*/ |
|
96 |
final boolean relative; |
|
97 |
||
98 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
99 |
* Constructor to build a Extern Item object and map it with the element name. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
100 |
* If the same element name is found in the map, then the first mapped |
10 | 101 |
* Item object or offline location will be retained. |
102 |
* |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
103 |
* @param elementName Element name found in the "element-list" file. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
104 |
* @param path URL or Directory path from where the "element-list" |
10 | 105 |
* file is picked. |
106 |
* @param relative True if path is URL, false if directory path. |
|
107 |
*/ |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
108 |
Item(String elementName, DocPath path, boolean relative) { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
109 |
this.elementName = elementName; |
10 | 110 |
this.path = path; |
111 |
this.relative = relative; |
|
112 |
} |
|
113 |
||
114 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
115 |
* String representation of "this" with elementname and the path. |
10 | 116 |
*/ |
40587 | 117 |
@Override |
10 | 118 |
public String toString() { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
119 |
return elementName + (relative? " -> " : " => ") + path.getPath(); |
10 | 120 |
} |
121 |
} |
|
122 |
||
45417 | 123 |
public Extern(BaseConfiguration configuration) { |
10 | 124 |
this.configuration = configuration; |
125 |
} |
|
126 |
||
127 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
128 |
* Determine if a element item is externally documented. |
10 | 129 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
130 |
* @param element an Element. |
40587 | 131 |
* @return true if the element is externally documented |
10 | 132 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
133 |
public boolean isExternal(Element element) { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
134 |
if (packageItems.isEmpty()) { |
10 | 135 |
return false; |
136 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
137 |
PackageElement pe = configuration.utils.containingPackage(element); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
138 |
if (pe.isUnnamed()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
139 |
return false; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
140 |
} |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
141 |
|
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
142 |
return findElementItem(pe) != null; |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
143 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
144 |
|
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
145 |
/** |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
146 |
* Determine if a element item is a module or not. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
147 |
* |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
148 |
* @param elementName name of the element. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
149 |
* @return true if the element is a module |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
150 |
*/ |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
151 |
public boolean isModule(String elementName) { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
152 |
Item elem = moduleItems.get(elementName); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
153 |
return (elem == null) ? false : true; |
10 | 154 |
} |
155 |
||
156 |
/** |
|
157 |
* Convert a link to be an external link if appropriate. |
|
158 |
* |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
159 |
* @param element The element . |
10 | 160 |
* @param relativepath The relative path. |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
161 |
* @param filename The link to convert. |
10 | 162 |
* @return if external return converted link else return null |
163 |
*/ |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
164 |
public DocLink getExternalLink(Element element, DocPath relativepath, String filename) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
165 |
return getExternalLink(element, relativepath, filename, null); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
166 |
} |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
167 |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
168 |
public DocLink getExternalLink(Element element, DocPath relativepath, String filename, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
169 |
String memberName) { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
170 |
Item fnd = findElementItem(element); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
171 |
if (fnd == null) |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
172 |
return null; |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
173 |
|
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
48295
diff
changeset
|
174 |
// The following is somewhat questionable since we are using DocPath |
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
48295
diff
changeset
|
175 |
// to contain external URLs! |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
176 |
DocPath p = fnd.relative ? |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
177 |
relativepath.resolve(fnd.path).resolve(filename) : |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
178 |
fnd.path.resolve(filename); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
179 |
return new DocLink(p, "is-external=true", memberName); |
10 | 180 |
} |
181 |
||
182 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
183 |
* Build the extern element list from given URL or the directory path, |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
184 |
* as specified with the "-link" flag. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
185 |
* Flag error if the "-link" or "-linkoffline" option is already used. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
186 |
* |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
187 |
* @param url URL or Directory path. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
188 |
* @param reporter The <code>DocErrorReporter</code> used to report errors. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
189 |
* @return true if successful, false otherwise |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
190 |
* @throws DocFileIOException if there is a problem reading a element list file |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
191 |
*/ |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
192 |
public boolean link(String url, Reporter reporter) throws DocFileIOException { |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
193 |
return link(url, url, reporter, false); |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
194 |
} |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
195 |
|
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
196 |
/** |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
197 |
* Build the extern element list from given URL or the directory path, |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
198 |
* as specified with the "-linkoffline" flag. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
199 |
* Flag error if the "-link" or "-linkoffline" option is already used. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
200 |
* |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
201 |
* @param url URL or Directory path. |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
202 |
* @param elemlisturl This can be another URL for "element-list" or ordinary |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
203 |
* file. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
204 |
* @param reporter The <code>DocErrorReporter</code> used to report errors. |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
205 |
* @return true if successful, false otherwise |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
206 |
* @throws DocFileIOException if there is a problem reading the element list file |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
207 |
*/ |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
208 |
public boolean link(String url, String elemlisturl, Reporter reporter) throws DocFileIOException { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
209 |
return link(url, elemlisturl, reporter, true); |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
210 |
} |
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
211 |
|
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
212 |
/* |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
213 |
* Build the extern element list from given URL or the directory path. |
10 | 214 |
* Flag error if the "-link" or "-linkoffline" option is already used. |
215 |
* |
|
216 |
* @param url URL or Directory path. |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
217 |
* @param elemlisturl This can be another URL for "element-list" or ordinary |
10 | 218 |
* file. |
219 |
* @param reporter The <code>DocErrorReporter</code> used to report errors. |
|
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
220 |
* @param linkoffline True if -linkoffline is used and false if -link is used. |
40587 | 221 |
* @return true if successful, false otherwise |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
222 |
* @throws DocFileIOException if there is a problem reading the element list file |
10 | 223 |
*/ |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
224 |
private boolean link(String url, String elemlisturl, Reporter reporter, boolean linkoffline) |
40587 | 225 |
throws DocFileIOException { |
10 | 226 |
this.linkoffline = linkoffline; |
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
227 |
try { |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
228 |
url = adjustEndFileSeparator(url); |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
229 |
if (isUrl(elemlisturl)) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
230 |
readElementListFromURL(url, toURL(adjustEndFileSeparator(elemlisturl))); |
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
231 |
} else { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
232 |
readElementListFromFile(url, DocFile.createFileForInput(configuration, elemlisturl)); |
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
233 |
} |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
234 |
return true; |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
235 |
} catch (Fault f) { |
47877
7e57d42b5eeb
8180019: javadoc should treat failure to access URL as an error, not a warning.
ksrini
parents:
47216
diff
changeset
|
236 |
reporter.print(Diagnostic.Kind.ERROR, f.getMessage()); |
10 | 237 |
return false; |
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
238 |
} |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
239 |
} |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
240 |
|
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
241 |
private URL toURL(String url) throws Fault { |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
242 |
try { |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
243 |
return new URL(url); |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
244 |
} catch (MalformedURLException e) { |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
245 |
throw new Fault(configuration.getText("doclet.MalformedURL", url), e); |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
246 |
} |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
247 |
} |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
248 |
|
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
249 |
private class Fault extends Exception { |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
250 |
private static final long serialVersionUID = 0; |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
251 |
|
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
252 |
Fault(String msg, Exception cause) { |
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
253 |
super(msg, cause); |
10 | 254 |
} |
255 |
} |
|
256 |
||
257 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
258 |
* Get the Extern Item object associated with this element name. |
10 | 259 |
* |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
260 |
* @param element Element |
10 | 261 |
*/ |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
262 |
private Item findElementItem(Element element) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
263 |
Item item = null; |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
264 |
if (element instanceof ModuleElement) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
265 |
item = moduleItems.get(configuration.utils.getModuleName((ModuleElement)element)); |
10 | 266 |
} |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
267 |
else if (element instanceof PackageElement) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
268 |
PackageElement packageElement = (PackageElement)element; |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
269 |
ModuleElement moduleElement = configuration.utils.containingModule(packageElement); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
270 |
Map<String, Item> pkgMap = packageItems.get(configuration.utils.getModuleName(moduleElement)); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
271 |
item = (pkgMap != null) ? pkgMap.get(configuration.utils.getPackageName(packageElement)) : null; |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
272 |
} |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
273 |
return item; |
10 | 274 |
} |
275 |
||
276 |
/** |
|
277 |
* If the URL or Directory path is missing end file separator, add that. |
|
278 |
*/ |
|
279 |
private String adjustEndFileSeparator(String url) { |
|
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
280 |
return url.endsWith("/") ? url : url + '/'; |
10 | 281 |
} |
282 |
||
283 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
284 |
* Fetch the URL and read the "element-list" file. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
285 |
* |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
286 |
* @param urlpath Path to the elements. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
287 |
* @param elemlisturlpath URL or the path to the "element-list" file. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
288 |
*/ |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
289 |
private void readElementListFromURL(String urlpath, URL elemlisturlpath) throws Fault { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
290 |
try { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
291 |
URL link = elemlisturlpath.toURI().resolve(DocPaths.ELEMENT_LIST.getPath()).toURL(); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
292 |
readElementList(link.openStream(), urlpath, false); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
293 |
} catch (URISyntaxException | MalformedURLException exc) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
294 |
throw new Fault(configuration.getText("doclet.MalformedURL", elemlisturlpath.toString()), exc); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
295 |
} catch (IOException exc) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
296 |
readAlternateURL(urlpath, elemlisturlpath); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
297 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
298 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
299 |
|
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
300 |
/** |
10 | 301 |
* Fetch the URL and read the "package-list" file. |
302 |
* |
|
303 |
* @param urlpath Path to the packages. |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
304 |
* @param elemlisturlpath URL or the path to the "package-list" file. |
10 | 305 |
*/ |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
306 |
private void readAlternateURL(String urlpath, URL elemlisturlpath) throws Fault { |
10 | 307 |
try { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
308 |
URL link = elemlisturlpath.toURI().resolve(DocPaths.PACKAGE_LIST.getPath()).toURL(); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
309 |
readElementList(link.openStream(), urlpath, false); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14545
diff
changeset
|
310 |
} catch (URISyntaxException | MalformedURLException exc) { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
311 |
throw new Fault(configuration.getText("doclet.MalformedURL", elemlisturlpath.toString()), exc); |
46079
059faa5e1267
8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents:
45417
diff
changeset
|
312 |
} catch (IOException exc) { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
313 |
throw new Fault(configuration.getText("doclet.URL_error", elemlisturlpath.toString()), exc); |
10 | 314 |
} |
315 |
} |
|
316 |
||
317 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
318 |
* Read the "element-list" file which is available locally. |
10 | 319 |
* |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
320 |
* @param path URL or directory path to the elements. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
321 |
* @param elemListPath Path to the local "element-list" file. |
40587 | 322 |
* @throws Fault if an error occurs that can be treated as a warning |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
323 |
* @throws DocFileIOException if there is a problem opening the element list file |
10 | 324 |
*/ |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
325 |
private void readElementListFromFile(String path, DocFile elemListPath) |
40587 | 326 |
throws Fault, DocFileIOException { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
327 |
DocFile file = elemListPath.resolve(DocPaths.ELEMENT_LIST); |
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
328 |
if (! (file.isAbsolute() || linkoffline)){ |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
329 |
file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT); |
10 | 330 |
} |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
331 |
if (file.exists()) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
332 |
readElementList(file, path); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
333 |
} else { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
334 |
DocFile file1 = elemListPath.resolve(DocPaths.PACKAGE_LIST); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
335 |
if (!(file1.isAbsolute() || linkoffline)) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
336 |
file1 = file1.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
337 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
338 |
if (file1.exists()) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
339 |
readElementList(file1, path); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
340 |
} else { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
341 |
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null); |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
342 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
343 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
344 |
} |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
345 |
|
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
346 |
private void readElementList(DocFile file, String path) throws Fault, DocFileIOException { |
10 | 347 |
try { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
348 |
if (file.canRead()) { |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
349 |
boolean pathIsRelative |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
350 |
= !isUrl(path) |
36040 | 351 |
&& !DocFile.createFileForInput(configuration, path).isAbsolute(); |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
352 |
readElementList(file.openInputStream(), path, pathIsRelative); |
10 | 353 |
} else { |
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
354 |
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null); |
10 | 355 |
} |
356 |
} catch (IOException exc) { |
|
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14358
diff
changeset
|
357 |
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc); |
10 | 358 |
} |
359 |
} |
|
360 |
||
361 |
/** |
|
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
362 |
* Read the file "element-list" and for each element name found, create |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
363 |
* Extern object and associate it with the element name in the map. |
10 | 364 |
* |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
365 |
* @param input InputStream from the "element-list" file. |
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
366 |
* @param path URL or the directory path to the elements. |
10 | 367 |
* @param relative Is path relative? |
40587 | 368 |
* @throws IOException if there is a problem reading or closing the stream |
10 | 369 |
*/ |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
370 |
private void readElementList(InputStream input, String path, boolean relative) |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
371 |
throws Fault, IOException { |
40587 | 372 |
try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
373 |
String elemname = null; |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
374 |
String moduleName = null; |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
375 |
DocPath elempath = null; |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
376 |
DocPath basePath = DocPath.create(path); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
377 |
while ((elemname = in.readLine()) != null) { |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
378 |
if (elemname.length() > 0) { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
379 |
elempath = basePath; |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
380 |
if (elemname.startsWith(DocletConstants.MODULE_PREFIX)) { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
381 |
moduleName = elemname.replace(DocletConstants.MODULE_PREFIX, ""); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
382 |
Item item = new Item(moduleName, elempath, relative); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
383 |
moduleItems.put(moduleName, item); |
48295
c79d31ba84b9
8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents:
47877
diff
changeset
|
384 |
} else { |
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
385 |
DocPath pkgPath = DocPath.create(elemname.replace('.', '/')); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
386 |
if (configuration.useModuleDirectories && moduleName != null) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
387 |
elempath = elempath.resolve(DocPath.create(moduleName).resolve(pkgPath)); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
388 |
} else { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
389 |
elempath = elempath.resolve(pkgPath); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
390 |
} |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
391 |
checkLinkCompatibility(elemname, moduleName, path); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
392 |
Item item = new Item(elemname, elempath, relative); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
393 |
packageItems.computeIfAbsent(moduleName == null ? |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
394 |
DocletConstants.DEFAULT_ELEMENT_NAME : moduleName, k -> new TreeMap<>()) |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
395 |
.put(elemname, item); |
10 | 396 |
} |
397 |
} |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
398 |
} |
10 | 399 |
} |
400 |
} |
|
401 |
||
402 |
public boolean isUrl (String urlCandidate) { |
|
403 |
try { |
|
40587 | 404 |
URL ignore = new URL(urlCandidate); |
10 | 405 |
//No exception was thrown, so this must really be a URL. |
406 |
return true; |
|
407 |
} catch (MalformedURLException e) { |
|
408 |
//Since exception is thrown, this must be a directory path. |
|
409 |
return false; |
|
410 |
} |
|
411 |
} |
|
51861
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
412 |
|
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
413 |
private void checkLinkCompatibility(String packageName, String moduleName, String path) throws Fault { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
414 |
PackageElement pe = configuration.utils.elementUtils.getPackageElement(packageName); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
415 |
if (pe != null) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
416 |
ModuleElement me = (ModuleElement)pe.getEnclosingElement(); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
417 |
if (me == null || me.isUnnamed()) { |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
418 |
if (moduleName != null) |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
419 |
throw new Fault(configuration.getText("doclet.linkMismatch_PackagedLinkedtoModule", |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
420 |
path), null); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
421 |
} else if (moduleName == null) |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
422 |
throw new Fault(configuration.getText("doclet.linkMismatch_ModuleLinkedtoPackage", |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
423 |
path), null); |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
424 |
} |
f7d40158eb2f
8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents:
48654
diff
changeset
|
425 |
} |
10 | 426 |
} |