本文整理汇总了Java中javax.tools.Diagnostic.Kind方法的典型用法代码示例。如果您正苦于以下问题:Java Diagnostic.Kind方法的具体用法?Java Diagnostic.Kind怎么用?Java Diagnostic.Kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.tools.Diagnostic
的用法示例。
在下文中一共展示了Diagnostic.Kind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: report
import javax.tools.Diagnostic; //导入方法依赖的package包/类
protected void report(Group group, Diagnostic.Kind dkind, DocTree tree, String code, Object... args) {
if (options.isEnabled(group, env.currAccess)) {
String msg = (code == null) ? (String) args[0] : localize(code, args);
env.trees.printMessage(dkind, msg, tree,
env.currDocComment, env.currPath.getCompilationUnit());
stats.record(group, dkind, code);
}
}
示例2: getKind
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public Diagnostic.Kind getKind() {
switch (type) {
case NOTE:
return Diagnostic.Kind.NOTE;
case WARNING:
return flags.contains(DiagnosticFlag.MANDATORY)
? Diagnostic.Kind.MANDATORY_WARNING
: Diagnostic.Kind.WARNING;
case ERROR:
return Diagnostic.Kind.ERROR;
default:
return Diagnostic.Kind.OTHER;
}
}
示例3: DuplicateDICheckIssue
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public DuplicateDICheckIssue(
@NotNull Diagnostic.Kind type,
@NotNull Element element,
@NotNull TypeElement enclosingClass,
@NotNull TypeElement duplicateClass) {
super(
type,
String.format(
MESSAGE_FORMAT,
element.asType().toString(),
enclosingClass.getQualifiedName().toString(),
duplicateClass.getQualifiedName().toString()),
element);
}
示例4: attributeTree
import javax.tools.Diagnostic; //导入方法依赖的package包/类
private static TypeMirror attributeTree(JavacTaskImpl jti, Tree tree, Scope scope,
final List<Diagnostic<? extends JavaFileObject>> errors, @NullAllowed final Diagnostic.Kind filter) {
Log log = Log.instance(jti.getContext());
JavaFileObject prev = log.useSource(new DummyJFO());
Enter enter = Enter.instance(jti.getContext());
Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
private Diagnostic.Kind f = filter == null ? Diagnostic.Kind.ERROR : filter;
@Override
public void report(JCDiagnostic diag) {
if (diag.getKind().compareTo(f) >= 0) {
errors.add(diag);
}
}
};
// ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
// ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
try {
// enter.shadowTypeEnvs(true);
Attr attr = Attr.instance(jti.getContext());
Env<AttrContext> env = ((JavacScope) scope).getEnv();
if (tree instanceof JCTree.JCExpression) {
return attr.attribExpr((JCTree) tree,env, Type.noType);
}
return attr.attribStat((JCTree) tree,env);
} finally {
// cacheContext.leave();
log.useSource(prev);
log.popDiagnosticHandler(discardHandler);
// enter.shadowTypeEnvs(false);
}
}
示例5: report
import javax.tools.Diagnostic; //导入方法依赖的package包/类
void report(DiagnosticListener errorHandler) {
if (_issues.isEmpty() || errorHandler == null) {
return;
}
JavaFileObject file = new SourceJavaFileObject(getFile().toURI());
for (IIssue issue : _issues.getIssues()) {
Diagnostic.Kind kind = issue.getKind() == IIssue.Kind.Error ? Diagnostic.Kind.ERROR : Diagnostic.Kind.WARNING;
errorHandler.report(new JavacDiagnostic(file, kind, issue.getStartOffset(), issue.getLine(), issue.getColumn(), issue.getMessage()));
}
}
示例6: printMessage
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
Element e) {
printMessage(kind, msg, e, null, null);
}
示例7: check
import javax.tools.Diagnostic; //导入方法依赖的package包/类
void check(Result<?> res) {
EnumSet<WarningKind> foundWarnings = EnumSet.noneOf(WarningKind.class);
for (Diagnostic.Kind kind : new Kind[] { Kind.ERROR, Kind.MANDATORY_WARNING, Kind.WARNING}) {
for (Diagnostic<? extends JavaFileObject> diag : res.diagnosticsForKind(kind)) {
for (WarningKind wk : WarningKind.values()) {
if (wk.code.equals(diag.getCode())) {
foundWarnings.add(wk);
}
}
}
}
EnumSet<WarningKind> expectedWarnings =
EnumSet.noneOf(WarningKind.class);
if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
trustMe == TrustMe.TRUST &&
suppressLevel != SuppressLevel.VARARGS &&
xlint != XlintOption.NONE &&
sig.isVarargs &&
!sig.isReifiableArg &&
body.hasAliasing &&
(methKind == MethodKind.CONSTRUCTOR ||
(methKind == MethodKind.METHOD &&
modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) {
expectedWarnings.add(WarningKind.UNSAFE_BODY);
}
if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
trustMe == TrustMe.DONT_TRUST &&
sig.isVarargs &&
!sig.isReifiableArg &&
xlint == XlintOption.ALL) {
expectedWarnings.add(WarningKind.UNSAFE_DECL);
}
if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
trustMe == TrustMe.TRUST &&
(!sig.isVarargs ||
((modKind == ModifierKind.NONE ||
modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) &&
methKind == MethodKind.METHOD))) {
expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
}
if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
trustMe == TrustMe.TRUST &&
xlint != XlintOption.NONE &&
suppressLevel != SuppressLevel.VARARGS &&
(modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) ||
methKind == MethodKind.CONSTRUCTOR) &&
sig.isVarargs &&
sig.isReifiableArg) {
expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
}
if (!expectedWarnings.containsAll(foundWarnings) ||
!foundWarnings.containsAll(expectedWarnings)) {
fail("invalid diagnostics for source:\n" +
res.compilationInfo() +
"\nOptions: " + xlint.getXlintOption() +
"\nSource Level: " + sourceLevel +
"\nExpected warnings: " + expectedWarnings +
"\nFound warnings: " + foundWarnings);
}
}
示例8: getMessageLevel
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public Diagnostic.Kind getMessageLevel() {
return super.getMessageLevel();
}
示例9: getKind
import javax.tools.Diagnostic; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public Diagnostic.Kind getKind() {
return d.getKind();
}
示例10: report
import javax.tools.Diagnostic; //导入方法依赖的package包/类
private void report(Diagnostic.Kind k, DocTreePath p, String msg) {
initReporter();
reporter.print(k, p, msg);
}
示例11: getKind
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public Diagnostic.Kind getKind() {
return d.getKind();
}
示例12: diagnosticsForKind
import javax.tools.Diagnostic; //导入方法依赖的package包/类
/**
* Retrieve the list of diagnostics of a given kind.
*/
public List<Diagnostic<? extends JavaFileObject>> diagnosticsForKind(Diagnostic.Kind kind) {
List<Diagnostic<? extends JavaFileObject>> diags = diagsCollector.diagsByKind.get(kind);
return diags != null ? diags : List.nil();
}
示例13: printMessage
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public void printMessage(Diagnostic.Kind kind, CharSequence msg) {
printMessage(kind, msg, null, null, null);
}
示例14: DICheckIssue
import javax.tools.Diagnostic; //导入方法依赖的package包/类
protected DICheckIssue(@NotNull Diagnostic.Kind kind, CharSequence msg, Element element) {
this.kind = kind;
this.msg = msg;
this.element = element;
}
示例15: printMessage
import javax.tools.Diagnostic; //导入方法依赖的package包/类
/**
* Prints a message of the specified kind at the location of the
* tree within the provided compilation unit
*
* @param kind the kind of message
* @param msg the message, or an empty string if none
* @param t the tree to use as a position hint
* @param root the compilation unit that contains tree
*/
@Override @DefinedBy(Api.COMPILER_TREE)
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
com.sun.source.tree.Tree t,
com.sun.source.tree.CompilationUnitTree root) {
printMessage(kind, msg, ((JCTree) t).pos(), root);
}