use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method doTestWriteRead.
@NotNull
protected Pair<EditorColorsScheme, TextAttributes> doTestWriteRead(@NotNull TextAttributesKey key, @NotNull TextAttributes attributes) {
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme sourceScheme = (EditorColorsScheme) defaultScheme.clone();
sourceScheme.setName("test");
sourceScheme.setAttributes(key, attributes);
Element root = new Element("scheme");
((AbstractColorsScheme) sourceScheme).writeExternal(root);
EditorColorsScheme targetScheme = new EditorColorsSchemeImpl(defaultScheme);
targetScheme.readExternal(root);
assertEquals("test", targetScheme.getName());
TextAttributes targetAttrs = targetScheme.getAttributes(key);
return Pair.create(targetScheme, targetAttrs);
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method loadScheme.
protected static EditorColorsScheme loadScheme(@NotNull String docText) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(docText));
Document doc = docBuilder.parse(inputSource);
Element root = new DOMBuilder().build(doc.getDocumentElement());
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme targetScheme = new EditorColorsSchemeImpl(defaultScheme);
targetScheme.readExternal(root);
return targetScheme;
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class DiffDividerDrawUtil method createVisibleSeparators.
@NotNull
public static List<DividerSeparator> createVisibleSeparators(@NotNull Editor editor1, @NotNull Editor editor2, @NotNull DividerSeparatorPaintable paintable) {
final List<DividerSeparator> separators = new ArrayList<>();
final Transformation[] transformations = new Transformation[] { getTransformation(editor1), getTransformation(editor2) };
final LineRange leftInterval = getVisibleInterval(editor1);
final LineRange rightInterval = getVisibleInterval(editor2);
final int height1 = editor1.getLineHeight();
final int height2 = editor2.getLineHeight();
final EditorColorsScheme scheme = editor1.getColorsScheme();
paintable.process((line1, line2) -> {
if (leftInterval.start > line1 + 1 && rightInterval.start > line2 + 1)
return true;
if (leftInterval.end < line1 && rightInterval.end < line2)
return false;
separators.add(createSeparator(transformations, line1, line2, height1, height2, scheme));
return true;
});
return separators;
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class DefaultHighlightInfoProcessor method highlightsInsideVisiblePartAreProduced.
@Override
public void highlightsInsideVisiblePartAreProduced(@NotNull final HighlightingSession session, @NotNull final List<HighlightInfo> infos, @NotNull TextRange priorityRange, @NotNull TextRange restrictRange, final int groupId) {
final PsiFile psiFile = session.getPsiFile();
final Project project = psiFile.getProject();
final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if (document == null)
return;
final long modificationStamp = document.getModificationStamp();
final TextRange priorityIntersection = priorityRange.intersection(restrictRange);
final Editor editor = session.getEditor();
((HighlightingSessionImpl) session).applyInEDT(() -> {
if (modificationStamp != document.getModificationStamp())
return;
if (priorityIntersection != null) {
MarkupModel markupModel = DocumentMarkupModel.forDocument(document, project, true);
EditorColorsScheme scheme = session.getColorsScheme();
UpdateHighlightersUtil.setHighlightersInRange(project, document, priorityIntersection, scheme, infos, (MarkupModelEx) markupModel, groupId);
}
if (editor != null && !editor.isDisposed()) {
// usability: show auto import popup as soon as possible
if (!DumbService.isDumb(project)) {
new ShowAutoImportPass(project, psiFile, editor).doApplyInformationToEditor();
}
DaemonListeners.repaintErrorStripeRenderer(editor, project);
}
});
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class UpdateHighlightersUtil method addHighlighterToEditorIncrementally.
static void addHighlighterToEditorIncrementally(@NotNull Project project, @NotNull Document document, @NotNull PsiFile file, int startOffset, int endOffset, @NotNull final HighlightInfo info, // if null global scheme will be used
@Nullable final EditorColorsScheme colorsScheme, final int group, @NotNull Map<TextRange, RangeMarker> ranges2markersCache) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (isFileLevelOrGutterAnnotation(info))
return;
if (info.getStartOffset() < startOffset || info.getEndOffset() > endOffset)
return;
MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true);
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
final boolean myInfoIsError = isSevere(info, severityRegistrar);
Processor<HighlightInfo> otherHighlightInTheWayProcessor = oldInfo -> {
if (!myInfoIsError && isCovered(info, severityRegistrar, oldInfo)) {
return false;
}
return oldInfo.getGroup() != group || !oldInfo.equalsByActualOffset(info);
};
boolean allIsClear = DaemonCodeAnalyzerEx.processHighlights(document, project, null, info.getActualStartOffset(), info.getActualEndOffset(), otherHighlightInTheWayProcessor);
if (allIsClear) {
createOrReuseHighlighterFor(info, colorsScheme, document, group, file, (MarkupModelEx) markup, null, ranges2markersCache, severityRegistrar);
clearWhiteSpaceOptimizationFlag(document);
assertMarkupConsistent(markup, project);
}
}
Aggregations