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


Java Annotation.setHighlightType方法代碼示例

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


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

示例1: visitRegExpNamedGroupRef

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitRegExpNamedGroupRef(RegExpNamedGroupRef groupRef) {
  if (!myLanguageHosts.supportsNamedGroupRefSyntax(groupRef)) {
    myHolder.createErrorAnnotation(groupRef, "This named group reference syntax is not supported");
    return;
  }
  if (groupRef.getGroupName() == null) {
    return;
  }
  final RegExpGroup group = groupRef.resolve();
  if (group == null) {
    final Annotation a = myHolder.createErrorAnnotation(groupRef, "Unresolved named group reference");
    if (a != null) {
      // IDEA-9381
      a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    }
  }
  else if (PsiTreeUtil.isAncestor(group, groupRef, true)) {
    myHolder.createWarningAnnotation(groupRef, "Group reference is nested into the named group it refers to");
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:RegExpAnnotator.java

示例2: doApplyInformationToEditor

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void doApplyInformationToEditor() {
  if (myUnusedDeclarations == null || myUnusedImports == null) {
    return;
  }

  AnnotationHolder annotationHolder = new AnnotationHolderImpl(new AnnotationSession(myFile));
  List<HighlightInfo> infos = new ArrayList<HighlightInfo>(myUnusedDeclarations);
  for (GrImportStatement unusedImport : myUnusedImports) {
    Annotation annotation = annotationHolder.createWarningAnnotation(calculateRangeToUse(unusedImport), GroovyInspectionBundle.message("unused.import"));
    annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
    annotation.registerFix(GroovyQuickFixFactory.getInstance().createOptimizeImportsFix(false));
    infos.add(HighlightInfo.fromAnnotation(annotation));
  }

  UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId());

  if (myUnusedImports != null && !myUnusedImports.isEmpty()) {
    IntentionAction fix = GroovyQuickFixFactory.getInstance().createOptimizeImportsFix(true);
    if (fix.isAvailable(myProject, myEditor, myFile) && myFile.isWritable()) {
      fix.invoke(myProject, myEditor, myFile);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:GroovyPostHighlightingPass.java

示例3: visitXPath2TypeElement

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitXPath2TypeElement(XPath2TypeElement o) {
  final ContextProvider contextProvider = o.getXPathContext();
  checkPrefixReferences(myHolder, o, contextProvider);

  if (o.getDeclaredType() == XPathType.UNKNOWN) {
    final PsiReference[] references = o.getReferences();
    for (PsiReference reference : references) {
      if (reference instanceof XsltReferenceContributor.SchemaTypeReference ) {
        if (!reference.isSoft() && reference.resolve() == null) {
          final String message = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern();
          final Annotation annotation =
            myHolder.createErrorAnnotation(reference.getRangeInElement().shiftRight(o.getTextOffset()), message);
          annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
        }
      }
    }
  }
  super.visitXPath2TypeElement(o);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:XPathAnnotator.java

示例4: markUnresolvedVariable

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
private static void markUnresolvedVariable(XPathVariableReference reference, AnnotationHolder holder) {
  final String referencedName = reference.getReferencedName();
  // missing name is already flagged by parser
  if (referencedName.length() > 0) {
    final TextRange range = reference.getTextRange().shiftRight(1).grown(-1);
    final Annotation ann = holder.createErrorAnnotation(range, "Unresolved variable '" + referencedName + "'");
    ann.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    final VariableContext variableContext = ContextProvider.getContextProvider(reference).getVariableContext();
    if (variableContext != null) {
      final IntentionAction[] fixes = variableContext.getUnresolvedVariableFixes(reference);
      for (IntentionAction fix : fixes) {
        ann.registerFix(fix);
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:XPathAnnotator.java

示例5: checkPrefixReferences

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
private static void checkPrefixReferences(AnnotationHolder holder, QNameElement element, ContextProvider myProvider) {
  final PsiReference[] references = element.getReferences();
  for (PsiReference reference : references) {
    if (reference instanceof PrefixReference) {
      final PrefixReference pr = ((PrefixReference)reference);
      if (!pr.isSoft() && pr.isUnresolved()) {
        final TextRange range = pr.getRangeInElement().shiftRight(pr.getElement().getTextRange().getStartOffset());
        final Annotation a = holder.createErrorAnnotation(range, "Unresolved namespace prefix '" + pr.getCanonicalText() + "'");
        a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);

        final NamespaceContext namespaceContext = myProvider.getNamespaceContext();
        final PrefixedName qName = element.getQName();
        if (namespaceContext != null && qName != null) {
          final IntentionAction[] fixes = namespaceContext.getUnresolvedNamespaceFixes(reference, qName.getLocalName());
          for (IntentionAction fix : fixes) {
            a.registerFix(fix);
          }
        }
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:XPathAnnotator.java

示例6: annotate

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
    if (isConfigFile(psiElement) && psiElement instanceof YAMLKeyValue && isYamlLeaf(psiElement)) {
        if (hasNoConfigurationObject(psiElement) && hasNoExplicitReference(psiElement)) {
            TextRange range = new TextRange(psiElement.getTextRange().getStartOffset(), psiElement.getTextRange().getStartOffset() + ((YAMLKeyValue) psiElement).getKeyText().length());
            Annotation warningAnnotation = annotationHolder.createWarningAnnotation(range, "Unused configuration property");
            warningAnnotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
        }
    }
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:11,代碼來源:CoffigYamlAnnotator.java

示例7: markError

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
private void markError(ASTNode parent, @Nullable ASTNode node, String message) {
    Annotation annotation;
    if (node == null) {
        annotation = holder.createErrorAnnotation(parent, message);
    } else {
        annotation = holder.createErrorAnnotation(node, message);
    }
    annotation.setHighlightType(ProblemHighlightType.GENERIC_ERROR);
}
 
開發者ID:protostuff,項目名稱:protobuf-jetbrains-plugin,代碼行數:10,代碼來源:ProtoErrorsAnnotator.java

示例8: annotate

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
/**
 * The method annotates all nodes which are used in edges but not declared explicitly
 *
 * @param element element you would like to annotate
 * @param holder  annotation holder
 */
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
    if (element instanceof DotDotgraphStmtImpl) {
        for (DotId id : getNotMentionedNodeIds(element)) {
            TextRange range = new TextRange(id.getTextRange().getStartOffset(),
                    id.getTextRange().getEndOffset());
            Annotation annotation = holder.createInfoAnnotation(range, "No such such node specified in graph");
            annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
        }

    }

}
 
開發者ID:bzixilu,項目名稱:dotplugin,代碼行數:20,代碼來源:DotAnnotator.java

示例9: visitRegExpProperty

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
public void visitRegExpProperty(RegExpProperty property) {
  final ASTNode category = property.getCategoryNode();
  if (category == null) {
    return;
  }
  if(!myLanguageHosts.isValidCategory(category.getPsi(), category.getText())) {
    final Annotation a = myHolder.createErrorAnnotation(category, "Unknown character category");
    if (a != null) {
      // IDEA-9381
      a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:RegExpAnnotator.java

示例10: visitRegExpBackref

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
public void visitRegExpBackref(final RegExpBackref backref) {
  final RegExpGroup group = backref.resolve();
  if (group == null) {
    final Annotation a = myHolder.createErrorAnnotation(backref, "Unresolved back reference");
    if (a != null) {
      // IDEA-9381
      a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    }
  }
  else if (PsiTreeUtil.isAncestor(group, backref, true)) {
    myHolder.createWarningAnnotation(backref, "Back reference is nested into the capturing group it refers to");
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:RegExpAnnotator.java

示例11: visitPosixBracketExpression

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitPosixBracketExpression(RegExpPosixBracketExpression posixBracketExpression) {
  final String className = posixBracketExpression.getClassName();
  if (!POSIX_CHARACTER_CLASSES.contains(className)) {
    final Annotation annotation = myHolder.createErrorAnnotation(posixBracketExpression, "Unknown POSIX character class");
    if (annotation != null) {
      annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:RegExpAnnotator.java

示例12: addError

import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
private void addError(PsiReference reference) {
  final TextRange rangeInElement = reference.getRangeInElement();
  final TextRange range = TextRange.from(reference.getElement().getTextRange().getStartOffset()
          + rangeInElement.getStartOffset(), rangeInElement.getLength());

  final Annotation annotation;
  if (reference instanceof EmptyResolveMessageProvider) {
    final String s = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern();
    annotation = myHolder.createErrorAnnotation(range, MessageFormat.format(s, reference.getCanonicalText()));
  }
  else {
    annotation = myHolder.createErrorAnnotation(range, "Cannot resolve symbol");
  }
  annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);

  if (reference instanceof LocalQuickFixProvider) {
    LocalQuickFix[] fixes = ((LocalQuickFixProvider)reference).getQuickFixes();
    if (fixes != null) {
      InspectionManager inspectionManager = InspectionManager.getInstance(reference.getElement().getProject());
      for (LocalQuickFix fix : fixes) {
        ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(reference.getElement(), annotation.getMessage(), fix,
                                                                                 ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, true);
        annotation.registerFix(fix, null, null, descriptor);
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:ReferenceAnnotator.java


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