本文整理汇总了Java中com.intellij.openapi.editor.colors.TextAttributesKey类的典型用法代码示例。如果您正苦于以下问题:Java TextAttributesKey类的具体用法?Java TextAttributesKey怎么用?Java TextAttributesKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextAttributesKey类属于com.intellij.openapi.editor.colors包,在下文中一共展示了TextAttributesKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTokenHighlights
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
}
示例2: getTokenHighlights
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
}
示例3: getTokenHighlights
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
}
示例4: getTokenHighlights
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
}
示例5: isInherited
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
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;
}
示例6: getSyntaxHighlighter
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
};
}
示例7: visitDocTag
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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();
}
}
示例8: getDeclarationAttribute
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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);
}
示例9: SchemeTextAttributesDescription
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
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();
}
示例10: getPresentation
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
};
}
示例11: getTokenHighlights
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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;
}
示例12: getScopeAttributes
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
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;
}
示例13: getPresentation
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
@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);
}
};
}
示例14: testScopeBased
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
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();
}
}
示例15: getTextAttributes
import com.intellij.openapi.editor.colors.TextAttributesKey; //导入依赖的package包/类
/**
* 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;
}