当前位置: 首页>>代码示例>>Java>>正文


Java Diagnostic.Kind方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:Messages.java

示例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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:JCDiagnostic.java

示例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);
}
 
开发者ID:groupon,项目名称:dependency-injection-checks,代码行数:15,代码来源:DuplicateDICheckIssue.java

示例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);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:Utilities.java

示例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()));
    }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:12,代码来源:TemplateModel.java

示例6: printMessage

import javax.tools.Diagnostic; //导入方法依赖的package包/类
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                  Element e) {
    printMessage(kind, msg, e, null, null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:JavacMessager.java

示例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);
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:70,代码来源:Warn5.java

示例8: getMessageLevel

import javax.tools.Diagnostic; //导入方法依赖的package包/类
public Diagnostic.Kind getMessageLevel() {
    return super.getMessageLevel();
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:4,代码来源:FluentValidatorTest.java

示例9: getKind

import javax.tools.Diagnostic; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public Diagnostic.Kind getKind() {
    return d.getKind();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ClientCodeWrapper.java

示例10: report

import javax.tools.Diagnostic; //导入方法依赖的package包/类
private void report(Diagnostic.Kind k, DocTreePath p, String msg) {
    initReporter();
    reporter.print(k, p, msg);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:Messages.java

示例11: getKind

import javax.tools.Diagnostic; //导入方法依赖的package包/类
public Diagnostic.Kind getKind() {
    return d.getKind();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:ClientCodeWrapper.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:ComboTask.java

示例13: printMessage

import javax.tools.Diagnostic; //导入方法依赖的package包/类
public void printMessage(Diagnostic.Kind kind, CharSequence msg) {
    printMessage(kind, msg, null, null, null);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:4,代码来源:JavacMessager.java

示例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;
}
 
开发者ID:groupon,项目名称:dependency-injection-checks,代码行数:6,代码来源:DICheckIssue.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:JavacTrees.java


注:本文中的javax.tools.Diagnostic.Kind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。