本文整理匯總了Java中javax.tools.Diagnostic.Kind.WARNING屬性的典型用法代碼示例。如果您正苦於以下問題:Java Kind.WARNING屬性的具體用法?Java Kind.WARNING怎麽用?Java Kind.WARNING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.tools.Diagnostic.Kind
的用法示例。
在下文中一共展示了Kind.WARNING屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: reportMessage
private void reportMessage(Diagnostic.Kind messageKind, String message, Object... parameters) {
if (messageKind == Kind.WARNING || messageKind == Kind.MANDATORY_WARNING) {
SuppressedWarnings suppressed = SuppressedWarnings.forElement(getElement(), false, false);
if (suppressed.immutables) {
return;
}
}
String formattedMessage = String.format(message, parameters);
if (element().isPresent() && annotation().isPresent()) {
messager().printMessage(messageKind, formattedMessage, getElement(), getAnnotation());
} else if (element().isPresent()) {
messager().printMessage(messageKind, formattedMessage, getElement());
} else {
messager().printMessage(messageKind, formattedMessage);
}
}
示例2: getKind
@Override
public Kind getKind() {
return Kind.WARNING;
}
示例3: 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);
}
}