30 |
30 |
31 import javax.tools.Diagnostic; |
31 import javax.tools.Diagnostic; |
32 import javax.tools.JavaFileObject; |
32 import javax.tools.JavaFileObject; |
33 |
33 |
34 import com.sun.tools.javac.api.DiagnosticFormatter; |
34 import com.sun.tools.javac.api.DiagnosticFormatter; |
35 import com.sun.tools.javac.file.JavacFileManager; |
|
36 import com.sun.tools.javac.tree.JCTree; |
35 import com.sun.tools.javac.tree.JCTree; |
37 |
36 |
38 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; |
37 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; |
39 |
38 |
40 /** An abstraction of a diagnostic message generated by the compiler. |
39 /** An abstraction of a diagnostic message generated by the compiler. |
352 else |
351 else |
353 return source.getFile(); |
352 return source.getFile(); |
354 } |
353 } |
355 |
354 |
356 /** |
355 /** |
357 * Get the name of the source file referred to by this diagnostic. |
|
358 * @return the name of the source referred to with this diagnostic, or null if none |
|
359 */ |
|
360 public String getSourceName() { |
|
361 JavaFileObject s = getSource(); |
|
362 return s == null ? null : JavacFileManager.getJavacFileName(s); |
|
363 } |
|
364 |
|
365 /** |
|
366 * Get the source referred to by this diagnostic. |
356 * Get the source referred to by this diagnostic. |
367 * @return the source referred to with this diagnostic, or null if none |
357 * @return the source referred to with this diagnostic, or null if none |
368 */ |
358 */ |
369 public DiagnosticSource getDiagnosticSource() { |
359 public DiagnosticSource getDiagnosticSource() { |
370 return source; |
360 return source; |