23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 6227454 |
26 * @bug 6227454 |
27 * @summary package.html and overview.html may not be read fully |
27 * @summary package.html and overview.html may not be read fully |
28 * * @modules jdk.javadoc/jdk.javadoc.internal.tool |
28 * @modules jdk.javadoc/jdk.javadoc.internal.tool |
29 */ |
29 */ |
30 |
30 |
31 import java.io.*; |
31 import java.io.*; |
|
32 import java.util.ArrayList; |
32 import java.util.Arrays; |
33 import java.util.Arrays; |
33 |
34 |
34 import java.util.HashSet; |
35 import java.util.HashSet; |
35 import java.util.ListIterator; |
36 import java.util.List; |
36 import java.util.Locale; |
37 import java.util.Locale; |
37 import java.util.Set; |
38 import java.util.Set; |
38 |
39 |
39 import javax.lang.model.SourceVersion; |
40 import javax.lang.model.SourceVersion; |
40 import javax.lang.model.element.Element; |
41 import javax.lang.model.element.Element; |
|
42 import javax.lang.model.util.ElementFilter; |
41 |
43 |
42 import com.sun.source.doctree.DocCommentTree; |
44 import com.sun.source.doctree.DocCommentTree; |
43 import com.sun.source.util.DocTrees; |
45 import com.sun.source.util.DocTrees; |
44 import jdk.javadoc.doclet.Doclet; |
46 import jdk.javadoc.doclet.Doclet; |
45 import jdk.javadoc.doclet.Reporter; |
47 import jdk.javadoc.doclet.Reporter; |
46 import jdk.javadoc.doclet.DocletEnvironment; |
48 import jdk.javadoc.doclet.DocletEnvironment; |
47 |
|
48 |
49 |
49 public class Test implements Doclet { |
50 public class Test implements Doclet { |
50 public static void main(String... args) throws Exception { |
51 public static void main(String... args) throws Exception { |
51 new Test().run(); |
52 new Test().run(); |
52 } |
53 } |
138 int testNum; |
139 int testNum; |
139 int errors; |
140 int errors; |
140 |
141 |
141 public boolean run(DocletEnvironment root) { |
142 public boolean run(DocletEnvironment root) { |
142 DocTrees docTrees = root.getDocTrees(); |
143 DocTrees docTrees = root.getDocTrees(); |
143 System.out.println("classes:" + root.getIncludedTypeElements()); |
144 System.out.println("classes:" + ElementFilter.typesIn(root.getIncludedElements())); |
144 |
145 |
145 Element klass = root.getIncludedTypeElements().iterator().next(); |
146 Element klass = ElementFilter.typesIn(root.getIncludedElements()).iterator().next(); |
146 String text = ""; |
147 String text = ""; |
147 try { |
148 try { |
148 DocCommentTree dcTree = docTrees.getDocCommentTree(klass, overviewpath); |
149 DocCommentTree dcTree = docTrees.getDocCommentTree(klass, overviewpath); |
149 text = dcTree.getFullBody().toString(); |
150 text = dcTree.getFullBody().toString(); |
150 } catch (IOException ioe) { |
151 } catch (IOException ioe) { |
188 public Option.Kind getKind() { |
189 public Option.Kind getKind() { |
189 return Option.Kind.STANDARD; |
190 return Option.Kind.STANDARD; |
190 } |
191 } |
191 |
192 |
192 @Override |
193 @Override |
193 public String getName() { |
194 public List<String> getNames() { |
194 return "overview"; |
195 List<String> out = new ArrayList<>(); |
|
196 out.add("overview"); |
|
197 return out; |
195 } |
198 } |
196 |
199 |
197 @Override |
200 @Override |
198 public String getParameters() { |
201 public String getParameters() { |
199 return "url"; |
202 return "url"; |
200 } |
203 } |
201 |
204 |
202 @Override |
205 @Override |
203 public boolean matches(String option) { |
206 public boolean process(String option, List<String> arguments) { |
204 String opt = option.startsWith("-") ? option.substring(1) : option; |
207 overviewpath = arguments.get(0); |
205 return getName().equals(opt); |
|
206 } |
|
207 |
|
208 @Override |
|
209 public boolean process(String option, ListIterator<String> arguments) { |
|
210 if (matches(option)) { |
|
211 overviewpath = arguments.next(); |
|
212 } |
|
213 return true; |
208 return true; |
214 } |
209 } |
215 } |
210 } |
216 }; |
211 }; |
217 return new HashSet<Option>(Arrays.asList(options)); |
212 return new HashSet<>(Arrays.asList(options)); |
218 } |
213 } |
219 |
214 |
220 @Override |
215 @Override |
221 public SourceVersion getSupportedSourceVersion() { |
216 public SourceVersion getSupportedSourceVersion() { |
222 return SourceVersion.latest(); |
217 return SourceVersion.latest(); |