139 public Void scan(DocCommentTree tree, TreePath p) { |
139 public Void scan(DocCommentTree tree, TreePath p) { |
140 env.setCurrent(p, tree); |
140 env.setCurrent(p, tree); |
141 |
141 |
142 boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty(); |
142 boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty(); |
143 |
143 |
144 if (tree == null) { |
144 if (p.getLeaf() == p.getCompilationUnit()) { |
145 if (!isSynthetic() && !isOverridingMethod) |
145 // If p points to a compilation unit, the implied declaration is the |
146 reportMissing("dc.missing.comment"); |
146 // package declaration (if any) for the compilation unit. |
147 return null; |
147 // Handle this case specially, because doc comments are only |
|
148 // expected in package-info files. |
|
149 JavaFileObject fo = p.getCompilationUnit().getSourceFile(); |
|
150 boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE); |
|
151 if (tree == null) { |
|
152 if (isPkgInfo) |
|
153 reportMissing("dc.missing.comment"); |
|
154 return null; |
|
155 } else { |
|
156 if (!isPkgInfo) |
|
157 reportReference("dc.unexpected.comment"); |
|
158 } |
|
159 } else { |
|
160 if (tree == null) { |
|
161 if (!isSynthetic() && !isOverridingMethod) |
|
162 reportMissing("dc.missing.comment"); |
|
163 return null; |
|
164 } |
148 } |
165 } |
149 |
166 |
150 tagStack.clear(); |
167 tagStack.clear(); |
151 currHeaderTag = null; |
168 currHeaderTag = null; |
152 |
169 |
183 return null; |
200 return null; |
184 } |
201 } |
185 |
202 |
186 private void reportMissing(String code, Object... args) { |
203 private void reportMissing(String code, Object... args) { |
187 env.messages.report(MISSING, Kind.WARNING, env.currPath.getLeaf(), code, args); |
204 env.messages.report(MISSING, Kind.WARNING, env.currPath.getLeaf(), code, args); |
|
205 } |
|
206 |
|
207 private void reportReference(String code, Object... args) { |
|
208 env.messages.report(REFERENCE, Kind.WARNING, env.currPath.getLeaf(), code, args); |
188 } |
209 } |
189 |
210 |
190 @Override |
211 @Override |
191 public Void visitDocComment(DocCommentTree tree, Void ignore) { |
212 public Void visitDocComment(DocCommentTree tree, Void ignore) { |
192 super.visitDocComment(tree, ignore); |
213 super.visitDocComment(tree, ignore); |