src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java

changeset 415
49359d0e6a9c
parent 302
18e0269f25e3
child 554
9d9f26857129
equal deleted inserted replaced
414:e992e602788e 415:49359d0e6a9c
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;
435 } 425 }
436 426
437 /** 427 /**
438 * Return the standard presentation of this diagnostic. 428 * Return the standard presentation of this diagnostic.
439 */ 429 */
430 @Override
440 public String toString() { 431 public String toString() {
441 return defaultFormatter.format(this,Locale.getDefault()); 432 return defaultFormatter.format(this,Locale.getDefault());
442 } 433 }
443 434
444 private DiagnosticFormatter<JCDiagnostic> defaultFormatter; 435 private DiagnosticFormatter<JCDiagnostic> defaultFormatter;

mercurial