1 /* |
1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
40 import javax.tools.Diagnostic; |
40 import javax.tools.Diagnostic; |
41 |
41 |
42 import com.sun.source.doctree.DocTree; |
42 import com.sun.source.doctree.DocTree; |
43 import com.sun.source.tree.Tree; |
43 import com.sun.source.tree.Tree; |
44 import com.sun.tools.doclint.Env.AccessKind; |
44 import com.sun.tools.doclint.Env.AccessKind; |
|
45 import com.sun.tools.javac.util.StringUtils; |
45 |
46 |
46 /** |
47 /** |
47 * Message reporting for DocLint. |
48 * Message reporting for DocLint. |
48 * |
49 * |
49 * Options are used to filter out messages based on group and access level. |
50 * Options are used to filter out messages based on group and access level. |
65 HTML, |
66 HTML, |
66 MISSING, |
67 MISSING, |
67 SYNTAX, |
68 SYNTAX, |
68 REFERENCE; |
69 REFERENCE; |
69 |
70 |
70 String optName() { return name().toLowerCase(); } |
71 String optName() { return StringUtils.toLowerCase(name()); } |
71 String notOptName() { return "-" + optName(); } |
72 String notOptName() { return "-" + optName(); } |
72 |
73 |
73 static boolean accepts(String opt) { |
74 static boolean accepts(String opt) { |
74 for (Group g: values()) |
75 for (Group g: values()) |
75 if (opt.equals(g.optName())) return true; |
76 if (opt.equals(g.optName())) return true; |
156 Map<String, Env.AccessKind> map = new HashMap<String, Env.AccessKind>(); |
157 Map<String, Env.AccessKind> map = new HashMap<String, Env.AccessKind>(); |
157 private final Stats stats; |
158 private final Stats stats; |
158 |
159 |
159 static boolean isValidOptions(String opts) { |
160 static boolean isValidOptions(String opts) { |
160 for (String opt: opts.split(",")) { |
161 for (String opt: opts.split(",")) { |
161 if (!isValidOption(opt.trim().toLowerCase())) |
162 if (!isValidOption(StringUtils.toLowerCase(opt.trim()))) |
162 return false; |
163 return false; |
163 } |
164 } |
164 return true; |
165 return true; |
165 } |
166 } |
166 |
167 |
201 void setOptions(String opts) { |
202 void setOptions(String opts) { |
202 if (opts == null) |
203 if (opts == null) |
203 setOption(ALL, Env.AccessKind.PRIVATE); |
204 setOption(ALL, Env.AccessKind.PRIVATE); |
204 else { |
205 else { |
205 for (String opt: opts.split(",")) |
206 for (String opt: opts.split(",")) |
206 setOption(opt.trim().toLowerCase()); |
207 setOption(StringUtils.toLowerCase(opt.trim())); |
207 } |
208 } |
208 } |
209 } |
209 |
210 |
210 private void setOption(String arg) throws IllegalArgumentException { |
211 private void setOption(String arg) throws IllegalArgumentException { |
211 if (arg.equals(Stats.OPT)) { |
212 if (arg.equals(Stats.OPT)) { |
213 return; |
214 return; |
214 } |
215 } |
215 |
216 |
216 int sep = arg.indexOf("/"); |
217 int sep = arg.indexOf("/"); |
217 if (sep > 0) { |
218 if (sep > 0) { |
218 Env.AccessKind ak = Env.AccessKind.valueOf(arg.substring(sep + 1).toUpperCase()); |
219 Env.AccessKind ak = Env.AccessKind.valueOf(StringUtils.toUpperCase(arg.substring(sep + 1))); |
219 setOption(arg.substring(0, sep), ak); |
220 setOption(arg.substring(0, sep), ak); |
220 } else { |
221 } else { |
221 setOption(arg, null); |
222 setOption(arg, null); |
222 } |
223 } |
223 } |
224 } |
288 groupTable.print(out); |
289 groupTable.print(out); |
289 out.println(); |
290 out.println(); |
290 out.println("By diagnostic kind..."); |
291 out.println("By diagnostic kind..."); |
291 Table dkindTable = new Table(); |
292 Table dkindTable = new Table(); |
292 for (Diagnostic.Kind k : Diagnostic.Kind.values()) { |
293 for (Diagnostic.Kind k : Diagnostic.Kind.values()) { |
293 dkindTable.put(k.toString().toLowerCase(), dkindCounts[k.ordinal()]); |
294 dkindTable.put(StringUtils.toLowerCase(k.toString()), dkindCounts[k.ordinal()]); |
294 } |
295 } |
295 dkindTable.print(out); |
296 dkindTable.print(out); |
296 out.println(); |
297 out.println(); |
297 out.println("By message kind..."); |
298 out.println("By message kind..."); |
298 Table codeTable = new Table(); |
299 Table codeTable = new Table(); |