本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
}
示例4: getKind
@Override
public ErrorKind getKind(Diagnostic<?> t) {
return t.getKind() == Kind.ERROR ? errorKind : ErrorKind.WARNING;
}
示例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);
}
}
}
示例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);
}
}