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


Java ProblemHighlightType.GENERIC_ERROR_OR_WARNING屬性代碼示例

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


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

示例1: registerError

@Override
protected void registerError(@NotNull PsiElement location,
                             @NotNull String description,
                             @Nullable LocalQuickFix[] fixes,
                             ProblemHighlightType highlightType) {
  if (PsiUtil.isCompileStatic(location)) {
    // filter all errors here, error will be highlighted by annotator
    if (highlightType != ProblemHighlightType.GENERIC_ERROR) {
      super.registerError(location, description, fixes, highlightType);
    }
  }
  else {
    if (highlightType == ProblemHighlightType.GENERIC_ERROR) {
      // if this visitor works within non-static context we will highlight all errors as warnings
      super.registerError(location, description, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
    }
    else {
      // if this visitor works within static context errors will be highlighted as errors by annotator, warnings will be highlighted as warnings here
      super.registerError(location, description, fixes, highlightType);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:GroovyTypeCheckVisitor.java

示例2: createIntention

private static IntentionAction createIntention(PsiElement node, TextRange range, String message, LocalQuickFix fix) {
  LocalQuickFix[] quickFixes = {fix};
  CommonProblemDescriptorImpl descr = new ProblemDescriptorImpl(node, node, message,
                                                                quickFixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true,
                                                                range, true);
  return QuickFixWrapper.wrap((ProblemDescriptor)descr, 0);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:UnsupportedFeatures.java

示例3: getProblemHighlightType

private static ProblemHighlightType getProblemHighlightType(final DomElementProblemDescriptor problemDescriptor) {
  if (problemDescriptor.getHighlightType() != null) {
    return problemDescriptor.getHighlightType();
  }
  if (problemDescriptor instanceof DomElementResolveProblemDescriptor) {
    final TextRange range = ((DomElementResolveProblemDescriptor)problemDescriptor).getPsiReference().getRangeInElement();
    if (range.getStartOffset() != range.getEndOffset()) {
      return ProblemHighlightType.LIKE_UNKNOWN_SYMBOL;
    }
  }
  return ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:DomElementsHighlightingUtil.java

示例4: visitCastExpression

@Override
public void visitCastExpression(GrTypeCastExpression expression) {
  super.visitCastExpression(expression);

  final GrExpression operand = expression.getOperand();
  if (operand == null) return;
  final PsiType actualType = operand.getType();
  if (actualType == null) return;

  if (expression.getCastTypeElement() == null) return;
  final PsiType expectedType = expression.getCastTypeElement().getType();
  
  final ConversionResult result = TypesUtil.canCast(expectedType, actualType, expression);
  if (result == ConversionResult.OK) return;
  final ProblemHighlightType highlightType = result == ConversionResult.ERROR
                                             ? ProblemHighlightType.GENERIC_ERROR
                                             : ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
  final String message = GroovyBundle.message(
    "cannot.cast",
    actualType.getPresentableText(),
    expectedType.getPresentableText()
  );
  registerError(
    expression,
    highlightType,
    message
  );
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:GroovyTypeCheckVisitor.java

示例5: checkTypes

@Nullable
private static Pair<String, ProblemHighlightType> checkTypes(@Nullable PyType expected,
                                                             @Nullable PyType actual,
                                                             @NotNull TypeEvalContext context,
                                                             @NotNull Map<PyGenericType, PyType> substitutions) {
  if (actual != null && expected != null) {
    if (!PyTypeChecker.match(expected, actual, context, substitutions)) {
      final String expectedName = PythonDocumentationProvider.getTypeName(expected, context);
      String quotedExpectedName = String.format("'%s'", expectedName);
      final boolean hasGenerics = PyTypeChecker.hasGenerics(expected, context);
      ProblemHighlightType highlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
      if (hasGenerics) {
        final PyType substitute = PyTypeChecker.substitute(expected, substitutions, context);
        if (substitute != null) {
          quotedExpectedName = String.format("'%s' (matched generic type '%s')",
                                   PythonDocumentationProvider.getTypeName(substitute, context),
                                   expectedName);
          highlightType = ProblemHighlightType.WEAK_WARNING;
        }
      }
      final String actualName = PythonDocumentationProvider.getTypeName(actual, context);
      String msg= String.format("Expected type %s, got '%s' instead", quotedExpectedName, actualName);
      if (expected instanceof PyStructuralType) {
        final Set<String> expectedAttributes = ((PyStructuralType)expected).getAttributeNames();
        final Set<String> actualAttributes = getAttributes(actual, context);
        if (actualAttributes != null) {
          final Sets.SetView<String> missingAttributes = Sets.difference(expectedAttributes, actualAttributes);
          if (missingAttributes.size() == 1) {
            msg = String.format("Type '%s' doesn't have expected attribute '%s'", actualName, missingAttributes.iterator().next());
          }
          else {
            msg = String.format("Type '%s' doesn't have expected attributes %s",
                                actualName,
                                StringUtil.join(missingAttributes, new Function<String, String>() {
                                  @Override
                                  public String fun(String s) {
                                    return String.format("'%s'", s);
                                  }
                                }, ", "));
          }
        }
      }
      return Pair.create(msg, highlightType);
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:47,代碼來源:PyTypeCheckerInspection.java

示例6: invalid

public static Effect invalid(String attrName, String text) {
  return new InvalidAttrEffect(attrName, text, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:3,代碼來源:XmlTagRuleProviderBase.java

示例7: RequireAttributeOneOf

public RequireAttributeOneOf(String ... attributeNames) {
  myAttributeNames = attributeNames;
  myProblemHighlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:XmlTagRuleProviderBase.java

示例8: SqliteMagicProblem

public SqliteMagicProblem(String message) {
  this(message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, EMPTY_QUICK_FIXS);
}
 
開發者ID:SiimKinks,項目名稱:sqlitemagic,代碼行數:3,代碼來源:SqliteMagicProblem.java


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