當前位置: 首頁>>代碼示例>>Java>>正文


Java Kind.ERROR屬性代碼示例

本文整理匯總了Java中javax.tools.Diagnostic.Kind.ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Kind.ERROR屬性的具體用法?Java Kind.ERROR怎麽用?Java Kind.ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.tools.Diagnostic.Kind的用法示例。


在下文中一共展示了Kind.ERROR屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hasErrorsImpl

private boolean hasErrorsImpl(Set<MessageContainer> visitedSinks) {
    for (Message msg : getMessages()) {
        if (msg.getKind() == Kind.ERROR) {
            return true;
        }
    }
    for (MessageContainer sink : findChildContainers()) {
        if (visitedSinks.contains(sink)) {
            return false;
        }

        visitedSinks.add(sink);

        if (sink.hasErrorsImpl(visitedSinks)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:arodchen,項目名稱:MaxSim,代碼行數:19,代碼來源:MessageContainer.java

示例2: report

@Override
public void report(Diagnostic<? extends JavaFileObject> message) {
    if (partialReparseErrors != null) {
        if (this.jfo != null && this.jfo == message.getSource()) {
            partialReparseErrors.add(message);
            if (message.getKind() == Kind.ERROR) {
                partialReparseRealErrors = true;
            }
        }
    } else {
        Diagnostics errors = getErrors(message.getSource());
        errors.add((int) message.getPosition(), message);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:CompilationInfoImpl.java

示例3: brokenPlatform

public static void brokenPlatform(
        @NonNull final Context ctx,
        @NonNull final Iterable<? extends CompileTuple> files,
        @NullAllowed final Diagnostic<JavaFileObject> diagnostic) {
    if (diagnostic == null) {
        return;
    }
    final Diagnostic<JavaFileObject> error = new Diagnostic<JavaFileObject>() {

        @Override
        public Kind getKind() {
            return Kind.ERROR;
        }

        @Override
        public JavaFileObject getSource() {
            return diagnostic.getSource();
        }

        @Override
        public long getPosition() {
            return diagnostic.getPosition();
        }

        @Override
        public long getStartPosition() {
            return diagnostic.getStartPosition();
        }

        @Override
        public long getEndPosition() {
            return diagnostic.getEndPosition();
        }

        @Override
        public long getLineNumber() {
            return diagnostic.getLineNumber();
        }

        @Override
        public long getColumnNumber() {
            return diagnostic.getColumnNumber();
        }

        @Override
        public String getCode() {
            return diagnostic.getCode();
        }

        @Override
        public String getMessage(Locale locale) {
            return diagnostic.getMessage(locale);
        }
    };
    for (CompileTuple file : files) {
        if (!file.virtual) {
            ErrorsCache.setErrors(
                ctx.getRootURI(),
                file.indexable,
                Collections.<Diagnostic<JavaFileObject>>singleton(error),
                ERROR_CONVERTOR);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:64,代碼來源:JavaCustomIndexer.java

示例4: getKind

@Override
public ErrorKind getKind(Diagnostic<?> t) {
    return t.getKind() == Kind.ERROR ? errorKind : ErrorKind.WARNING;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:JavaCustomIndexer.java

示例5: doTestJavadoc

private void doTestJavadoc(String origJavadoc, Function<JavacTask, Element> getElement, String expectedJavadoc) throws Exception {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    String subClass =
            "package test;\n" +
            "public class Sub extends Super {\n" +
            origJavadoc +
            "    public String test(int p1, int p2, int p3) throws IllegalStateException, IllegalArgumentException, IllegalAccessException { return null;} \n" +
            "}\n";
    String superClass =
            "package test;\n" +
            "/**Top level." +
            " */\n" +
            "public class Super {\n" +
            "    /**\n" +
            "     * javadoc1A\n" +
            "     *\n" +
            "     * @param p1 param1A\n" +
            "     * @param p2 param2A\n" +
            "     * @param p3 param3A\n" +
            "     * @throws IllegalStateException exc1A\n" +
            "     * @throws IllegalArgumentException exc2A\n" +
            "     * @throws IllegalAccessException exc3A\n" +
            "     * @return valueA\n" +
            "     */\n" +
            "    public String test(int p1, int p2, int p3) throws IllegalStateException, IllegalArgumentException, IllegalAccessException { return null;} \n" +
            "}\n";

    Path srcZip = Paths.get("src.zip");

    try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
        out.putNextEntry(new JarEntry("test/Sub.java"));
        out.write(subClass.getBytes());
        out.putNextEntry(new JarEntry("test/Super.java"));
        out.write(superClass.getBytes());
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }

    DiagnosticListener<? super JavaFileObject> noErrors = d -> {
        if (d.getKind() == Kind.ERROR) {
            throw new AssertionError(d.getMessage(null));
        }
    };

    assertTrue(compiler.getTask(null, null, noErrors, Arrays.asList("-d", "."), null, Arrays.asList(new JFOImpl("Super", superClass), new JFOImpl("Sub", subClass))).call());

    try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
        fm.setLocationFromPaths(StandardLocation.CLASS_PATH, Arrays.asList(Paths.get(".").toAbsolutePath()));
        JavacTask task = (JavacTask) compiler.getTask(null, fm, noErrors, null, null, null);

        Element el = getElement.apply(task);

        try (JavadocHelper helper = JavadocHelper.create(task, Arrays.asList(srcZip))) {
            String javadoc = helper.getResolvedDocComment(el);

            assertEquals(javadoc, expectedJavadoc);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:59,代碼來源:JavadocHelperTest.java

示例6: check

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,代碼行數:69,代碼來源:Warn5.java


注:本文中的javax.tools.Diagnostic.Kind.ERROR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。