com.intellij.lang.annotation.Annotation.setTextAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.intellij.lang.annotation.Annotation.setTextAttributes()方法的一些代码示例,展示了Annotation.setTextAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.setTextAttributes()方法的具体详情如下:
包路径:com.intellij.lang.annotation.Annotation
类名称:Annotation
方法名:setTextAttributes

Annotation.setTextAttributes介绍

暂无

代码示例

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateNumber(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    Annotation annotation = holder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.NUMBER);
  }
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateText(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  Annotation annotation = holder.createInfoAnnotation(element, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.STRING);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateInlineCode(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  Annotation annotation = holder.createInfoAnnotation(element, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.DOCUMENTATION_INLINE_CODE);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateStringLiteralTemplateEnd(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  Annotation annotation = holder.createInfoAnnotation(element, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.TEMPLATE_LANGUAGE_COLOR);
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

private static void setHighlighting(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull TextAttributesKey key) {
 holder.createInfoAnnotation(element, null).setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
 String description = ApplicationManager.getApplication().isUnitTestMode() ? key.getExternalName() : null;
 holder.createInfoAnnotation(element, description).setTextAttributes(key);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateKeyword(@NotNull PsiElement element, @NotNull AnnotationHolder holder,
    @NotNull TextAttributesKey textAttributesKey, boolean excludeEndChar) {
  TextRange textRange = element.getTextRange();
  TextRange newTextRange = new TextRange(textRange.getStartOffset(),
      textRange.getEndOffset() - (excludeEndChar ? 1 : 0));
  Annotation annotation = holder.createInfoAnnotation(newTextRange, null);
  annotation.setTextAttributes(textAttributesKey);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateTemplateStart(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  TextRange textRange = element.getTextRange();
  TextRange newTextRange = new TextRange(textRange.getEndOffset() - 1, textRange.getEndOffset());
  Annotation annotation = holder.createInfoAnnotation(newTextRange, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.STRING);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateKeyword(@NotNull PsiElement element, @NotNull AnnotationHolder holder,
    boolean excludeEndChar) {
  TextRange textRange = element.getTextRange();
  TextRange newTextRange = new TextRange(textRange.getStartOffset(),
      textRange.getEndOffset() - (excludeEndChar ? 1 : 0));
  Annotation annotation = holder.createInfoAnnotation(newTextRange, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.KEYWORD);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private void annotateExpressionTemplateStart(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  TextRange textRange = element.getTextRange();
  TextRange newTextRange = new TextRange(textRange.getEndOffset() - 2, textRange.getEndOffset());
  Annotation annotation = holder.createInfoAnnotation(newTextRange, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.TEMPLATE_LANGUAGE_COLOR);
  if (textRange.getEndOffset() - 2 > textRange.getStartOffset()) {
    newTextRange = new TextRange(textRange.getStartOffset(), textRange.getEndOffset() - 2);
    annotation = holder.createInfoAnnotation(newTextRange, null);
    annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.STRING);
  }
}

代码示例来源:origin: KronicDeth/intellij-elixir

@Override
  public void annotate(@NotNull PsiElement psiElement, @NotNull com.intellij.lang.annotation.AnnotationHolder annotationHolder) {
    if (psiElement instanceof ErlangAtom) {
      ErlangAtom erlangAtom = (ErlangAtom) psiElement;
      String name = erlangAtom.getName();

      if (name.startsWith(ELIXIR_ALIAS_PREFIX)) {
        Project project = psiElement.getProject();

        Collection<NamedElement> namedElementCollection = StubIndex.getElements(
            ModularName.KEY,
            name,
            project,
            GlobalSearchScope.allScope(project),
            NamedElement.class
        );

        if (namedElementCollection.size() > 0) {
          TextRange textRange = psiElement.getTextRange();
          String unprefixedName = name.substring(ELIXIR_ALIAS_PREFIX.length(), name.length());
          Annotation annotation = annotationHolder.createInfoAnnotation(textRange, "Resolves to Elixir Module " + unprefixedName);
          annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
        } else {
          TextRange textRange = psiElement.getTextRange();
          annotationHolder.createErrorAnnotation(textRange, "Unresolved Elixir Module");
        }
      }
    }
  }
}

代码示例来源:origin: ballerina-platform/ballerina-lang

if (parent instanceof BallerinaAnnotationAttachment) {
  Annotation annotation = holder.createInfoAnnotation(element, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.ANNOTATION);
  return;
      .getParent() instanceof BallerinaGlobalVariableDefinition)) {
    Annotation annotation = holder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.GLOBAL_VARIABLE);
  if (parent instanceof BallerinaAnnotationAttachment) {
    Annotation annotation = holder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.ANNOTATION);
    || elementType == BallerinaTypes.DEPRECATED_TEMPLATE_TEXT) {
  Annotation annotation = holder.createInfoAnnotation(element, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.DOCUMENTATION);
} else if (elementType == BallerinaTypes.MARKDOWN_DOCUMENTATION_LINE_START) {
  TextRange textRange = element.getTextRange();
  TextRange newTextRange = new TextRange(startOffset, startOffset + 1);
  Annotation annotation = holder.createInfoAnnotation(newTextRange, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.DOCUMENTATION);
} else if (elementType == BallerinaTypes.PARAMETER_DOCUMENTATION_START) {
  TextRange textRange = element.getTextRange();
  TextRange newTextRange = new TextRange(startOffset, startOffset + 1);
  Annotation annotation = holder.createInfoAnnotation(newTextRange, null);
  annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.DOCUMENTATION);

代码示例来源:origin: BashSupport/BashSupport

private void annotateSubshell(PsiElement element, AnnotationHolder holder) {
    final Annotation annotation = holder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BashSyntaxHighlighter.SUBSHELL_COMMAND);
  }
}

代码示例来源:origin: Camelcade/Perl5-IDEA

public void decorateElement(PsiElement element, @NotNull AnnotationHolder holder, TextAttributesKey key) {
  if (element == null) {
   return;
  }
  holder.createInfoAnnotation(element, null).setTextAttributes(key);
 }
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@Override
 public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  if (element instanceof HTMLMasonNamedElement) {
   PsiElement nameIdentifier = ((HTMLMasonNamedElement)element).getNameIdentifier();

   if (nameIdentifier != null) {
    holder.createInfoAnnotation(nameIdentifier, null).setTextAttributes(PerlSyntaxHighlighter.PERL_SUB_DEFINITION);
   }
  }
 }
}

代码示例来源:origin: BashSupport/BashSupport

protected void highlightVariable(@NotNull BashVar element, @NotNull AnnotationHolder annotationHolder) {
  if (element.isBuiltinVar()) {
    //highlighting for built-in variables
    Annotation annotation = annotationHolder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BashSyntaxHighlighter.VAR_USE_BUILTIN);
  } else if (element.isParameterExpansion()) {
    //highlighting for composed variables
    Annotation annotation = annotationHolder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BashSyntaxHighlighter.VAR_USE_COMPOSED);
  }
}

代码示例来源:origin: BashSupport/BashSupport

@Override
  public void visitElement(PsiElement element) {
    if (element instanceof BashVar) {
      //containedVars.add((BashVar) containerElement);
      Annotation infoAnnotation = holder.createInfoAnnotation(element, null);
      infoAnnotation.setTextAttributes(BashSyntaxHighlighter.VAR_USE);
    }
    super.visitElement(element);
  }
}.visitElement(containerElement);

代码示例来源:origin: BashSupport/BashSupport

private void annotateVarDef(BashVarDef bashVarDef, AnnotationHolder annotationHolder) {
  final PsiElement identifier = bashVarDef.findAssignmentWord();
  if (identifier != null) {
    final Annotation annotation = annotationHolder.createInfoAnnotation(identifier, null);
    annotation.setTextAttributes(BashSyntaxHighlighter.VAR_DEF);
  }
}

代码示例来源:origin: JetBrains/Grammar-Kit

private static void addRuleHighlighting(BnfRule rule, PsiElement psiElement, AnnotationHolder annotationHolder) {
 if (ParserGeneratorUtil.Rule.isMeta(rule)) {
  annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.META_RULE);
 }
 else {
  annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.RULE);
 }
 PsiFile file = rule.getContainingFile();
 if (StringUtil.isNotEmpty(((BnfFile)file).findAttributeValue(rule, KnownAttribute.RECOVER_WHILE, null))) {
  annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.RECOVER_MARKER);
 }
}

代码示例来源:origin: BashSupport/BashSupport

private void hightlightRemappedTokens(PsiElement element, AnnotationHolder annotationHolder) {
  if (element.getNode().getElementType() == BashTokenTypes.IN_KEYWORD_REMAPPED) {
    Annotation annotation = annotationHolder.createInfoAnnotation(element, null);
    annotation.setTextAttributes(BashSyntaxHighlighter.KEYWORD);
  }
}

代码示例来源:origin: BashSupport/BashSupport

private void annotateBinaryData(BashBinaryDataElement element, AnnotationHolder annotationHolder) {
  Annotation annotation = annotationHolder.createInfoAnnotation(element, null);
  annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
  annotation = annotationHolder.createInfoAnnotation(element, null);
  annotation.setTextAttributes(BashSyntaxHighlighter.BINARY_DATA);
  annotation.setNeedsUpdateOnTyping(false);
}

相关文章