use of com.intellij.openapi.editor.colors.TextAttributesKey in project scss-lint-plugin by idok.
the class AnnotatorUtils method getTextAttributes.
@NotNull
public static TextAttributes getTextAttributes(@Nullable EditorColorsScheme editorColorsScheme, @NotNull SeverityRegistrar severityRegistrar, @NotNull HighlightSeverity severity) {
TextAttributes textAttributes = severityRegistrar.getTextAttributesBySeverity(severity);
if (textAttributes != null) {
return textAttributes;
}
EditorColorsScheme colorsScheme = getColorsScheme(editorColorsScheme);
HighlightInfoType.HighlightInfoTypeImpl infoType = severityRegistrar.getHighlightInfoTypeBySeverity(severity);
TextAttributesKey key = infoType.getAttributesKey();
return colorsScheme.getAttributes(key);
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoHighlightingAnnotator method annotate.
@Override
public void annotate(@NotNull PsiElement o, @NotNull AnnotationHolder holder) {
if (!o.isValid())
return;
if (o instanceof GoImportSpec && ((GoImportSpec) o).isDot()) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (o) {
List<PsiElement> importUsers = o.getUserData(GoReferenceBase.IMPORT_USERS);
if (importUsers != null) {
List<PsiElement> newImportUsers = ContainerUtil.newSmartList();
newImportUsers.addAll(importUsers.stream().filter(PsiElement::isValid).collect(Collectors.toList()));
o.putUserData(GoReferenceBase.IMPORT_USERS, newImportUsers.isEmpty() ? null : newImportUsers);
}
}
} else if (o instanceof GoLiteral) {
if (((GoLiteral) o).getHex() != null || ((GoLiteral) o).getOct() != null) {
setHighlighting(o, holder, NUMBER);
}
} else if (o instanceof GoReferenceExpressionBase) {
PsiReference reference = o.getReference();
highlightRefIfNeeded((GoReferenceExpressionBase) o, reference != null ? reference.resolve() : null, holder);
} else if (o instanceof GoTypeSpec) {
TextAttributesKey key = getColor((GoTypeSpec) o);
setHighlighting(((GoTypeSpec) o).getIdentifier(), holder, key);
} else if (o instanceof GoConstDefinition) {
setHighlighting(o, holder, getColor((GoConstDefinition) o));
} else if (o instanceof GoVarDefinition) {
setHighlighting(o, holder, getColor((GoVarDefinition) o));
} else if (o instanceof GoFieldDefinition) {
setHighlighting(o, holder, getColor((GoFieldDefinition) o));
} else if (o instanceof GoParamDefinition) {
setHighlighting(o, holder, FUNCTION_PARAMETER);
} else if (o instanceof GoReceiver) {
PsiElement identifier = ((GoReceiver) o).getIdentifier();
if (identifier != null) {
setHighlighting(identifier, holder, METHOD_RECEIVER);
}
} else if (o instanceof GoLabelDefinition || o instanceof GoLabelRef) {
setHighlighting(o, holder, LABEL);
} else if (o instanceof GoNamedSignatureOwner) {
PsiElement identifier = ((GoNamedSignatureOwner) o).getIdentifier();
if (identifier != null) {
setHighlighting(identifier, holder, getColor((GoNamedSignatureOwner) o));
}
}
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project smali by JesusFreke.
the class SmaliHighlightingColors method createTextAttributesKey.
private static TextAttributesKey createTextAttributesKey(String name, TextAttributesKey defaultColor) {
TextAttributesKey key = TextAttributesKey.createTextAttributesKey(name, defaultColor);
allKeys.add(key);
return key;
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class NodeRenderer method getSimpleTextAttributes.
public static SimpleTextAttributes getSimpleTextAttributes(@Nullable final ItemPresentation presentation, @NotNull EditorColorsScheme colorsScheme) {
if (presentation instanceof ColoredItemPresentation) {
final TextAttributesKey textAttributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();
if (textAttributesKey == null)
return SimpleTextAttributes.REGULAR_ATTRIBUTES;
final TextAttributes textAttributes = colorsScheme.getAttributes(textAttributesKey);
return textAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.fromTextAttributes(textAttributes);
}
return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class AbstractProjectViewPSIPane method createComponent.
@Override
public JComponent createComponent() {
if (myComponent != null)
return myComponent;
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
myTree = createTree(treeModel);
enableDnD();
myComponent = ScrollPaneFactory.createScrollPane(myTree);
if (Registry.is("error.stripe.enabled")) {
ErrorStripePainter painter = new ErrorStripePainter(true);
Disposer.register(this, new TreeUpdater<ErrorStripePainter>(painter, myComponent, myTree) {
@Override
protected void update(ErrorStripePainter painter, int index, Object object) {
if (object instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
object = node.getUserObject();
}
if (object instanceof PsiDirectoryNode && !myTree.isCollapsed(index)) {
object = null;
}
super.update(painter, index, object);
}
@Override
protected ErrorStripe getErrorStripe(Object object) {
if (object instanceof PresentableNodeDescriptor) {
PresentableNodeDescriptor node = (PresentableNodeDescriptor) object;
PresentationData presentation = node.getPresentation();
TextAttributesKey key = presentation.getTextAttributesKey();
if (key != null) {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
if (attributes != null && EffectType.WAVE_UNDERSCORE == attributes.getEffectType()) {
return ErrorStripe.create(attributes.getEffectColor(), 1);
}
}
}
return null;
}
});
}
myTreeStructure = createStructure();
BaseProjectTreeBuilder treeBuilder = createBuilder(treeModel);
installComparator(treeBuilder);
setTreeBuilder(treeBuilder);
initTree();
Disposer.register(getTreeBuilder(), new UiNotifyConnector(myTree, new Activatable() {
private boolean showing;
@Override
public void showNotify() {
if (!showing) {
showing = true;
restoreExpandedPaths();
}
}
@Override
public void hideNotify() {
if (showing) {
showing = false;
saveExpandedPaths();
}
}
}));
return myComponent;
}
Aggregations