com.intellij.openapi.editor.HighlighterColors Java Examples
The following examples show how to use
com.intellij.openapi.editor.HighlighterColors.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 6 votes |
private void annotateWord(PsiElement bashWord, AnnotationHolder annotationHolder) { //we have to mark the remapped tokens (which are words now) to have the default word formatting. PsiElement child = bashWord.getFirstChild(); while (child != null && false) { if (!noWordHighlightErase.contains(child.getNode().getElementType())) { Annotation annotation = annotationHolder.createInfoAnnotation(child, null); annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotation = annotationHolder.createInfoAnnotation(child, null); annotation.setEnforcedTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(HighlighterColors.TEXT)); } child = child.getNextSibling(); } }
Example #2
Source File: Annotation.java From consulo with Apache License 2.0 | 6 votes |
/** * 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 */ @Nonnull 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; }
Example #3
Source File: HighlightInfo.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull static HighlightInfo fromAnnotation(@Nonnull Annotation annotation, boolean batchMode) { TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes(); TextAttributesKey key = annotation.getTextAttributes(); TextAttributesKey forcedAttributesKey = forcedAttributes == null && key != HighlighterColors.NO_HIGHLIGHTING ? key : null; HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation), annotation.getStartOffset(), annotation.getEndOffset(), annotation.getMessage(), annotation.getTooltip(), annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(), 0, annotation.getProblemGroup(), null, annotation.getGutterIconRenderer()); List<? extends Annotation.QuickFixInfo> fixes = batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes(); if (fixes != null) { for (Annotation.QuickFixInfo quickFixInfo : fixes) { TextRange range = quickFixInfo.textRange; HighlightDisplayKey k = quickFixInfo.key != null ? quickFixInfo.key : HighlightDisplayKey.find(ANNOTATOR_INSPECTION_SHORT_NAME); info.registerFix(quickFixInfo.quickFix, null, HighlightDisplayKey.getDisplayNameByKey(k), range, k); } } return info; }
Example #4
Source File: ColorManager.java From saros with GNU General Public License v2.0 | 5 votes |
private IdentifiableColorKeys(final int id) { this.id = id; final String selectionKeyName = SELECTION_KEY_PREFIX + id; final String contributionKeyName = CONTRIBUTION_KEY_PREFIX + id; this.selectionColorKey = TextAttributesKey.createTextAttributesKey(selectionKeyName, HighlighterColors.TEXT); this.contributionColorKey = TextAttributesKey.createTextAttributesKey(contributionKeyName, HighlighterColors.TEXT); }
Example #5
Source File: ChunkExtractor.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private TextAttributes convertAttributes(@Nonnull TextAttributesKey[] keys) { TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT); for (TextAttributesKey key : keys) { TextAttributes attrs2 = myColorsScheme.getAttributes(key); if (attrs2 != null) { attrs = TextAttributes.merge(attrs, attrs2); } } attrs = attrs.clone(); return attrs; }
Example #6
Source File: FragmentedEditorHighlighter.java From consulo with Apache License 2.0 | 5 votes |
private boolean isUsualAttributes(final TextAttributes ta) { if (myUsualAttributes == null) { final EditorColorsManager manager = EditorColorsManager.getInstance(); final EditorColorsScheme[] schemes = manager.getAllSchemes(); EditorColorsScheme defaultScheme = schemes[0]; for (EditorColorsScheme scheme : schemes) { if (manager.isDefaultScheme(scheme)) { defaultScheme = scheme; break; } } myUsualAttributes = defaultScheme.getAttributes(HighlighterColors.TEXT); } return myUsualAttributes.equals(ta); }
Example #7
Source File: EditorHighlighterUpdater.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected EditorHighlighter createHighlighter() { EditorHighlighter highlighter = myFile != null ? EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile) : new EmptyEditorHighlighter(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(HighlighterColors.TEXT)); highlighter.setText(myEditor.getDocument().getImmutableCharSequence()); return highlighter; }
Example #8
Source File: RecentLocationsRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static TextAttributes createDefaultTextAttributesWithBackground(@Nonnull EditorColorsScheme colorsScheme, @Nonnull Color backgroundColor) { TextAttributes defaultTextAttributes = new TextAttributes(); TextAttributes textAttributes = colorsScheme.getAttributes(HighlighterColors.TEXT); if (textAttributes != null) { defaultTextAttributes = textAttributes.clone(); defaultTextAttributes.setBackgroundColor(backgroundColor); } return defaultTextAttributes; }
Example #9
Source File: ClickNavigator.java From consulo with Apache License 2.0 | 5 votes |
public static String highlightingTypeFromTokenType(IElementType tokenType, SyntaxHighlighter highlighter) { TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType); String s = null; for (int i = highlights.length - 1; i >= 0; i--) { if (highlights[i] != HighlighterColors.TEXT) { s = highlights[i].getExternalName(); break; } } return s == null ? HighlighterColors.TEXT.getExternalName() : s; }
Example #10
Source File: HighlightData.java From consulo with Apache License 2.0 | 5 votes |
public void addHighlToView(final Editor view, EditorColorsScheme scheme, final Map<TextAttributesKey,String> displayText) { // XXX: Hack if (HighlighterColors.BAD_CHARACTER.equals(myHighlightType)) { return; } final TextAttributes attr = scheme.getAttributes(myHighlightType); if (attr != null) { UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { try { // IDEA-53203: add ERASE_MARKER for manually defined attributes view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, TextAttributes.ERASE_MARKER, HighlighterTargetArea.EXACT_RANGE); RangeHighlighter highlighter = view.getMarkupModel() .addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attr, HighlighterTargetArea.EXACT_RANGE); final Color errorStripeColor = attr.getErrorStripeColor(); highlighter.setErrorStripeMarkColor(errorStripeColor); final String tooltip = displayText.get(myHighlightType); highlighter.setErrorStripeTooltip(tooltip); } catch (Exception e) { throw new RuntimeException(e); } }); } }
Example #11
Source File: AbstractColorsScheme.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Color getDefaultBackground() { final Color c = getAttributes(HighlighterColors.TEXT).getBackgroundColor(); return c != null ? c : Color.white; }
Example #12
Source File: AbstractColorsScheme.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Color getDefaultForeground() { final Color c = getAttributes(HighlighterColors.TEXT).getForegroundColor(); return c != null ? c : Color.black; }
Example #13
Source File: EmptyEditorHighlighter.java From consulo with Apache License 2.0 | 4 votes |
@Override public void setColorScheme(EditorColorsScheme scheme) { setAttributes(scheme.getAttributes(HighlighterColors.TEXT)); }