本文整理汇总了Java中com.intellij.openapi.editor.markup.HighlighterTargetArea类的典型用法代码示例。如果您正苦于以下问题:Java HighlighterTargetArea类的具体用法?Java HighlighterTargetArea怎么用?Java HighlighterTargetArea使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HighlighterTargetArea类属于com.intellij.openapi.editor.markup包,在下文中一共展示了HighlighterTargetArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: highlightLine
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private void highlightLine(int index, NamedTextAttr namedTextAttr) {
UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
try {
MarkupModelEx markupModel = myEditor.getMarkupModel();
final Document doc = markupModel.getDocument();
final int lineStartOffset = doc.getLineStartOffset(index);
final int lineEndOffset = doc.getLineEndOffset(index);
// IDEA-53203: add ERASE_MARKER for manually defined attributes
markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
HighlighterLayer.SELECTION - 1, TextAttributes.ERASE_MARKER,
HighlighterTargetArea.EXACT_RANGE);
RangeHighlighter rangeHighlight =
markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
HighlighterLayer.SELECTION - 1, namedTextAttr,
HighlighterTargetArea.EXACT_RANGE);
rangeHighlight.setErrorStripeMarkColor(namedTextAttr.getErrorStripeColor());
rangeHighlight.setErrorStripeTooltip(namedTextAttr.getName());
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
示例2: changedUpdateImpl
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
protected void changedUpdateImpl(@NotNull DocumentEvent e) {
// todo Denis Zhdanov
DocumentEventImpl event = (DocumentEventImpl)e;
final boolean shouldTranslateViaDiff = isValid() && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, this);
boolean wasTranslatedViaDiff = shouldTranslateViaDiff;
if (shouldTranslateViaDiff) {
wasTranslatedViaDiff = translatedViaDiff(e, event);
}
if (!wasTranslatedViaDiff) {
super.changedUpdateImpl(e);
if (isValid()) {
myLine = getDocument().getLineNumber(getStartOffset());
int endLine = getDocument().getLineNumber(getEndOffset());
if (endLine != myLine) {
setIntervalEnd(getDocument().getLineEndOffset(myLine));
}
}
}
if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
setIntervalStart(DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), myLine));
setIntervalEnd(getDocument().getLineEndOffset(myLine));
}
}
示例3: HighlighterSweep
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private HighlighterSweep(@NotNull MarkupModelEx markupModel, int start, int end, final boolean onlyFullLine) {
// we have to get all highlighters in advance and sort them by affected offsets
// since these can be different from the real offsets the highlighters are sorted by in the tree. (See LINES_IN_RANGE perverts)
final List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
markupModel.processRangeHighlightersOverlappingWith(myReverseIteration ? end : start,
myReverseIteration ? start : end,
new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list) {
@Override
protected boolean accept(RangeHighlighterEx ex) {
return !onlyFullLine || ex.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;
}
});
highlighters = list.isEmpty() ? RangeHighlighterEx.EMPTY_ARRAY : list.toArray(new RangeHighlighterEx[list.size()]);
Arrays.sort(highlighters, myReverseIteration ? BY_AFFECTED_END_OFFSET_REVERSED : RangeHighlighterEx.BY_AFFECTED_START_OFFSET);
while (i < highlighters.length) {
RangeHighlighterEx highlighter = highlighters[i++];
if (!skipHighlighter(highlighter)) {
myNextHighlighter = highlighter;
break;
}
}
}
示例4: advanceSegmentHighlighters
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private void advanceSegmentHighlighters() {
myDoc.advance();
myView.advance();
boolean fileEnd = myStartOffset == myDocument.getTextLength();
for (int i = myCurrentHighlighters.size() - 1; i >= 0; i--) {
RangeHighlighterEx highlighter = myCurrentHighlighters.get(i);
if (myReverseIteration ?
highlighter.getAffectedAreaStartOffset() >= myStartOffset :
fileEnd && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE ?
highlighter.getAffectedAreaEndOffset() < myStartOffset :
highlighter.getAffectedAreaEndOffset() <= myStartOffset) {
myCurrentHighlighters.remove(i);
}
}
}
示例5: HighlighterSweep
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private HighlighterSweep(@NotNull MarkupModelEx markupModel, int start, int end, final boolean onlyFullLine) {
// we have to get all highlighters in advance and sort them by affected offsets
// since these can be different from the real offsets the highlighters are sorted by in the tree. (See LINES_IN_RANGE perverts)
final List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
markupModel.processRangeHighlightersOverlappingWith(start, end, new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list) {
@Override
protected boolean accept(RangeHighlighterEx ex) {
return !onlyFullLine || ex.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;
}
});
highlighters = list.isEmpty() ? RangeHighlighterEx.EMPTY_ARRAY : list.toArray(new RangeHighlighterEx[list.size()]);
Arrays.sort(highlighters, RangeHighlighterEx.BY_AFFECTED_START_OFFSET);
while (i < highlighters.length) {
RangeHighlighterEx highlighter = highlighters[i++];
if (!skipHighlighter(highlighter)) {
myNextHighlighter = highlighter;
break;
}
}
}
示例6: linkFollowed
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private static void linkFollowed(Editor editor, Collection<RangeHighlighter> ranges, final RangeHighlighter link) {
MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel();
for (RangeHighlighter range : ranges) {
TextAttributes oldAttr = range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES);
if (oldAttr != null) {
markupModel.setRangeHighlighterAttributes(range, oldAttr);
range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, null);
}
if (range == link) {
range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, range.getTextAttributes());
markupModel.setRangeHighlighterAttributes(range, getFollowedHyperlinkAttributes(range));
}
}
//refresh highlighter text attributes
markupModel.addRangeHighlighter(0, 0, HYPERLINK_LAYER, getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE).dispose();
}
示例7: testRangeHighlighterLinesInRangeForLongLinePerformance
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception {
final int N = 50000;
Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N));
final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true);
for (int i=0; i<N-1;i++) {
markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE);
}
markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE);
PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() {
@Override
public void run() {
List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list);
for (int i=0; i<N-1;i++) {
list.clear();
markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll);
assertEquals(2, list.size()); // 1 line plus one exact range marker
}
}
}).assertTiming();
}
示例8: installHighlighterSet
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@NotNull
private HighlightersSet installHighlighterSet(@NotNull Info info, @NotNull Editor editor) {
final JComponent internalComponent = editor.getContentComponent();
internalComponent.addKeyListener(myEditorKeyListener);
editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
final Cursor cursor = internalComponent.getCursor();
internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);
List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
for (TextRange range : info.getRanges()) {
TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor);
final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
HighlighterLayer.SELECTION + 1,
attr,
HighlighterTargetArea.EXACT_RANGE);
highlighters.add(highlighter);
}
return new HighlightersSet(highlighters, editor, cursor, info);
}
示例9: syntaxError
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
protected void syntaxError(String annotation, Token offendingToken) {
// Annotation annot = new Annotation(20, 30, HighlightSeverity.ERROR, "Test!", "Test Message!");
// HighlightInfo info = HighlightInfo.fromAnnotation(annot);
// List<HighlightInfo> al = new ArrayList<HighlightInfo>();
// al.add(info);
// UpdateHighlightersUtil.setHighlightersToEditor(project, doc, 20, 30, al, null, 0)
final TextAttributes attr = new TextAttributes();
attr.setForegroundColor(JBColor.RED);
attr.setEffectColor(JBColor.RED);
attr.setEffectType(EffectType.WAVE_UNDERSCORE);
MarkupModel markupModel = editor.getMarkupModel();
RangeHighlighter h =
markupModel.addRangeHighlighter(startIndex+offendingToken.getStartIndex(),
startIndex+offendingToken.getStopIndex()+1,
HighlighterLayer.ERROR, // layer
attr,
HighlighterTargetArea.EXACT_RANGE);
h.putUserData(SYNTAX_HIGHLIGHTING_TAG, offendingToken); // store any non-null value to tag it
}
示例10: changedUpdateImpl
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
protected void changedUpdateImpl(DocumentEvent e) {
// todo Denis Zhdanov
DocumentEventImpl event = (DocumentEventImpl)e;
final boolean shouldTranslateViaDiff = PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, this);
boolean wasTranslatedViaDiff = shouldTranslateViaDiff;
if (shouldTranslateViaDiff) {
wasTranslatedViaDiff = translatedViaDiff(e, event);
}
if (!wasTranslatedViaDiff) {
super.changedUpdateImpl(e);
if (isValid()) {
setLine(getDocument().getLineNumber(getStartOffset()));
int endLine = getDocument().getLineNumber(getEndOffset());
if (endLine != getLine()) {
setIntervalEnd(getDocument().getLineEndOffset(getLine()));
}
}
}
if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
setIntervalStart(getDocument().getLineStartOffset(getLine()));
setIntervalEnd(getDocument().getLineEndOffset(getLine()));
}
}
示例11: addRangeHighlighterAndChangeAttributes
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset,
int endOffset,
int layer,
TextAttributes textAttributes,
@NotNull HighlighterTargetArea targetArea,
boolean isPersistent,
@Nullable Consumer<RangeHighlighterEx> changeAttributesAction) {
ApplicationManager.getApplication().assertIsDispatchThread();
RangeHighlighterEx highlighter = isPersistent
? new PersistentRangeHighlighterImpl(this, startOffset, layer, targetArea, textAttributes)
: new RangeHighlighterImpl(this, startOffset, endOffset, layer, targetArea, textAttributes, false,
false);
myCachedHighlighters = null;
if (changeAttributesAction != null) {
((RangeHighlighterImpl)highlighter).changeAttributesNoEvents(changeAttributesAction);
}
fireAfterAdded(highlighter);
return highlighter;
}
示例12: installHighlighterSet
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private HighlightersSet installHighlighterSet(Info info, Editor editor) {
final JComponent internalComponent = editor.getContentComponent();
internalComponent.addKeyListener(myEditorKeyListener);
editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
final Cursor cursor = internalComponent.getCursor();
internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);
List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
for (TextRange range : info.getRanges()) {
final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
HighlighterLayer.SELECTION + 1,
attributes,
HighlighterTargetArea.EXACT_RANGE);
highlighters.add(highlighter);
}
return new HighlightersSet(highlighters, editor, cursor, info);
}
示例13: addDecisionEventHighlighter
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
public Token addDecisionEventHighlighter(PreviewState previewState, MarkupModel markupModel,
DecisionEventInfo info, Color errorStripeColor,
EffectType effectType) {
TokenStream tokens = previewState.parsingResult.parser.getInputStream();
Token startToken = tokens.get(info.startIndex);
Token stopToken = tokens.get(info.stopIndex);
TextAttributes textAttributes =
new TextAttributes(JBColor.BLACK, JBColor.WHITE, errorStripeColor,
effectType, Font.PLAIN);
textAttributes.setErrorStripeColor(errorStripeColor);
final RangeHighlighter rangeHighlighter =
markupModel.addRangeHighlighter(
startToken.getStartIndex(), stopToken.getStopIndex()+1,
HighlighterLayer.ADDITIONAL_SYNTAX, textAttributes,
HighlighterTargetArea.EXACT_RANGE);
rangeHighlighter.putUserData(DECISION_EVENT_INFO_KEY, info);
rangeHighlighter.setErrorStripeMarkColor(errorStripeColor);
return startToken;
}
示例14: highlightAndOfferHint
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
public void highlightAndOfferHint(Editor editor, int offset,
Interval sourceInterval,
JBColor color,
EffectType effectType, String hintText) {
CaretModel caretModel = editor.getCaretModel();
final TextAttributes attr = new TextAttributes();
attr.setForegroundColor(color);
attr.setEffectColor(color);
attr.setEffectType(effectType);
MarkupModel markupModel = editor.getMarkupModel();
markupModel.addRangeHighlighter(
sourceInterval.a,
sourceInterval.b,
InputPanel.TOKEN_INFO_LAYER, // layer
attr,
HighlighterTargetArea.EXACT_RANGE
);
if ( hintText.contains("<") ) {
hintText = hintText.replaceAll("<", "<");
}
// HINT
caretModel.moveToOffset(offset); // info tooltip only shows at cursor :(
HintManager.getInstance().showInformationHint(editor, hintText);
}
示例15: changedUpdateImpl
import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
protected void changedUpdateImpl(@Nonnull DocumentEvent e) {
// todo Denis Zhdanov
DocumentEventImpl event = (DocumentEventImpl)e;
final boolean shouldTranslateViaDiff = isValid() && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, getStartOffset(), getEndOffset());
boolean wasTranslatedViaDiff = shouldTranslateViaDiff;
if (shouldTranslateViaDiff) {
wasTranslatedViaDiff = translatedViaDiff(e, event);
}
if (!wasTranslatedViaDiff) {
super.changedUpdateImpl(e);
if (isValid()) {
myLine = getDocument().getLineNumber(getStartOffset());
int endLine = getDocument().getLineNumber(getEndOffset());
if (endLine != myLine) {
setIntervalEnd(getDocument().getLineEndOffset(myLine));
}
}
}
if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
setIntervalStart(DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), myLine));
setIntervalEnd(getDocument().getLineEndOffset(myLine));
}
}