本文整理匯總了Java中com.intellij.openapi.editor.ex.RangeHighlighterEx類的典型用法代碼示例。如果您正苦於以下問題:Java RangeHighlighterEx類的具體用法?Java RangeHighlighterEx怎麽用?Java RangeHighlighterEx使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RangeHighlighterEx類屬於com.intellij.openapi.editor.ex包,在下文中一共展示了RangeHighlighterEx類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: UnifiedEditorRangeHighlighter
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
public UnifiedEditorRangeHighlighter(@Nullable Project project, @NotNull Document document) {
ApplicationManager.getApplication().assertReadAccessAllowed();
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, false);
if (model == null) return;
model.processRangeHighlightersOverlappingWith(0, document.getTextLength(), new Processor<RangeHighlighterEx>() {
@Override
public boolean process(RangeHighlighterEx marker) {
int newStart = marker.getStartOffset();
int newEnd = marker.getEndOffset();
myPieces.add(new Element(marker, newStart, newEnd));
return true;
}
});
}
示例2: processRange
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
private void processRange(@NotNull MarkupModelEx model, @NotNull HighlightRange range) {
final TextRange base = range.getBase();
final TextRange changed = range.getChanged();
final int changedLength = changed.getEndOffset() - changed.getStartOffset();
model.processRangeHighlightersOverlappingWith(changed.getStartOffset(), changed.getEndOffset(), new Processor<RangeHighlighterEx>() {
@Override
public boolean process(RangeHighlighterEx marker) {
int relativeStart = Math.max(marker.getStartOffset() - changed.getStartOffset(), 0);
int relativeEnd = Math.min(marker.getEndOffset() - changed.getStartOffset(), changedLength);
int newStart = base.getStartOffset() + relativeStart;
int newEnd = base.getStartOffset() + relativeEnd;
if (newEnd - newStart <= 0) return true;
myPieces.add(new Element(marker, newStart, newEnd));
return true;
}
});
}
示例3: apply
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
public void apply(@Nullable Project project, @NotNull Document document) {
MarkupModel model = DocumentMarkupModel.forDocument(document, project, true);
for (Element piece : myPieces) {
RangeHighlighterEx delegate = piece.getDelegate();
if (!delegate.isValid()) continue;
RangeHighlighter highlighter = model
.addRangeHighlighter(piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getTextAttributes(), delegate.getTargetArea());
highlighter.setEditorFilter(delegate.getEditorFilter());
highlighter.setCustomRenderer(delegate.getCustomRenderer());
highlighter.setErrorStripeMarkColor(delegate.getErrorStripeMarkColor());
highlighter.setErrorStripeTooltip(delegate.getErrorStripeTooltip());
highlighter.setGutterIconRenderer(delegate.getGutterIconRenderer());
highlighter.setLineMarkerRenderer(delegate.getLineMarkerRenderer());
highlighter.setLineSeparatorColor(delegate.getLineSeparatorColor());
highlighter.setThinErrorStripeMark(delegate.isThinErrorStripeMark());
highlighter.setLineSeparatorPlacement(delegate.getLineSeparatorPlacement());
highlighter.setLineSeparatorRenderer(delegate.getLineSeparatorRenderer());
}
}
示例4: changeAttributesNoEvents
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
@NotNull
ChangeResult changeAttributesNoEvents(@NotNull Consumer<RangeHighlighterEx> change) {
assert !isFlagSet(IN_BATCH_CHANGE_MASK);
assert !isFlagSet(CHANGED_MASK);
setFlag(IN_BATCH_CHANGE_MASK, true);
setFlag(RENDERERS_CHANGED_MASK, false);
ChangeResult result;
try {
change.consume(this);
}
finally {
setFlag(IN_BATCH_CHANGE_MASK, false);
boolean changed = isFlagSet(CHANGED_MASK);
boolean renderersChanged = isFlagSet(RENDERERS_CHANGED_MASK);
result = changed ? renderersChanged ? ChangeResult.RENDERERS_CHANGED : ChangeResult.MINOR_CHANGE : ChangeResult.NOT_CHANGED;
setFlag(CHANGED_MASK, false);
setFlag(RENDERERS_CHANGED_MASK, false);
}
return result;
}
示例5: processHighlights
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
public static boolean processHighlights(@NotNull Document document,
@NotNull Project project,
@Nullable("null means all") final HighlightSeverity minSeverity,
final int startOffset,
final int endOffset,
@NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
@Override
public boolean process(@NotNull RangeHighlighterEx marker) {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo)) return true;
HighlightInfo info = (HighlightInfo)tt;
return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0
|| info.highlighter == null
|| processor.process(info);
}
});
}
示例6: processHighlightsOverlappingOutside
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
static boolean processHighlightsOverlappingOutside(@NotNull Document document,
@NotNull Project project,
@Nullable("null means all") final HighlightSeverity minSeverity,
final int startOffset,
final int endOffset,
@NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
@Override
public boolean process(@NotNull RangeHighlighterEx marker) {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo)) return true;
HighlightInfo info = (HighlightInfo)tt;
return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0
|| info.highlighter == null
|| processor.process(info);
}
});
}
示例7: paintHighlighterAfterEndOfLine
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
private void paintHighlighterAfterEndOfLine(Graphics2D g, RangeHighlighterEx highlighter) {
if (!highlighter.isAfterEndOfLine()) {
return;
}
int startOffset = highlighter.getStartOffset();
int lineEndOffset = myDocument.getLineEndOffset(myDocument.getLineNumber(startOffset));
if (myEditor.getFoldingModel().isOffsetCollapsed(lineEndOffset)) return;
Point lineEnd = myView.offsetToXY(lineEndOffset, true, false);
int x = lineEnd.x;
int y = lineEnd.y;
TextAttributes attributes = highlighter.getTextAttributes();
paintBackground(g, attributes, x, y, myView.getPlainSpaceWidth());
if (attributes != null && hasTextEffect(attributes.getEffectColor(), attributes.getEffectType())) {
paintTextEffect(g, x, x + myView.getPlainSpaceWidth() - 1, y + myView.getAscent(),
attributes.getEffectColor(), attributes.getEffectType());
}
}
示例8: paintBorderEffect
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
private void paintBorderEffect(final Graphics2D g,
final ClipDetector clipDetector,
MarkupModelEx markupModel,
int clipStartOffset,
int clipEndOffset) {
markupModel.processRangeHighlightersOverlappingWith(clipStartOffset, clipEndOffset, new Processor<RangeHighlighterEx>() {
@Override
public boolean process(RangeHighlighterEx rangeHighlighter) {
if (rangeHighlighter.getEditorFilter().avaliableIn(myEditor)) {
TextAttributes attributes = rangeHighlighter.getTextAttributes();
if (isBorder(attributes)) {
paintBorderEffect(g, clipDetector, rangeHighlighter.getAffectedAreaStartOffset(), rangeHighlighter.getAffectedAreaEndOffset(),
attributes);
}
}
return true;
}
});
}
示例9: getHyperlinks
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
public static List<RangeHighlighter> getHyperlinks(int startOffset, int endOffset, final Editor editor) {
final MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel();
final CommonProcessors.CollectProcessor<RangeHighlighterEx> processor = new CommonProcessors.CollectProcessor<RangeHighlighterEx>();
markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset,
new FilteringProcessor<RangeHighlighterEx>(new Condition<RangeHighlighterEx>() {
@Override
public boolean value(RangeHighlighterEx rangeHighlighterEx) {
return rangeHighlighterEx.getEditorFilter().avaliableIn(editor) &&
HYPERLINK_LAYER == rangeHighlighterEx.getLayer() &&
rangeHighlighterEx.isValid() &&
getHyperlinkInfo(rangeHighlighterEx) != null;
}
}, processor)
);
return new ArrayList<RangeHighlighter>(processor.getResults());
}
示例10: testRangeHighlighterLinesInRangeForLongLinePerformance
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的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();
}
示例11: isOffsetInsideHighlightInfo
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
private static boolean isOffsetInsideHighlightInfo(int offset, @NotNull HighlightInfo info, boolean includeFixRange) {
RangeHighlighterEx highlighter = info.highlighter;
if (highlighter == null || !highlighter.isValid()) return false;
int startOffset = highlighter.getStartOffset();
int endOffset = highlighter.getEndOffset();
if (startOffset <= offset && offset <= endOffset) {
return true;
}
if (!includeFixRange) return false;
RangeMarker fixMarker = info.fixMarker;
if (fixMarker != null) { // null means its range is the same as highlighter
if (!fixMarker.isValid()) return false;
startOffset = fixMarker.getStartOffset();
endOffset = fixMarker.getEndOffset();
return startOffset <= offset && offset <= endOffset;
}
return false;
}
示例12: getHighlightedStringsInConsole
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
/**
* Gets highlighted information from test console. Some parts of output (like file links) may be highlighted, and you need to check them.
*
* @return pair of [[ranges], [texts]] where range is [from,to] in doc. for each region, and "text" is text extracted from this region.
* For example assume that in document "spam eggs ham" words "ham" and "spam" are highlighted.
* You should have 2 ranges (0, 4) and (10, 13) and 2 strings (spam and ham)
*/
@NotNull
public Pair<List<Pair<Integer, Integer>>, List<String>> getHighlightedStringsInConsole() {
final List<String> resultStrings = new ArrayList<String>();
final List<Pair<Integer, Integer>> resultRanges = new ArrayList<Pair<Integer, Integer>>();
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
myConsole.flushDeferredText();
final Editor editor = myConsole.getEditor();
for (final RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) {
if (highlighter instanceof RangeHighlighterEx) {
final int start = ((RangeHighlighterEx)highlighter).getAffectedAreaStartOffset();
final int end = ((RangeHighlighterEx)highlighter).getAffectedAreaEndOffset();
resultRanges.add(Pair.create(start, end));
resultStrings.add(editor.getDocument().getText().substring(start, end));
}
}
}
}, ModalityState.NON_MODAL);
return Pair.create(resultRanges, resultStrings);
}
示例13: RangeHighlighterImpl
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
RangeHighlighterImpl(@NotNull MarkupModel model,
int start,
int end,
int layer,
@NotNull HighlighterTargetArea target,
TextAttributes textAttributes, boolean greedyToLeft, boolean greedyToRight) {
super((DocumentEx)model.getDocument(), start, end,false);
data = new RangeHighlighterData(model, target, textAttributes) {
@NotNull
@Override
public RangeHighlighterEx getRangeHighlighter() {
return RangeHighlighterImpl.this;
}
};
registerInTree(start, end, greedyToLeft, greedyToRight, layer);
}
示例14: addRangeHighlighterAndChangeAttributes
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的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;
}
示例15: processHighlights
import com.intellij.openapi.editor.ex.RangeHighlighterEx; //導入依賴的package包/類
public static boolean processHighlights(@NotNull Document document,
@NotNull Project project,
@Nullable("null means all") final HighlightSeverity minSeverity,
final int startOffset,
final int endOffset,
@NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
@Override
public boolean process(@NotNull RangeHighlighterEx marker) {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo)) return true;
HighlightInfo info = (HighlightInfo)tt;
return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0
|| info.highlighter == null
|| processor.process(info);
}
});
}