use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class ChameleonSyntaxHighlightingPass method collectHighlights.
private void collectHighlights(@NotNull PsiElement element, @NotNull List<HighlightInfo> inside, @NotNull List<HighlightInfo> outside, @NotNull ProperTextRange priorityRange) {
EditorColorsScheme scheme = ObjectUtils.notNull(getColorsScheme(), EditorColorsManager.getInstance().getGlobalScheme());
TextAttributes defaultAttrs = scheme.getAttributes(HighlighterColors.TEXT);
Language language = ILazyParseableElementType.LANGUAGE_KEY.get(element.getNode());
if (language == null)
return;
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, myProject, myFile.getVirtualFile());
for (PsiElement token : psiTraverser(element).traverse(TreeTraversal.LEAVES_DFS)) {
TextRange tr = token.getTextRange();
if (tr.isEmpty())
continue;
IElementType type = PsiUtilCore.getElementType(token);
TextAttributesKey[] keys = syntaxHighlighter.getTokenHighlights(type);
// force attribute colors to override host' ones
TextAttributes attributes = null;
for (TextAttributesKey key : keys) {
TextAttributes attrs2 = scheme.getAttributes(key);
if (attrs2 != null) {
attributes = attributes == null ? attrs2 : TextAttributes.merge(attributes, attrs2);
}
}
TextAttributes forcedAttributes;
if (attributes == null || attributes.isEmpty() || attributes.equals(defaultAttrs)) {
forcedAttributes = TextAttributes.ERASE_MARKER;
} else {
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT).range(tr).textAttributes(TextAttributes.ERASE_MARKER).createUnconditionally();
(priorityRange.contains(tr) ? inside : outside).add(info);
forcedAttributes = new TextAttributes(attributes.getForegroundColor(), attributes.getBackgroundColor(), attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType());
}
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT).range(tr).textAttributes(forcedAttributes).createUnconditionally();
(priorityRange.contains(tr) ? inside : outside).add(info);
}
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class SeverityUtil method getSeverityBasedTextAttributes.
private static SeverityRegistrar.SeverityBasedTextAttributes getSeverityBasedTextAttributes(@NotNull SeverityRegistrar registrar, @NotNull HighlightInfoType type) {
final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
final TextAttributes textAttributes = scheme.getAttributes(type.getAttributesKey());
if (textAttributes != null) {
return new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes, (HighlightInfoType.HighlightInfoTypeImpl) type);
}
TextAttributes severity = registrar.getTextAttributesBySeverity(type.getSeverity(null));
return new SeverityRegistrar.SeverityBasedTextAttributes(severity, (HighlightInfoType.HighlightInfoTypeImpl) type);
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class ActionUsagePanel method configureByText.
private void configureByText(final String usageText, FileType fileType) {
Document document = myEditor.getDocument();
String text = StringUtil.convertLineSeparators(usageText);
document.replaceString(0, document.getTextLength(), text);
final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
myEditor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(fileType, scheme, null));
setupSpots(document);
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class ModuleToDoNode method update.
@Override
public void update(PresentationData presentation) {
if (DumbService.getInstance(getProject()).isDumb())
return;
String newName = getValue().getName();
int nameEndOffset = newName.length();
int todoItemCount = getTodoItemCount(getValue());
int fileCount = getFileCount(getValue());
newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
if (CopyPasteManager.getInstance().isCutElement(getValue())) {
textAttributes.setForegroundColor(CopyPasteManager.CUT_COLOR);
}
myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
presentation.setIcon(ModuleType.get(getValue()).getIcon());
presentation.setPresentableText(newName);
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class TodoDirNode method updateImpl.
@Override
protected void updateImpl(PresentationData data) {
super.updateImpl(data);
int fileCount = getFileCount(getValue());
if (getValue() == null || !getValue().isValid() || fileCount == 0) {
setValue(null);
return;
}
VirtualFile directory = getValue().getVirtualFile();
boolean isProjectRoot = !ProjectRootManager.getInstance(getProject()).getFileIndex().isInContent(directory);
String newName = isProjectRoot || getStructure().getIsFlattenPackages() ? getValue().getVirtualFile().getPresentableUrl() : getValue().getName();
int nameEndOffset = newName.length();
int todoItemCount = getTodoItemCount(getValue());
newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
Color newColor = FileStatusManager.getInstance(getProject()).getStatus(getValue().getVirtualFile()).getColor();
if (CopyPasteManager.getInstance().isCutElement(getValue())) {
newColor = CopyPasteManager.CUT_COLOR;
}
textAttributes.setForegroundColor(newColor);
myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
data.setPresentableText(newName);
}
Aggregations