use of com.intellij.openapi.util.ProperTextRange in project intellij-community by JetBrains.
the class EditorMarkupModelImpl method repaint.
// startOffset == -1 || endOffset == -1 means whole document
void repaint(int startOffset, int endOffset) {
ProperTextRange range = offsetsToYPositions(startOffset, endOffset);
markDirtied(range);
if (startOffset == -1 || endOffset == -1) {
myDirtyYPositions = WHOLE_DOCUMENT;
}
JScrollBar bar = myEditor.getVerticalScrollBar();
bar.repaint(0, range.getStartOffset(), bar.getWidth(), range.getLength() + myMinMarkHeight);
}
use of com.intellij.openapi.util.ProperTextRange in project intellij-community by JetBrains.
the class EditorMarkupModelImpl method getNearestHighlighters.
private void getNearestHighlighters(@NotNull MarkupModelEx markupModel, final int scrollBarY, @NotNull final Collection<RangeHighlighter> nearest) {
int startOffset = yPositionToOffset(scrollBarY - myMinMarkHeight, true);
int endOffset = yPositionToOffset(scrollBarY + myMinMarkHeight, false);
markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset, highlighter -> {
if (highlighter.getErrorStripeMarkColor() != null) {
ProperTextRange range = offsetsToYPositions(highlighter.getStartOffset(), highlighter.getEndOffset());
if (scrollBarY >= range.getStartOffset() - myMinMarkHeight * 2 && scrollBarY <= range.getEndOffset() + myMinMarkHeight * 2) {
nearest.add(highlighter);
}
}
return true;
});
}
use of com.intellij.openapi.util.ProperTextRange in project intellij-plugins by JetBrains.
the class DartServerFindUsagesTest method checkUsages.
private void checkUsages(@NotNull final SearchScope scope, @NotNull final String... expected) {
final String[] actualResult = ContainerUtil.map2Array(findUsages(scope), String.class, info -> {
final PsiElement element = info.getElement();
assertNotNull(element);
final ProperTextRange range = info.getRangeInElement();
assertNotNull(range);
final int startOffset = element.getTextRange().getStartOffset() + range.getStartOffset();
final int endOffset = element.getTextRange().getStartOffset() + range.getEndOffset();
return element.getClass().getSimpleName() + " in " + element.getContainingFile().getName() + "@" + startOffset + ":" + endOffset + (info.isDynamicUsage() ? " (dynamic usage)" : "") + (info.isNonCodeUsage() ? " (non-code usage)" : "");
});
assertSameElements(actualResult, expected);
}
use of com.intellij.openapi.util.ProperTextRange in project intellij-community by JetBrains.
the class WholeFileLocalInspectionsPassFactory method createHighlightingPass.
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@NotNull final PsiFile file, @NotNull final Editor editor) {
final Long appliedModificationCount = myPsiModificationCount.get(file);
if (appliedModificationCount != null && appliedModificationCount == PsiManager.getInstance(myProject).getModificationTracker().getModificationCount()) {
//optimization
return null;
}
if (!ProblemHighlightFilter.shouldHighlightFile(file)) {
return null;
}
if (myFileToolsCache.containsKey(file) && !myFileToolsCache.get(file)) {
return null;
}
ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
return new LocalInspectionsPass(file, editor.getDocument(), 0, file.getTextLength(), visibleRange, true, new DefaultHighlightInfoProcessor()) {
@NotNull
@Override
List<LocalInspectionToolWrapper> getInspectionTools(@NotNull InspectionProfileWrapper profile) {
List<LocalInspectionToolWrapper> tools = super.getInspectionTools(profile);
List<LocalInspectionToolWrapper> result = tools.stream().filter(LocalInspectionToolWrapper::runForWholeFile).collect(Collectors.toList());
myFileToolsCache.put(file, !result.isEmpty());
return result;
}
@Override
protected String getPresentableName() {
return DaemonBundle.message("pass.whole.inspections");
}
@Override
void inspectInjectedPsi(@NotNull List<PsiElement> elements, boolean onTheFly, @NotNull ProgressIndicator indicator, @NotNull InspectionManager iManager, boolean inVisibleRange, @NotNull List<LocalInspectionToolWrapper> wrappers) {
// already inspected in LIP
}
@Override
protected void applyInformationWithProgress() {
super.applyInformationWithProgress();
myPsiModificationCount.put(file, PsiManager.getInstance(myProject).getModificationTracker().getModificationCount());
}
};
}
use of com.intellij.openapi.util.ProperTextRange in project intellij-community by JetBrains.
the class MyTestInjector method textRangeToInject.
public static TextRange textRangeToInject(PsiLanguageInjectionHost host) {
ASTNode[] children = host.getNode().getChildren(null);
TextRange insideQuotes = new ProperTextRange(0, host.getTextLength());
if (children.length > 1 && children[0].getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {
insideQuotes = new ProperTextRange(children[1].getTextRange().getStartOffset() - host.getTextRange().getStartOffset(), insideQuotes.getEndOffset());
}
if (children.length > 1 && children[children.length - 1].getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
insideQuotes = new ProperTextRange(insideQuotes.getStartOffset(), children[children.length - 2].getTextRange().getEndOffset() - host.getTextRange().getStartOffset());
}
if (host instanceof PsiLiteralExpression) {
insideQuotes = new ProperTextRange(1, host.getTextLength() - 1);
}
return insideQuotes;
}
Aggregations