本文整理汇总了Java中com.intellij.openapi.editor.markup.RangeHighlighter.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java RangeHighlighter.isValid方法的具体用法?Java RangeHighlighter.isValid怎么用?Java RangeHighlighter.isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.markup.RangeHighlighter
的用法示例。
在下文中一共展示了RangeHighlighter.isValid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAllGutters
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@Override
@NotNull
public List<GutterMark> findAllGutters() {
final Project project = getProject();
final SortedMap<Integer, List<GutterMark>> result = new TreeMap<Integer, List<GutterMark>>();
List<HighlightInfo> infos = doHighlighting();
for (HighlightInfo info : infos) {
addGutterIconRenderer(info.getGutterIconRenderer(), info.startOffset, result);
}
RangeHighlighter[] highlighters = DocumentMarkupModel.forDocument(myEditor.getDocument(), project, true).getAllHighlighters();
for (final RangeHighlighter highlighter : highlighters) {
if (!highlighter.isValid()) continue;
addGutterIconRenderer(highlighter.getGutterIconRenderer(), highlighter.getStartOffset(), result);
}
return ContainerUtil.concat(result.values());
}
示例2: assertHighlighted
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
protected void assertHighlighted(VirtualFile file, HighlightInfo... expected) throws IOException {
Editor editor = getEditor(file);
HighlightUsagesHandler.invoke(myProject, editor, getTestPsiFile(file));
RangeHighlighter[] highlighters = editor.getMarkupModel().getAllHighlighters();
List<HighlightInfo> actual = new ArrayList<HighlightInfo>();
for (RangeHighlighter each : highlighters) {
if (!each.isValid()) continue;
int offset = each.getStartOffset();
PsiElement element = getTestPsiFile(file).findElementAt(offset);
element = PsiTreeUtil.getParentOfType(element, XmlTag.class);
String text = editor.getDocument().getText().substring(offset, each.getEndOffset());
actual.add(new HighlightInfo(element, text));
}
assertUnorderedElementsAreEqual(actual, expected);
}
示例3: removeHighlighter
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@Override
public void removeHighlighter(@NotNull RangeHighlighter segmentHighlighter) {
ApplicationManager.getApplication().assertIsDispatchThread();
myCachedHighlighters = null;
if (!segmentHighlighter.isValid()) return;
boolean removed = treeFor(segmentHighlighter).removeInterval((RangeHighlighterEx)segmentHighlighter);
LOG.assertTrue(removed);
}
示例4: pickupHighlighterFromGarbageBin
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@Nullable // null means no highlighter found in the cache
RangeHighlighter pickupHighlighterFromGarbageBin(int startOffset, int endOffset, int layer){
TextRange range = new TextRange(startOffset, endOffset);
Collection<RangeHighlighter> collection = incinerator.get(range);
for (RangeHighlighter highlighter : collection) {
if (highlighter.isValid() && highlighter.getLayer() == layer) {
incinerator.remove(range, highlighter);
return highlighter;
}
}
return null;
}
示例5: errorMarkerClicked
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@Override
public void errorMarkerClicked(@NotNull ErrorStripeEvent e) {
RangeHighlighter highlighter = e.getHighlighter();
if (!highlighter.isValid()) return;
HighlightInfo info = findInfo(highlighter);
if (info != null) {
GotoNextErrorHandler.navigateToError(myProject, e.getEditor(), info);
}
}
示例6: purgeInvalidHighlighters
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
private static boolean purgeInvalidHighlighters(Editor editor, List<RangeHighlighter> hl) {
final Set set = ContainerUtil.newIdentityTroveSet(Arrays.asList(editor.getMarkupModel().getAllHighlighters()));
boolean hasHighlighter = false;
for (Iterator<RangeHighlighter> iterator = hl.iterator(); iterator.hasNext();) {
final RangeHighlighter h = iterator.next();
if (!h.isValid() || !set.contains(h)) {
iterator.remove();
} else {
hasHighlighter = true;
}
}
return hasHighlighter;
}
示例7: recycleHighlighter
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
void recycleHighlighter(@NotNull RangeHighlighter highlighter) {
if (highlighter.isValid()) {
incinerator.putValue(ProperTextRange.create(highlighter), highlighter);
}
}
示例8: updateInSelectionHighlighters
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private void updateInSelectionHighlighters() {
if (mySearchResults.getEditor() == null) return;
final SelectionModel selectionModel = mySearchResults.getEditor().getSelectionModel();
int[] starts = selectionModel.getBlockSelectionStarts();
int[] ends = selectionModel.getBlockSelectionEnds();
final HashSet<RangeHighlighter> toRemove = new HashSet<RangeHighlighter>();
Set<RangeHighlighter> toAdd = new HashSet<RangeHighlighter>();
for (RangeHighlighter highlighter : myHighlighters) {
if (!highlighter.isValid()) continue;
boolean intersectsWithSelection = false;
for (int i = 0; i < starts.length; ++i) {
TextRange selectionRange = new TextRange(starts[i], ends[i]);
intersectsWithSelection = selectionRange.intersects(highlighter.getStartOffset(), highlighter.getEndOffset()) &&
selectionRange.getEndOffset() != highlighter.getStartOffset() &&
highlighter.getEndOffset() != selectionRange.getStartOffset();
if (intersectsWithSelection) break;
}
final Object userData = highlighter.getUserData(IN_SELECTION_KEY);
if (userData != null) {
if (!intersectsWithSelection) {
if (userData == IN_SELECTION2) {
HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), highlighter);
toRemove.add(highlighter);
} else {
highlighter.putUserData(IN_SELECTION_KEY, null);
}
}
} else if (intersectsWithSelection) {
TextRange cursor = mySearchResults.getCursor();
if (cursor != null && highlighter.getStartOffset() == cursor.getStartOffset() &&
highlighter.getEndOffset() == cursor.getEndOffset()) continue;
final RangeHighlighter toAnnotate = highlightRange(new TextRange(highlighter.getStartOffset(), highlighter.getEndOffset()),
new TextAttributes(null, null, Color.WHITE, EffectType.ROUNDED_BOX, 0), toAdd);
highlighter.putUserData(IN_SELECTION_KEY, IN_SELECTION1);
toAnnotate.putUserData(IN_SELECTION_KEY, IN_SELECTION2);
}
}
myHighlighters.removeAll(toRemove);
myHighlighters.addAll(toAdd);
}