use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class XmlTagTreeHighlightingPass method getHighlights.
public List<HighlightInfo> getHighlights() {
clearLineMarkers(myEditor);
final int count = myPairsToHighlight.size();
final List<HighlightInfo> highlightInfos = new ArrayList<>(count * 2);
final MarkupModel markupModel = myEditor.getMarkupModel();
final Color[] baseColors = XmlTagTreeHighlightingUtil.getBaseColors();
final Color[] colorsForEditor = count > 1 ? toColorsForEditor(baseColors) : new Color[] { myEditor.getColorsScheme().getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES).getBackgroundColor() };
final Color[] colorsForLineMarkers = toColorsForLineMarkers(baseColors);
final List<RangeHighlighter> newHighlighters = new ArrayList<>();
assert colorsForEditor.length > 0;
for (int i = 0; i < count && i < baseColors.length; i++) {
Pair<TextRange, TextRange> pair = myPairsToHighlight.get(i);
if (pair.first == null && pair.second == null) {
continue;
}
Color color = colorsForEditor[i];
if (color == null) {
continue;
}
if (pair.first != null && !pair.first.isEmpty()) {
highlightInfos.add(createHighlightInfo(color, pair.first));
}
if (pair.second != null && !pair.second.isEmpty()) {
highlightInfos.add(createHighlightInfo(color, pair.second));
}
final int start = pair.first != null ? pair.first.getStartOffset() : pair.second.getStartOffset();
final int end = pair.second != null ? pair.second.getEndOffset() : pair.first.getEndOffset();
final Color lineMarkerColor = colorsForLineMarkers[i];
if (count > 1 && lineMarkerColor != null && start != end) {
final RangeHighlighter highlighter = createHighlighter(markupModel, new TextRange(start, end), lineMarkerColor);
newHighlighters.add(highlighter);
}
}
myEditor.putUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY, newHighlighters);
return highlightInfos;
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class XmlTagTreeHighlightingPass method clearHighlightingAndLineMarkers.
public static void clearHighlightingAndLineMarkers(final Editor editor, @NotNull Project project) {
final MarkupModel markupModel = DocumentMarkupModel.forDocument(editor.getDocument(), project, true);
for (RangeHighlighter highlighter : markupModel.getAllHighlighters()) {
Object tooltip = highlighter.getErrorStripeTooltip();
if (!(tooltip instanceof HighlightInfo)) {
continue;
}
if (((HighlightInfo) tooltip).type == TYPE) {
highlighter.dispose();
}
}
clearLineMarkers(editor);
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class JavaFxFieldToPropertyTest method getIntentionAction.
protected IntentionAction getIntentionAction() throws Exception {
final List<HighlightInfo> infos = doHighlighting();
final Editor editor = getEditor();
final PsiFile file = getFile();
return findIntentionAction(infos, actionName, editor, file);
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class JavaFXCollapseSubtagToAttributeTest method doTest.
private void doTest(boolean available, final String tagName) throws Exception {
configureByFiles(null, getTestName(true) + ".fxml");
final List<HighlightInfo> infos = doHighlighting();
Editor editor = getEditor();
PsiFile file = getFile();
IntentionAction intentionAction = findIntentionAction(infos, "Collapse tag '" + tagName + "' to attribute", editor, file);
if (available) {
assertNotNull("Collapse tag '" + tagName + "' to attribute", intentionAction);
assertTrue(CodeInsightTestFixtureImpl.invokeIntention(intentionAction, file, editor, "Collapse tag '" + tagName + "' to attribute"));
checkResultByFile(getTestName(true) + "_after.fxml");
} else {
assertNull(intentionAction);
}
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class JavaFXExpandAttributeTest method doTest.
private void doTest(boolean available, final String attrName) throws Exception {
configureByFiles(null, getTestName(true) + ".fxml");
final List<HighlightInfo> infos = doHighlighting();
Editor editor = getEditor();
PsiFile file = getFile();
final String actionName = "Expand '" + attrName + "' to tag";
IntentionAction intentionAction = findIntentionAction(infos, actionName, editor, file);
if (available) {
assertNotNull(actionName, intentionAction);
assertTrue(CodeInsightTestFixtureImpl.invokeIntention(intentionAction, file, editor, actionName));
checkResultByFile(getTestName(true) + "_after.fxml");
} else {
assertNull(intentionAction);
}
}
Aggregations