本文整理汇总了Java中com.sun.tools.javac.api.DiagnosticFormatter类的典型用法代码示例。如果您正苦于以下问题:Java DiagnosticFormatter类的具体用法?Java DiagnosticFormatter怎么用?Java DiagnosticFormatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiagnosticFormatter类属于com.sun.tools.javac.api包,在下文中一共展示了DiagnosticFormatter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JCDiagnostic
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Create a diagnostic object.
* @param formatter the formatter to use for the diagnostic
* @param dt the type of diagnostic
* @param lc the lint category for the diagnostic
* @param source the name of the source file, or null if none.
* @param pos the character offset within the source file, if given.
* @param key a resource key to identify the text of the diagnostic
* @param args arguments to be included in the text of the diagnostic
*/
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
DiagnosticType dt,
LintCategory lc,
Set<DiagnosticFlag> flags,
DiagnosticSource source,
DiagnosticPosition pos,
String key,
Object... args) {
if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
throw new IllegalArgumentException();
this.defaultFormatter = formatter;
this.type = dt;
this.lintCategory = lc;
this.flags = flags;
this.source = source;
this.position = pos;
this.key = key;
this.args = args;
}
示例2: JCDiagnostic
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Create a diagnostic object.
* @param formatter the formatter to use for the diagnostic
* @param diagnosticInfo the diagnostic key
* @param lc the lint category for the diagnostic
* @param source the name of the source file, or null if none.
* @param pos the character offset within the source file, if given.
*/
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
DiagnosticInfo diagnosticInfo,
LintCategory lc,
Set<DiagnosticFlag> flags,
DiagnosticSource source,
DiagnosticPosition pos) {
if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
throw new IllegalArgumentException();
this.defaultFormatter = formatter;
this.diagnosticInfo = diagnosticInfo;
this.lintCategory = lc;
this.flags = flags;
this.source = source;
this.position = pos;
}
示例3: wrap
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
public static Diagnostic wrap(Diagnostic d, DiagnosticFormatter<JCDiagnostic> df) {
if (d instanceof JCDiagnostic) {
return new RichDiagnostic((JCDiagnostic) d, df);
} else {
return d;
}
}
示例4: getFragmentFormatter
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
@Deprecated
public static DiagnosticFormatter<JCDiagnostic> getFragmentFormatter() {
if (fragmentFormatter == null) {
fragmentFormatter = new BasicDiagnosticFormatter(JavacMessages.getDefaultMessages());
}
return fragmentFormatter;
}
示例5: JCDiagnostic
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Create a diagnostic object.
* @param fomatter the formatter to use for the diagnostic
* @param dt the type of diagnostic
* @param lc the lint category for the diagnostic
* @param source the name of the source file, or null if none.
* @param pos the character offset within the source file, if given.
* @param key a resource key to identify the text of the diagnostic
* @param args arguments to be included in the text of the diagnostic
*/
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
DiagnosticType dt,
LintCategory lc,
Set<DiagnosticFlag> flags,
DiagnosticSource source,
DiagnosticPosition pos,
String key,
Object... args) {
if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
throw new IllegalArgumentException();
this.defaultFormatter = formatter;
this.type = dt;
this.lintCategory = lc;
this.flags = flags;
this.source = source;
this.position = pos;
this.key = key;
this.args = args;
int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
if (n == Position.NOPOS || source == null)
line = column = -1;
else {
line = source.getLineNumber(n);
column = source.getColumnNumber(n, true);
}
}
示例6: testThroughFormatterFormat
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
public void testThroughFormatterFormat() throws IOException {
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
DiagnosticChecker dc = new DiagnosticChecker("compiler.err.prob.found.req");
JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(new JavaSource()));
ct.analyze();
DiagnosticFormatter<JCDiagnostic> formatter =
Log.instance(((JavacTaskImpl) ct).getContext()).getDiagnosticFormatter();
String msg = formatter.formatMessage(dc.diag, Locale.getDefault());
//no redundant package qualifiers
Assert.check(msg.indexOf("java.") == -1, msg);
}
示例7: JCDiagnostic
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Create a diagnostic object.
* @param formatter the formatter to use for the diagnostic
* @param dt the type of diagnostic
* @param lc the lint category for the diagnostic
* @param source the name of the source file, or null if none.
* @param pos the character offset within the source file, if given.
* @param key a resource key to identify the text of the diagnostic
* @param args arguments to be included in the text of the diagnostic
*/
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
DiagnosticType dt,
LintCategory lc,
Set<DiagnosticFlag> flags,
DiagnosticSource source,
DiagnosticPosition pos,
String key,
Object... args) {
if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
throw new IllegalArgumentException();
this.defaultFormatter = formatter;
this.type = dt;
this.lintCategory = lc;
this.flags = flags;
this.source = source;
this.position = pos;
this.key = key;
this.args = args;
int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
if (n == Position.NOPOS || source == null)
line = column = -1;
else {
line = source.getLineNumber(n);
column = source.getColumnNumber(n, true);
}
}
示例8: JCDiagnostic
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Create a diagnostic object.
* @param fomatter the formatter to use for the diagnostic
* @param dt the type of diagnostic
* @param lc the lint category for the diagnostic
* @param source the name of the source file, or null if none.
* @param pos the character offset within the source file, if given.
* @param key a resource key to identify the text of the diagnostic
* @param args arguments to be included in the text of the diagnostic
*/
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
DiagnosticType dt,
LintCategory lc,
Set<DiagnosticFlag> flags,
DiagnosticSource source,
DiagnosticPosition pos,
String key,
Object... args) {
if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
throw new IllegalArgumentException();
this.defaultFormatter = formatter;
this.type = dt;
this.lintCategory = lc;
this.flags = flags;
this.source = source;
this.position = pos;
this.key = key;
this.args = args;
int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
if (n == Position.NOPOS || source == null)
line = column = -1;
else {
line = source.getLineNumber(n);
column = source.getColumnNumber(n, true);
}
}
示例9: report
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
@Override
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
DiagnosticFormatter<JCDiagnostic> formatter = Log.instance(context).getDiagnosticFormatter();
Locale locale = JavacMessages.instance(context).getCurrentLocale();
String formatted = formatter.format((JCDiagnostic) diagnostic, locale);
diagnostics.add(new FormattedDiagnostic(diagnostic, formatted));
}
示例10: RichDiagnostic
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
public RichDiagnostic(JCDiagnostic delegate, DiagnosticFormatter<JCDiagnostic> formatter) {
this.delegate = delegate;
this.formatter = formatter;
}
示例11: getDiagnosticFormatter
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Get the current diagnostic formatter.
*/
public DiagnosticFormatter<JCDiagnostic> getDiagnosticFormatter() {
return diagFormatter;
}
示例12: setDiagnosticFormatter
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/**
* Set the current diagnostic formatter.
*/
public void setDiagnosticFormatter(DiagnosticFormatter<JCDiagnostic> diagFormatter) {
this.diagFormatter = diagFormatter;
}
示例13: getDiagnosticFormatter
import com.sun.tools.javac.api.DiagnosticFormatter; //导入依赖的package包/类
/** Get the current diagnostic formatter.
*/
public DiagnosticFormatter<JCDiagnostic> getDiagnosticFormatter() {
return diagFormatter;
}