当前位置: 首页>>代码示例>>Java>>正文


Java HighlightInfoType.WARNING属性代码示例

本文整理汇总了Java中com.intellij.codeInsight.daemon.impl.HighlightInfoType.WARNING属性的典型用法代码示例。如果您正苦于以下问题:Java HighlightInfoType.WARNING属性的具体用法?Java HighlightInfoType.WARNING怎么用?Java HighlightInfoType.WARNING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.codeInsight.daemon.impl.HighlightInfoType的用法示例。


在下文中一共展示了HighlightInfoType.WARNING属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTagProblemInfoType

private static HighlightInfoType getTagProblemInfoType(XmlTag tag) {
  if (tag instanceof HtmlTag && XmlUtil.HTML_URI.equals(tag.getNamespace())) {
    if (isInjectedHtmlTagWithoutValidation((HtmlTag)tag)) return HighlightInfoType.INFORMATION;
    return HighlightInfoType.WARNING;
  }
  return HighlightInfoType.WRONG_REF;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:XmlHighlightVisitor.java

示例2: addMessageWithFixes

@Override
public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, @NotNull final IntentionAction... fixes) {
  if (message != null && !message.isEmpty()) {
    final PsiFile containingFile = context.getContainingFile();
    final HighlightInfoType defaultInfoType = type == ErrorType.ERROR ? HighlightInfoType.ERROR : type == ErrorType.WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;

    if (context instanceof XmlTag && XmlExtension.getExtension(containingFile).shouldBeHighlightedAsTag((XmlTag)context)) {
      addElementsForTagWithManyQuickFixes((XmlTag)context, message, defaultInfoType, fixes);
    }
    else {
      final PsiElement contextOfFile = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile);
      final HighlightInfo highlightInfo;

      if (contextOfFile != null) {
        TextRange range = InjectedLanguageManager.getInstance(context.getProject()).injectedToHost(context, context.getTextRange());
        highlightInfo = HighlightInfo.newHighlightInfo(defaultInfoType).range(range).descriptionAndTooltip(message).create();
      }
      else {
        highlightInfo =
          HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(context).descriptionAndTooltip(message).create();
      }

      for (final IntentionAction quickFixAction : fixes) {
        if (quickFixAction == null) continue;
        QuickFixAction.registerQuickFixAction(highlightInfo, quickFixAction);
      }
      addToResults(highlightInfo);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:XmlHighlightVisitor.java

示例3: checkAttribute

private void checkAttribute(XmlAttribute attribute) {
  XmlTag tag = attribute.getParent();
  if (tag == null) return;

  final String name = attribute.getName();

  if (XmlExtension.getExtension(attribute.getContainingFile()).needWhitespaceBeforeAttribute()) {
    PsiElement prevLeaf = PsiTreeUtil.prevLeaf(attribute);

    if (!(prevLeaf instanceof PsiWhiteSpace)) {
      TextRange textRange = attribute.getTextRange();
      HighlightInfoType type = tag instanceof HtmlTag ? HighlightInfoType.WARNING : HighlightInfoType.ERROR;
      String description = XmlErrorMessages.message("attribute.should.be.preceded.with.space");
      HighlightInfo info = HighlightInfo.newHighlightInfo(type).range(textRange.getStartOffset(), textRange.getStartOffset()).descriptionAndTooltip(description).create();
      addToResults(info);
    }
  }

  if (attribute.isNamespaceDeclaration() || XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(attribute.getNamespace())) {
    //checkReferences(attribute.getValueElement());
    return;
  }

  XmlElementDescriptor elementDescriptor = tag.getDescriptor();
  if (elementDescriptor == null ||
      elementDescriptor instanceof AnyXmlElementDescriptor ||
      ourDoJaxpTesting) {
    return;
  }

  XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor(attribute);

  if (attributeDescriptor == null) {
    if (!XmlUtil.attributeFromTemplateFramework(name, tag)) {
      final String localizedMessage = XmlErrorMessages.message("attribute.is.not.allowed.here", name);
      final HighlightInfo highlightInfo = reportAttributeProblem(tag, name, attribute, localizedMessage);
      if (highlightInfo != null) {
        PsiFile file = tag.getContainingFile();
        if (file != null) {
          for (XmlUndefinedElementFixProvider fixProvider : Extensions.getExtensions(XmlUndefinedElementFixProvider.EP_NAME)) {
            IntentionAction[] fixes = fixProvider.createFixes(attribute);
            if (fixes != null) {
              for (IntentionAction action : fixes) {
                QuickFixAction.registerQuickFixAction(highlightInfo, action);
              }
              break;
            }
          }
        }
      }
    }
  }
  else {
    checkDuplicateAttribute(tag, attribute);

    // we skip resolve of attribute references since there is separate check when taking attribute descriptors
    PsiReference[] attrRefs = attribute.getReferences();
    doCheckRefs(attribute, attrRefs, !attribute.getNamespacePrefix().isEmpty() ? 2 : 1);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:XmlHighlightVisitor.java

示例4: doCheckRefs

private void doCheckRefs(final PsiElement value, final PsiReference[] references, int start) {
  for (int i = start; i < references.length; ++i) {
    PsiReference reference = references[i];
    ProgressManager.checkCanceled();
    if (isUrlReference(reference)) continue;
    if (!hasBadResolve(reference, false)) {
      continue;
    }
    String description = getErrorDescription(reference);

    final int startOffset = reference.getElement().getTextRange().getStartOffset();
    final TextRange referenceRange = reference.getRangeInElement();

    // logging for IDEADEV-29655
    if (referenceRange.getStartOffset() > referenceRange.getEndOffset()) {
      LOG.error("Reference range start offset > end offset:  " + reference +
      ", start offset: " + referenceRange.getStartOffset() + ", end offset: " + referenceRange.getEndOffset());
    }

    HighlightInfoType type = getTagProblemInfoType(PsiTreeUtil.getParentOfType(value, XmlTag.class));
    if (value instanceof XmlAttributeValue) {
      PsiElement parent = value.getParent();
      if (parent instanceof XmlAttribute) {
        String name = ((XmlAttribute)parent).getName().toLowerCase();
        if (type.getSeverity(null).compareTo(HighlightInfoType.WARNING.getSeverity(null)) > 0 && name.endsWith("stylename")) {
          type = HighlightInfoType.WARNING;
        }
      }
    }
    HighlightInfo info = HighlightInfo.newHighlightInfo(type)
      .range(startOffset + referenceRange.getStartOffset(), startOffset + referenceRange.getEndOffset())
      .descriptionAndTooltip(description).create();
    addToResults(info);
    if (reference instanceof LocalQuickFixProvider) {
      LocalQuickFix[] fixes = ((LocalQuickFixProvider)reference).getQuickFixes();
      if (fixes != null) {
        InspectionManager manager = InspectionManager.getInstance(reference.getElement().getProject());
        for (LocalQuickFix fix : fixes) {
          ProblemDescriptor descriptor = manager.createProblemDescriptor(value, description, fix,
                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true);
          QuickFixAction.registerQuickFixAction(info, new LocalQuickFixAsIntentionAdapter(fix, descriptor));
        }
      }
    }
    UnresolvedReferenceQuickFixProvider.registerReferenceFixes(reference, new QuickFixActionRegistrarImpl(info));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:XmlHighlightVisitor.java


注:本文中的com.intellij.codeInsight.daemon.impl.HighlightInfoType.WARNING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。