Java 类com.intellij.openapi.editor.colors.TextAttributesKey 实例源码

项目:intellij-postfix-templates    文件:CptSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(CptTypes.SEPARATOR) || tokenType.equals(CptTypes.MAP)) {
        return SEPARATOR_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_NAME)) {
        return TEMPLATE_NAME_KEYS;
    } else if (tokenType.equals(CptTypes.CLASS_NAME)) {
        return CLASS_NAME_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_DESCRIPTION)) {
        return TEMPLATE_DESCRIPTION_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_CODE)) {
        return TEMPLATE_CODE_KEYS;
    } else if (TEMPLATE_VARIABLE_PARTS.contains(tokenType)) {
        return TEMPLATE_VARIABLE_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_ESCAPE)) {
        return TEMPLATE_ESCAPE_KEYS;
    } else if (tokenType.equals(CptTypes.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:intellij-crystal    文件:CrystalSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(CrystalTypes.SEPARATOR)) {
        return SEPARATOR_KEYS;
    } else if (tokenType.equals(CrystalTypes.KEY)) {
        return KEY_KEYS;
    } else if (tokenType.equals(CrystalTypes.VALUE)) {
        return VALUE_KEYS;
    } else if (tokenType.equals(CrystalTypes.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:sercapnp    文件:CapnpSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(CapnpTypes.SEPARATOR)) {
        return SEPARATOR_KEYS;

    } else if (tokenType.equals(CapnpTypes.IDENTIFIER)){
        return IDENTIFIER_KEYS;
    } else if (tokenType.equals(CapnpTypes.KEYWORD)) {
        return KEY_KEYS;
    } else if (tokenType.equals(CapnpTypes.TYPE)) {
        return TYPE_KEYS;
    } else if (tokenType.equals(CapnpTypes.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:intellij-csv-validator    文件:CsvSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(CsvTypes.COMMA)) {
        return COMMA_KEYS;
    } else if (tokenType.equals(CsvTypes.QUOTE)) {
        return QUOTE_KEYS;
    } else if (tokenType.equals(CsvTypes.TEXT)) {
        return TEXT_KEYS;
    } else if (tokenType.equals(CsvTypes.ESCAPED_TEXT)) {
        return ESCAPED_TEXT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:intellij-ce-playground    文件:ColorAndFontOptions.java   
public boolean isInherited(TextAttributesKey key) {
  TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
  if (fallbackKey != null) {
    if (myParentScheme instanceof AbstractColorsScheme) {
      TextAttributes ownAttrs = ((AbstractColorsScheme)myParentScheme).getDirectlyDefinedAttributes(key);
      if (ownAttrs != null) {
        return ownAttrs.isFallbackEnabled();
      }
    }
    TextAttributes attributes = getAttributes(key);
    if (attributes != null) {
      TextAttributes fallbackAttributes = getAttributes(fallbackKey);
      return attributes == fallbackAttributes;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:PlainTextSyntaxHighlighterFactory.java   
@Override
@NotNull
public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
  return new SyntaxHighlighterBase() {
    @NotNull
    @Override
    public Lexer getHighlightingLexer() {
      return createPlainTextLexer();
    }

    @NotNull
    @Override
    public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
      return EMPTY;
    }
  };
}
项目:lua-for-idea    文件:LuaAnnotator.java   
@Override
public void visitDocTag(LuaDocTag e) {
    super.visitDocTag(e);

    LuaDocSyntaxHighlighter highlighter = new LuaDocSyntaxHighlighter();

    PsiElement element = e.getFirstChild();
    while (element != null) {
        if (element instanceof ASTNode) {
            ASTNode astNode = (ASTNode) element;
            TextAttributesKey[] keys = highlighter.getTokenHighlights(astNode.getElementType());
            for (TextAttributesKey key : keys) {
                final Annotation a = myHolder.createInfoAnnotation(element, null);
                a.setTextAttributes(key);
            }
        }
        element = element.getNextSibling();
    }
}
项目:intellij-ce-playground    文件:GrKeywordAndDeclarationHighlighter.java   
@Nullable
private static TextAttributesKey getDeclarationAttribute(PsiElement element) {
  if (element.getParent() instanceof GrAnnotation && element.getNode().getElementType() == GroovyTokenTypes.mAT) {
    return GroovySyntaxHighlighter.ANNOTATION;
  }

  PsiElement parent = element.getParent();
  if (!(parent instanceof GrNamedElement) || ((GrNamedElement)parent).getNameIdentifierGroovy() != element) {
    return null;
  }

  //don't highlight local vars and parameters here because their highlighting needs index.
  if (PsiUtil.isLocalVariable(parent) || parent instanceof GrParameter) return null;

  return GrHighlightUtil.getDeclarationHighlightingAttribute(parent, null);
}
项目:intellij-ce-playground    文件:ColorAndFontOptions.java   
private SchemeTextAttributesDescription(String name, String group, @NotNull TextAttributesKey key, @NotNull MyColorScheme  scheme, Icon icon,
                                       String toolTip) {
  super(name, group,
        getInitialAttributes(scheme, key).clone(),
        key, scheme, icon, toolTip);
  this.key = key;
  myInitialAttributes = getInitialAttributes(scheme, key);
  TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
  if (fallbackKey != null) {
    myFallbackAttributes = scheme.getAttributes(fallbackKey);
    myBaseAttributeDescriptor = ColorSettingsPages.getInstance().getAttributeDescriptor(fallbackKey);
    if (myBaseAttributeDescriptor == null) {
      myBaseAttributeDescriptor =
        new Pair<ColorSettingsPage, AttributesDescriptor>(null, new AttributesDescriptor(fallbackKey.getExternalName(), fallbackKey));
    }
  }
  myIsInheritedInitial = scheme.isInherited(key);
  setInherited(myIsInheritedInitial);
  if (myIsInheritedInitial) {
    setInheritedAttributes(getTextAttributes());
  }
  initCheckedStatus();
}
项目:intellij-ce-playground    文件:PackagePresentationProvider.java   
@Override
public ItemPresentation getPresentation(@NotNull final PsiPackage aPackage) {
  return new ColoredItemPresentation() {
    @Override
    public TextAttributesKey getTextAttributesKey() {
      return null;
    }

    @Override
    public String getPresentableText() {
      return aPackage.getName();
    }

    @Override
    public String getLocationString() {
      return aPackage.getQualifiedName();
    }

    @Override
    public Icon getIcon(boolean open) {
      return PlatformIcons.PACKAGE_ICON;
    }
  };
}
项目:intellij-ce-playground    文件:ProguardSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
  // Return the appropriate text attributes depending on the type of token.
  if (tokenType.equals(ProguardTypes.LINE_CMT)) {
    return COMMENTS_KEY;
  }
  if (tokenType.equals(TokenType.BAD_CHARACTER)) {
    return BAD_CHARS_KEY;
  }
  if (tokenType.equals(ProguardTypes.JAVA_DECL)) {
    return CLASS_SPEC_KEY;
  }
  if (tokenType.equals(ProguardTypes.CLOSE_BRACE) || tokenType.equals(ProguardTypes.OPEN_BRACE)) {
    return OPERATOR_KEY;
  }
  if (tokenType.equals(ProguardTypes.FLAG_NAME)) {
    return FLAG_NAME_KEY;
  }
  if (tokenType.equals(ProguardTypes.FLAG_ARG)) {
    return FLAG_ARG_KEY;
  }

  return EMPTY_KEY;
}
项目:intellij-ce-playground    文件:HighlightNamesUtil.java   
private static TextAttributes getScopeAttributes(@NotNull PsiElement element, @NotNull TextAttributesScheme colorsScheme) {
  PsiFile file = element.getContainingFile();
  if (file == null) return null;
  TextAttributes result = null;
  DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(file.getProject());
  List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes();
  for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
    final NamedScope namedScope = scope.getFirst();
    final TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName());
    final TextAttributes attributes = colorsScheme.getAttributes(scopeKey);
    if (attributes == null || attributes.isEmpty()) {
      continue;
    }
    final PackageSet packageSet = namedScope.getValue();
    if (packageSet != null && packageSet.contains(file, scope.getSecond())) {
      result = TextAttributes.merge(attributes, result);
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:PropertiesStructureViewElement.java   
@NotNull
public ItemPresentation getPresentation() {
  return new ColoredItemPresentation() {
    @Nullable
    @Override
    public TextAttributesKey getTextAttributesKey() {
      return (myPresentableName != null && myPresentableName.isEmpty()) ? GROUP_KEY :null;
    }

    public String getPresentableText() {
      return myPresentableName == null
             ? myProperty.getUnescapedKey()
             : (myPresentableName.isEmpty() ? ResourceBundlePropertyStructureViewElement.PROPERTY_GROUP_KEY_TEXT : myPresentableName);
    }

    public String getLocationString() {
      return null;
    }

    public Icon getIcon(boolean open) {
      return myProperty.getIcon(0);
    }
  };
}
项目:intellij-ce-playground    文件:AdvHighlightingTest.java   
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
  scopeManager.addScope(xScope);
  scopeManager.addScope(utilScope);

  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);
  TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

  TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
  TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
  scheme.setAttributes(utilKey, utilAttributes);

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:intellij-ce-playground    文件:Annotation.java   
/**
 * Returns the text attribute key used for highlighting the annotation. If not specified
 * explicitly, the key is determined automatically based on the problem highlight type and
 * the annotation severity.
 *
 * @return the text attribute key used for highlighting
 */
@NotNull
public TextAttributesKey getTextAttributes() {
  if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
    if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
    return CodeInsightColors.ERRORS_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
    return CodeInsightColors.DEPRECATED_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
    return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
    return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
  }
  return HighlighterColors.NO_HIGHLIGHTING;
}
项目:intellij-ce-playground    文件:DiffOptionsPanel.java   
@Override
public void updateOptionsList() {
  myOptionsModel.clear();
  myDescriptions.clear();
  Map<TextAttributesKey, TextDiffType> typesByKey = ContainerUtil.newMapFromValues(TextDiffType.MERGE_TYPES.iterator(),
                                                                                   TextDiffType.ATTRIBUTES_KEY);
  for (int i = 0; i < myOptions.getCurrentDescriptions().length; i++) {
    EditorSchemeAttributeDescriptor description = myOptions.getCurrentDescriptions()[i];
    TextAttributesKey type = TextAttributesKey.find(description.getType());
    if (description.getGroup() == ColorAndFontOptions.DIFF_GROUP &&
        typesByKey.keySet().contains(type)) {
      myOptionsModel.add(typesByKey.get(type));
      myDescriptions.put(type.getExternalName(), (MyColorAndFontDescription)description);
    }
  }
  ScrollingUtil.ensureSelectionExists(myOptionsList);
}
项目:intellij-ce-playground    文件:DiffOptionsPanel.java   
@Override
public Set<String> processListOptions() {
  Set<String> result = ContainerUtil.newHashSet();
  Map<TextAttributesKey, TextDiffType> typesByKey = ContainerUtil.newMapFromValues(TextDiffType.MERGE_TYPES.iterator(),
                                                                                   TextDiffType.ATTRIBUTES_KEY);
  for (int i = 0; i < myOptions.getCurrentDescriptions().length; i++) {
    EditorSchemeAttributeDescriptor description = myOptions.getCurrentDescriptions()[i];
    TextAttributesKey type = TextAttributesKey.find(description.getType());
    if (description.getGroup() == ColorAndFontOptions.DIFF_GROUP &&
        typesByKey.keySet().contains(type)) {
      result.add(type.getExternalName());
    }
  }

  return result;
}
项目:intellij-ce-playground    文件:ChunkExtractor.java   
public static boolean isHighlightedAsComment(TextAttributesKey... keys) {
  for (TextAttributesKey key : keys) {
    if (key == DefaultLanguageHighlighterColors.DOC_COMMENT ||
        key == SyntaxHighlighterColors.DOC_COMMENT ||
        key == DefaultLanguageHighlighterColors.LINE_COMMENT ||
        key == SyntaxHighlighterColors.LINE_COMMENT ||
        key == DefaultLanguageHighlighterColors.BLOCK_COMMENT ||
        key == SyntaxHighlighterColors.JAVA_BLOCK_COMMENT
      ) {
      return true;
    }
    if (key == null) continue;
    final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey();
    if (fallbackAttributeKey != null && isHighlightedAsComment(fallbackAttributeKey)) {
      return true;
    }
  }
  return false;
}
项目:TS-IJ    文件:TSSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (KEYS.containsKey(tokenType)) {
        return KEYS.get(tokenType);
    }
    return EMPTY_KEYS;
}
项目:AppleScript-IDEA    文件:AppleScriptColorAnnotator.java   
private static void createInfoAnnotation(final @NotNull AnnotationHolder holder,
                                         final @Nullable PsiElement element,
                                         final @Nullable TextAttributesKey attributeKey) {
  if (element != null && attributeKey != null) {
    holder.createInfoAnnotation(element, null).setTextAttributes(attributeKey);
  }
}
项目:greycat-idea-plugin    文件:GCMSyntaxHighlighter.java   
@NotNull
@Override
public final TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    /* Entities OPERATIONS */
    if (KEYWORD_SET.contains(tokenType)) {
        return KEYWORD_KEYS;
    }
    if (SEPARATOR_SET.contains(tokenType)) {
        return SEPARATOR_KEYS;
    }
    /* Basic elem */

    if (tokenType.equals(GCMTypes.ANNOTATION)) {
        return ANNOTATION_KEYS;
    }
    if (tokenType.equals(GCMTypes.IDENT)) {
        return IDENT_KEYS;
    }
    if (tokenType.equals(GCMTypes.NUMBER)) {
        return NUMBER_KEYS;
    }
    if (tokenType.equals(GCMTypes.LINE_COMMENT) | tokenType.equals(GCMTypes.BLOCK_COMMENT)) {
        return COMMENT_KEYS;
    }
    if (tokenType.equals(GCMTypes.STRING)) {
        return STRING_KEYS;
    }
    if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    }
    return EMPTY_KEYS;

}
项目:EmojiPrefix    文件:EmojiResourceSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType type) {
    if (textAttrMap.containsKey(type)) {
        return textAttrMap.get(type);
    }
    return EMPTY_KEYS;
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (KEYWORD_TOKEN_SET.contains(tokenType)) {
        return KEYWORD_KEYS;
    } else if (tokenType.equals(FlexibleSearchTypes.STRING)) {
        return STRING_KEYS;
    } else if (SYMBOL_TOKEN_SET.contains(tokenType)) {
        return SYMBOL_KEYS;
    } else if (COLUMN_TOKEN_SET.contains(tokenType)) {
        return COLUMN_KEYS;
    } else if (TABLE_NAME_TOKEN_SET.contains(tokenType)) {
        return TABLE_KEYS;
    } else if (BRACES_TOKEN_SET.contains(tokenType)) {
        return BRACES_KEYS;
    } else if (BRACKETS_TOKEN_SET.contains(tokenType)) {
        return BRACKETS_KEYS;
    } else if (PARENTHESES_TOKEN_SET.contains(tokenType)) {
        return PARENTHESES_KEYS;
    } else if (tokenType.equals(FlexibleSearchTypes.NUMBER)) {
        return NUMBER_KEYS;
    } else if (tokenType.equals(FlexibleSearchParserDefinition.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHARACTER_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:idea-onescript    文件:OneScriptSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType iElementType) {
    if (iElementType.equals(OneScriptTypes.COMMENT)) {
        return COMMENT_KEYS;
    } else if (iElementType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else if (iElementType.equals(OneScriptTypes.STRING)
            || iElementType.equals(OneScriptTypes.STRINGSTART)
            || iElementType.equals(OneScriptTypes.STRINGPART)
            || iElementType.equals(OneScriptTypes.STRINGTAIL)) {
        return STRING_KEYS;
    } else if (iElementType.equals(OneScriptTypes.DATETIME)) {
        return DATETIME_KEYS;
    } else if (iElementType.equals(OneScriptTypes.COMPILER_DIRECTIVE)) {
        return COMPILER_DIRECTIVE_KEYS;
    } else if (iElementType.equals(OneScriptTypes.USING)) {
        return USING_DIRECTIVE_KEYS;
    } else if (iElementType.equals(OneScriptTypes.PREPROCESSOR)) {
        return PREPROCESSOR_DIRECTIVE_KEYS;
    } else if (iElementType.equals(OneScriptTypes.BOOLEAN_TRUE)
            || iElementType.equals(OneScriptTypes.BOOLEAN_FALSE)
            || iElementType.equals(OneScriptTypes.UNDEFINED)
            || iElementType.equals(OneScriptTypes.NULL)) {
        return LITERAL_CONSTANT_KEYS;
    } else if (iElementType.toString().endsWith("_KEYWORD")) {
        return KEYWORD_KEYS;
    } else {
        return new TextAttributesKey[0];
    }
}
项目:intellij-ce-playground    文件:TemplateDataHighlighterWrapper.java   
@Override
@NotNull
public TextAttributesKey[] getTokenHighlights(final IElementType tokenType) {
  if (tokenType == BAD_CHARACTER) {
    return new TextAttributesKey[0];
  }

  return myHighlighter.getTokenHighlights(tokenType);
}
项目:sutr-io    文件:SutrColorSettingsPage.java   
@NotNull
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
    log.info("Returning additional highlighting tags.");

    if (_keyMap != null) {
        return _keyMap;
    }

    return new HashMap<>();
}
项目:intellij-ce-playground    文件:ProblemDescriptorUtil.java   
@NotNull
public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor,
                                                            @NotNull HighlightSeverity severity,
                                                            @NotNull SeverityRegistrar severityRegistrar) {
  final ProblemHighlightType highlightType = problemDescriptor.getHighlightType();
  switch (highlightType) {
    case GENERIC_ERROR_OR_WARNING:
      return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
    case LIKE_DEPRECATED:
      return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.DEPRECATED.getAttributesKey());
    case LIKE_UNKNOWN_SYMBOL:
      if (severity == HighlightSeverity.ERROR) {
        return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.WRONG_REF.getAttributesKey());
      }
      if (severity == HighlightSeverity.WARNING) {
        return new HighlightInfoType.HighlightInfoTypeImpl(severity, CodeInsightColors.WEAK_WARNING_ATTRIBUTES);
      }
      return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
    case LIKE_UNUSED_SYMBOL:
      return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
    case INFO:
      return HighlightInfoType.INFO;
    case WEAK_WARNING:
      return HighlightInfoType.WEAK_WARNING;
    case ERROR:
      return HighlightInfoType.WRONG_REF;
    case GENERIC_ERROR:
      return HighlightInfoType.ERROR;
    case INFORMATION:
      final TextAttributesKey attributes = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes();
      if (attributes != null) {
        return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, attributes);
      }
      return HighlightInfoType.INFORMATION;
  }
  throw new RuntimeException("Cannot map " + highlightType);
}
项目:intellij-ce-playground    文件:SyntaxHighlighterBase.java   
/**
 * Tries to update the map by associating given keys with a given value.
 * Throws error if the map already contains different mapping for one of given keys.
 */
protected static void safeMap(@NotNull final Map<IElementType, TextAttributesKey> map,
                              @NotNull final TokenSet keys,
                              @NotNull final TextAttributesKey value) {
  for (final IElementType type : keys.getTypes()) {
    safeMap(map, type, value);
  }
}
项目:intellij-ce-playground    文件:PsiElementListCellRenderer.java   
@Nullable
protected TextAttributes getNavigationItemAttributes(Object value) {
  TextAttributes attributes = null;

  if (value instanceof NavigationItem) {
    TextAttributesKey attributesKey = null;
    final ItemPresentation presentation = ((NavigationItem)value).getPresentation();
    if (presentation instanceof ColoredItemPresentation) attributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();

    if (attributesKey != null) {
      attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
    }
  }
  return attributes;
}
项目:intellij-ce-playground    文件:SyntaxHighlighterBase.java   
@NotNull
public static TextAttributesKey[] pack(@NotNull TextAttributesKey[] base, @Nullable TextAttributesKey t1, @Nullable TextAttributesKey t2) {
  int add = 0;
  if (t1 != null) add++;
  if (t2 != null) add++;
  if (add == 0) return base;
  TextAttributesKey[] result = new TextAttributesKey[base.length + add];
  add = base.length;
  System.arraycopy(base, 0, result, 0, base.length);
  if (t1 != null) result[add++] = t1;
  if (t2 != null) result[add] = t2;
  return result;
}
项目:intellij-graphql    文件:GraphQLSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
  if (tokenType.equals(GraphQLElementTypes.NAME)) {
    return IDENTIFIER_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.KEYWORD)) {
    return KEYWORD_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.NUMBER)) {
    return NUMBER_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.STRING)) {
    return STRING_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.COMMENT)) {
    return COMMENT_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.BRACE_L) || tokenType.equals(GraphQLElementTypes.BRACE_R)) {
    return BRACES_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.PAREN_L) || tokenType.equals(GraphQLElementTypes.PAREN_R)) {
    return PARENTHESES_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.BRACKET_L) || tokenType.equals(GraphQLElementTypes.BRACKET_R)) {
    return BRACKETS_KEYS;
  } else if (tokenType.equals(GraphQLElementTypes.SPREAD)) {
    return SPREAD_KEYS;
  } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
    return BAD_CHARACTER_KEYS;
  } else {
    return EMPTY_KEYS;
  }
}
项目:intellij-ce-playground    文件:SyntaxHighlighterBase.java   
@NotNull
public static TextAttributesKey[] pack(@NotNull TextAttributesKey[] base, @Nullable TextAttributesKey key) {
  if (key == null) return base;
  TextAttributesKey[] result = new TextAttributesKey[base.length + 1];
  System.arraycopy(base, 0, result, 0, base.length);
  result[base.length] = key;
  return result;
}
项目:intellij-ce-playground    文件:ComponentTree.java   
private AttributeWrapper getAttributeWrapper(RadComponent component) {
  AttributeWrapper wrapper = AttributeWrapper.DEFAULT;
  final HighlightDisplayLevel level = getHighlightDisplayLevel(myDesigner.getProject(), component);

  if (level != null) {
    TextAttributesKey attributesKey =
      SeverityRegistrar.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity())
        .getAttributesKey();
    final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);

    wrapper = new AttributeWrapper() {
      @Override
      public SimpleTextAttributes getAttribute(SimpleTextAttributes attributes) {
        Color bgColor = textAttributes.getBackgroundColor();
        try {
          textAttributes.setBackgroundColor(null);
          return SimpleTextAttributes.fromTextAttributes(TextAttributes.merge(attributes.toTextAttributes(), textAttributes));
        }
        finally {
          textAttributes.setBackgroundColor(bgColor);
        }
      }
    };
  }

  return wrapper;
}
项目:rythm_plugin    文件:RythmSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {

    if (tokenType.equals(RythmTypes.RYTHM_ARGS)) {
        return RYTHM_ARGS_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_EXTENDS)) {
        return RYTHM_EXTENDS_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_SECTION)) {
        return RYTHM_SECTION_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_IMPORT)) {
        return RYTHM_IMPORT_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_INVOKE)) {
        return RYTHM_INVOKE_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_RENDER)) {
        return RYTHM_RENDER_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_IF)) {
        return RYTHM_IF_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_FOR)) {
        return RYTHM_FOR_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_I_18_N)) {
        return RYTHM_I_18_N_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_PREFIX)) {
        return RYTHM_PREFIX_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_METHOD)) {
        return RYTHM_METHOD_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_KEY)) {
        return RYTHM_KEY_KEYS;
    } else if (tokenType.equals(RythmTypes.RYTHM_COMMENT)) {
        return RYTHM_COMMENT_KEYS;
    } else if(tokenType.equals(RythmTypes.FUNCTION)){
        return FUNCTION_KEYS;
    } /*if (tokenType.equals(RythmTypes.PARAM)) {
        return RYTHM_PARAM_KEYS;
    } */else if (tokenType.equals(RythmTypes.RYTHM_ELSE)){
        return RYTHM_ELSE_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:intellij-ce-playground    文件:HighlightInfoHolder.java   
@NotNull
public TextAttributesScheme getColorsScheme() {
  return new TextAttributesScheme() {
    @Override
    public TextAttributes getAttributes(TextAttributesKey key) {
      return key.getDefaultAttributes();
    }
  };
}
项目:intellij-ce-playground    文件:XsltNSColorProvider.java   
@Nullable
@Override
public TextAttributesKey getKeyForNamespace(String namespace, XmlElement context) {
  if (!(context instanceof XmlTag)) return null;
  if (XsltSupport.XSLT_NS.equals(((XmlTag)context).getNamespace())) return XsltSupport.XSLT_DIRECTIVE;
  return null;
}
项目:intellij-ce-playground    文件:GrDeclarationHighlightingVisitor.java   
private void visit(GrReferenceElement element) {
  ProgressManager.checkCanceled();
  final PsiElement resolved = element.resolve();
  final TextAttributesKey attribute = GrHighlightUtil.getDeclarationHighlightingAttribute(resolved, element);
  if (attribute != null) {
    final PsiElement refNameElement = GrHighlightUtil.getElementToHighlight(element);
    addInfo(attribute, refNameElement);
  }
}
项目:protobuf-jetbrains-plugin    文件:ProtoSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (!(tokenType instanceof TokenIElementType)) {
        return EMPTY_KEYS;
    }
    TokenIElementType myType = (TokenIElementType) tokenType;
    int antlrTokenType = myType.getAntlrTokenType();
    TextAttributesKey attrKey;
    switch (antlrTokenType) {
        case ProtoLexer.INTEGER_VALUE:
        case ProtoLexer.FLOAT_VALUE:
            attrKey = NUMBER;
            break;
        case ProtoLexer.STRING_VALUE:
            attrKey = STRING;
            break;
        case ProtoLexer.COMMENT:
            attrKey = BLOCK_COMMENT;
            break;
        case ProtoLexer.LINE_COMMENT:
            attrKey = LINE_COMMENT;
            break;
        case ProtoLexer.PLUGIN_DEV_MARKER:
            attrKey = METADATA;
            break;
        default:
            return EMPTY_KEYS;
    }
    return new TextAttributesKey[]{attrKey};
}
项目:dotplugin    文件:DotSyntaxHighlighter.java   
/**
 * The methods determines the text attributes for the token provided as arg
 * @param tokenType
 * @return text attributes required to highlight the corresponding token
 */
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(DotTypes.EXTENDED_ID)| tokenType.equals(DotTypes.SIMPLE_ID)) {
        return VARS_KEYS;

    } else if (tokenType.equals(DotTypes.NUMERAL_ID)){
        return NUMERIC_KEYS;
    } else if (tokenType.equals(DotTypes.GRAPH_)
            | tokenType.equals(DotTypes.NODE_)
            | tokenType.equals(DotTypes.EDGE_)
            | tokenType.equals(DotTypes.STRICT_)
            | tokenType.equals(DotTypes.DIGRAPH_)) {
        return KEYWORD_KEYS;
    } else if (tokenType.equals(DotTypes.COMPASS)) {
        return COMPASS_KEYS;
    } else if(tokenType.equals(DotTypes.BRACHET_LEFT)|
            tokenType.equals(DotTypes.BRACKET_RIGHT)|
            tokenType.equals(DotTypes.CURLY_BRACHET_LEFT)|
            tokenType.equals(DotTypes.CURLY_BRACKET_RIGHT)){
        return BRACKET_KEYS;

    } else if (tokenType.equals(DotTypes.EDGE_OP)) {
        return EDGE_OP_KEYS;
    } else if (tokenType.equals(DotTypes.COMMENT) | tokenType.equals(DotTypes.MULTILINE_COMMENT)) {
        return COMMENT_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:epigraph    文件:SchemaAnnotatorBase.java   
protected static Annotation setHighlighting(
    @NotNull PsiElement element, @NotNull AnnotationHolder holder,
    @NotNull TextAttributesKey key) {
  Annotation annotation = holder.createInfoAnnotation(element, null);
  annotation.setEnforcedTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key));
  return annotation;
}