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


Java Kind.WARNING屬性代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:Reporter.java

示例2: getKind

@Override
public Kind getKind() {
    return Kind.WARNING;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:CompilationInfoImpl.java

示例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);
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:69,代碼來源:Warn5.java


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