@NotNull public static Map<String, List<ProblemDescriptor>> inspectEx(@NotNull final List<LocalInspectionToolWrapper> toolWrappers, @NotNull final PsiFile file, @NotNull final InspectionManager iManager, final boolean isOnTheFly, boolean failFastOnAcquireReadAction, @NotNull final ProgressIndicator indicator) { if (toolWrappers.isEmpty()) return Collections.emptyMap(); final List<PsiElement> elements = new ArrayList<PsiElement>(); TextRange range = file.getTextRange(); Divider.divideInsideAndOutside(file, range.getStartOffset(), range.getEndOffset(), range, elements, new ArrayList<ProperTextRange>(), Collections.<PsiElement>emptyList(), Collections.<ProperTextRange>emptyList(), true, Conditions.<PsiFile>alwaysTrue()); return inspectElements(toolWrappers, file, iManager, isOnTheFly, failFastOnAcquireReadAction, indicator, elements, calcElementDialectIds(elements)); }
public static void divideInsideAndOutside(@NotNull PsiFile file, int startOffset, int endOffset, @NotNull TextRange range, @NotNull List<PsiElement> inside, @NotNull List<ProperTextRange> insideRanges, @NotNull List<PsiElement> outside, @NotNull List<ProperTextRange> outsideRanges, boolean includeParents, @NotNull Condition<PsiFile> filter) { final FileViewProvider viewProvider = file.getViewProvider(); for (Language language : viewProvider.getLanguages()) { final PsiFile psiRoot = viewProvider.getPsi(language); if (filter.value(psiRoot)) { divideInsideAndOutside(psiRoot, startOffset, endOffset, range, inside, insideRanges, outside, outsideRanges, includeParents); } } }
/** * @return range in element */ @Nullable("null means range is invalid") public ProperTextRange getRangeInElement() { PsiElement element = getElement(); if (element == null) return null; TextRange elementRange = element.getTextRange(); ProperTextRange result; if (myPsiFileRange == null) { int startOffset = element.getTextOffset(); result = ProperTextRange.create(startOffset, elementRange.getEndOffset()); } else { Segment rangeInFile = myPsiFileRange.getRange(); if (rangeInFile == null) return null; result = ProperTextRange.create(rangeInFile); } int delta = elementRange.getStartOffset(); return result.getStartOffset() < delta ? null : result.shiftRight(-delta); }
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, new Processor<RangeHighlighterEx>() { @Override public boolean process(@NotNull RangeHighlighterEx highlighter) { if (!highlighter.getEditorFilter().avaliableIn(myEditor)) return true; 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; } }); }
private void repaint(@NotNull final Graphics g, int gutterWidth, @NotNull ProperTextRange yrange) { final Rectangle clip = new Rectangle(0, yrange.getStartOffset(), gutterWidth, yrange.getLength() + myMinMarkHeight); paintTrackBasement(g, clip); Document document = myEditor.getDocument(); int startOffset = yPositionToOffset(clip.y - myMinMarkHeight, true); int endOffset = yPositionToOffset(clip.y + clip.height, false); Shape oldClip = g.getClip(); g.clipRect(clip.x, clip.y, clip.width, clip.height); drawMarkup(g, startOffset, endOffset, (MarkupModelEx)DocumentMarkupModel.forDocument(document, myEditor.getProject(), true), EditorMarkupModelImpl.this); g.setClip(oldClip); }
public void markDirtied(@NotNull ProperTextRange yPositions) { if (myDirtyYPositions != WHOLE_DOCUMENT) { int start = Math.max(0, yPositions.getStartOffset() - myEditor.getLineHeight()); int end = myEditorScrollbarTop + myEditorTargetHeight == 0 ? yPositions.getEndOffset() + myEditor.getLineHeight() : Math .min(myEditorScrollbarTop + myEditorTargetHeight, yPositions.getEndOffset() + myEditor.getLineHeight()); ProperTextRange adj = new ProperTextRange(start, Math.max(end, start)); myDirtyYPositions = myDirtyYPositions == null ? adj : myDirtyYPositions.union(adj); } myEditorScrollbarTop = 0; myEditorSourceHeight = 0; myEditorTargetHeight = 0; dimensionsAreValid = false; }
@Nullable private static ProperTextRange processIfOnePoint(@NotNull DocumentEvent e, int intervalStart, int intervalEnd, boolean greedyRight) { int offset = e.getOffset(); int oldLength = e.getOldLength(); int oldEnd = offset + oldLength; if (offset < intervalStart && intervalStart < oldEnd) { return null; } if (offset == intervalStart && oldLength == 0 && greedyRight) { return new ProperTextRange(intervalStart, intervalEnd + e.getNewLength()); } if (intervalStart > oldEnd || intervalStart == oldEnd && oldLength > 0) { return new ProperTextRange(intervalStart + e.getNewLength() - oldLength, intervalEnd + e.getNewLength() - oldLength); } return new ProperTextRange(intervalStart, intervalEnd); }
@Nullable private static Pair<ProperTextRange, LinesCols> translateViaDiff(final DocumentEventImpl event, LinesCols linesCols) { try { int myStartLine = event.translateLineViaDiffStrict(linesCols.myStartLine); Document document = event.getDocument(); if (myStartLine < 0 || myStartLine >= document.getLineCount()) { return null; } int start = document.getLineStartOffset(myStartLine) + linesCols.myStartColumn; if (start >= document.getTextLength()) return null; int myEndLine = event.translateLineViaDiffStrict(linesCols.myEndLine); if (myEndLine < 0 || myEndLine >= document.getLineCount()) { return null; } int end = document.getLineStartOffset(myEndLine) + linesCols.myEndColumn; if (end > document.getTextLength() || end < start) return null; return Pair.create(new ProperTextRange(start, end), new LinesCols(myStartLine, linesCols.myStartColumn, myEndLine, linesCols.myEndColumn)); } catch (FilesTooBigForDiffException e) { return null; } }
@Nullable static Pair<ProperTextRange, LinesCols> applyChange(DocumentEvent event, Segment range, int intervalStart, int intervalEnd, boolean greedyLeft, boolean greedyRight, LinesCols linesCols) { final boolean shouldTranslateViaDiff = PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, range); Pair<ProperTextRange, LinesCols> translated = null; if (shouldTranslateViaDiff) { translated = translateViaDiff((DocumentEventImpl)event, linesCols); } if (translated == null) { ProperTextRange fallback = applyChange(event, intervalStart, intervalEnd, greedyLeft, greedyRight); if (fallback == null) return null; LinesCols lc = storeLinesAndCols(fallback, event.getDocument()); if (lc == null) return null; translated = Pair.create(fallback, lc); } if (translated.first.getEndOffset() > event.getDocument().getTextLength() || translated.second.myEndLine < translated.second.myStartLine || translated.second.myStartLine == translated.second.myEndLine && translated.second.myEndColumn < translated.second.myStartColumn || event.getDocument().getLineCount() < translated.second.myEndLine) { return null; } return translated; }
@Override public PsiElement restoreElement() { PsiFile hostFile = myHostContext.getContainingFile(); if (hostFile == null || !hostFile.isValid()) return null; PsiElement hostContext = myHostContext.getElement(); if (hostContext == null) return null; Segment segment = myInjectedFileRangeInHostFile.getPsiRange(); if (segment == null) return null; PsiFile injectedPsi = getInjectedFileIn(hostContext, hostFile, TextRange.create(segment)); ProperTextRange rangeInInjected = hostToInjected(true, segment, injectedPsi, myAffixOffsets); if (rangeInInjected == null) return null; return SelfElementInfo.findElementInside(injectedPsi, rangeInInjected.getStartOffset(), rangeInInjected.getEndOffset(), anchorClass, anchorLanguage); }
@Override @NotNull public TextRange getRangeInsideHost() { PsiLanguageInjectionHost host = getHost(); Segment psiRange = relevantRangeInHost.getPsiRange(); TextRange textRange = psiRange == null ? null : TextRange.create(psiRange); if (host == null) { if (textRange != null) return textRange; Segment fromSP = hostElementPointer.getPsiRange(); if (fromSP != null) return TextRange.create(fromSP); return new TextRange(0,0); } TextRange hostTextRange = host.getTextRange(); textRange = textRange == null ? null : textRange.intersection(hostTextRange); if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength()); return textRange.shiftRight(-hostTextRange.getStartOffset()); }
private void getNearestHighlighters(MarkupModelEx markupModel, MouseEvent e, final double width, final Collection<RangeHighlighter> nearest) { if (0 > e.getX() || e.getX() >= width) return; final int y = e.getY(); int startOffset = yPositionToOffset(y - getMinHeight(), true); int endOffset = yPositionToOffset(y + getMinHeight(), false); markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() { @Override public boolean process(RangeHighlighterEx highlighter) { if (highlighter.getErrorStripeMarkColor() != null) { ProperTextRange range = offsetsToYPositions(highlighter.getStartOffset(), highlighter.getEndOffset()); if (y >= range.getStartOffset() - getMinHeight() * 2 && y <= range.getEndOffset() + getMinHeight() * 2) { nearest.add(highlighter); } } return true; } }); }
@Override @NotNull public TextRange getRangeInsideHost() { PsiLanguageInjectionHost host = getHost(); ProperTextRange textRange = relevantRangeInHost.isValid() ? new ProperTextRange(relevantRangeInHost.getStartOffset(), relevantRangeInHost.getEndOffset()) : null; if (host == null) { if (textRange != null) return textRange; Segment fromSP = hostElementPointer.getRange(); if (fromSP != null) return TextRange.create(fromSP); return new TextRange(0,0); } TextRange hostTextRange = host.getTextRange(); textRange = textRange == null ? null : textRange.intersection(hostTextRange); if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength()); return textRange.shiftRight(-hostTextRange.getStartOffset()); }
@Override public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) { ProperTextRange.assertProperRange(rangeInsideHost); String subText = rangeInsideHost.substring(myHost.getText()); outSourceOffsets = new int[subText.length() + 1]; boolean b = PropertyImpl.parseCharacters(subText, outChars, outSourceOffsets); if (b) { for (int i=0; i<outChars.length(); i++) { if (outChars.charAt(i) != subText.charAt(outSourceOffsets[i])) { if (subText.charAt(outSourceOffsets[i]) != '\\') { throw new IllegalStateException(); } } } } return b; }
@Override public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) { ProperTextRange.assertProperRange(rangeInsideHost); String subText = rangeInsideHost.substring(myHost.getText()); outSourceOffsets = new int[subText.length() + 1]; final IElementType elementType = myHost.getFirstChild().getNode().getElementType(); if (elementType == GroovyTokenTypes.mSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_CONTENT) { return GrStringUtil.parseStringCharacters(subText, outChars, outSourceOffsets); } else if (elementType == GroovyTokenTypes.mREGEX_LITERAL || elementType == GroovyTokenTypes.mREGEX_CONTENT) { return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, true); } else if (elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL || elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_CONTENT) { return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, false); } else return false; }
private void getNearestHighlighters(MarkupModelEx markupModel, final int scrollBarY, final Collection<RangeHighlighter> nearest) { int startOffset = yPositionToOffset(scrollBarY - myMinMarkHeight, true); int endOffset = yPositionToOffset(scrollBarY + myMinMarkHeight, false); markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() { @Override public boolean process(RangeHighlighterEx 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; } }); }
public void markDirtied(@Nonnull ProperTextRange yPositions) { if (myDirtyYPositions != WHOLE_DOCUMENT) { int start = Math.max(0, yPositions.getStartOffset() - myEditor.getLineHeight()); int end = myEditorScrollbarTop + myEditorTargetHeight == 0 ? yPositions.getEndOffset() + myEditor.getLineHeight() : Math.min(myEditorScrollbarTop + myEditorTargetHeight, yPositions.getEndOffset() + myEditor.getLineHeight()); ProperTextRange adj = new ProperTextRange(start, Math.max(end, start)); myDirtyYPositions = myDirtyYPositions == null ? adj : myDirtyYPositions.union(adj); } myEditorScrollbarTop = 0; myEditorSourceHeight = 0; myEditorTargetHeight = 0; dimensionsAreValid = false; }
@Override PsiElement restoreElement() { PsiFile hostFile = myHostContext.getContainingFile(); if (hostFile == null || !hostFile.isValid()) return null; PsiElement hostContext = myHostContext.getElement(); if (hostContext == null) return null; Segment segment = myInjectedFileRangeInHostFile.getPsiRange(); if (segment == null) return null; PsiFile injectedPsi = getInjectedFileIn(hostContext, hostFile, TextRange.create(segment)); ProperTextRange rangeInInjected = hostToInjected(true, segment, injectedPsi, myAffixOffsets); if (rangeInInjected == null) return null; return myType.findPsiElement(injectedPsi, rangeInInjected.getStartOffset(), rangeInInjected.getEndOffset()); }
@Override public void highlightsOutsideVisiblePartAreProduced(@Nonnull final HighlightingSession session, @Nullable Editor editor, @Nonnull final List<HighlightInfo> infos, @Nonnull final TextRange priorityRange, @Nonnull final TextRange restrictedRange, final int groupId) { final PsiFile psiFile = session.getPsiFile(); final Project project = psiFile.getProject(); final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) return; final long modificationStamp = document.getModificationStamp(); ((HighlightingSessionImpl)session).applyInEDT(() -> { if (project.isDisposed() || modificationStamp != document.getModificationStamp()) return; EditorColorsScheme scheme = session.getColorsScheme(); UpdateHighlightersUtil.setHighlightersOutsideRange(project, document, psiFile, infos, scheme, restrictedRange.getStartOffset(), restrictedRange.getEndOffset(), ProperTextRange.create(priorityRange), groupId); if (editor != null) { DaemonListeners.repaintErrorStripeRenderer(editor, project); } }); }
@Nonnull private TextRange calcRangeInsideHostElement(boolean usePsiRange) { PsiLanguageInjectionHost host = getHost(); Segment psiRange = usePsiRange ? relevantRangeInHost.getPsiRange() : relevantRangeInHost.getRange(); TextRange textRange = psiRange == null ? null : TextRange.create(psiRange); if (host == null) { if (textRange != null) return textRange; Segment fromSP = usePsiRange ? hostElementPointer.getPsiRange() : hostElementPointer.getRange(); if (fromSP != null) return TextRange.create(fromSP); return new TextRange(0, 0); } TextRange hostTextRange = host.getTextRange(); textRange = textRange == null ? null : textRange.intersection(hostTextRange); if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength()); return textRange.shiftLeft(hostTextRange.getStartOffset()); }
private static PsiElement getParentFromUsage(UsageInfo usage) { ProperTextRange range = usage.getRangeInElement(); assertNotNull(range); PsiElement element = usage.getElement(); assertNotNull(element); PsiElement elementAt = element.findElementAt(range.getStartOffset()); assertNotNull(elementAt); return elementAt.getParent(); }
@Override @NotNull public RangeHighlighter addRangeHighlighter(final int startOffset, final int endOffset, final int layer, final TextAttributes textAttributes, @NotNull final HighlighterTargetArea targetArea) { TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset)); return myHostModel.addRangeHighlighter(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, textAttributes, targetArea); }
@NotNull @Override public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, int endOffset, int layer, TextAttributes textAttributes, @NotNull HighlighterTargetArea targetArea, boolean isPersistent, Consumer<RangeHighlighterEx> changeAttributesAction) { TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset)); return myHostModel.addRangeHighlighterAndChangeAttributes(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, textAttributes, targetArea, isPersistent, changeAttributesAction); }
@NotNull public static ProperTextRange calculateVisibleRange(@NotNull Editor editor) { Rectangle rect = editor.getScrollingModel().getVisibleArea(); LogicalPosition startPosition = editor.xyToLogicalPosition(new Point(rect.x, rect.y)); int visibleStart = editor.logicalPositionToOffset(startPosition); LogicalPosition endPosition = editor.xyToLogicalPosition(new Point(rect.x + rect.width, rect.y + rect.height)); int visibleEnd = editor.logicalPositionToOffset(new LogicalPosition(endPosition.line + 1, 0)); return new ProperTextRange(visibleStart, Math.max(visibleEnd, visibleStart)); }
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); }
@Override protected void doPaintTrack(@NotNull Graphics g, @NotNull JComponent c, @NotNull Rectangle bounds) { if (isMacScrollbarHiddenAndXcodeLikeScrollbar()) { paintTrackBasement(g, bounds); return; } Rectangle clip = g.getClipBounds().intersection(bounds); if (clip.height == 0) return; Rectangle componentBounds = c.getBounds(); ProperTextRange docRange = ProperTextRange.create(0, componentBounds.height); if (myCachedTrack == null || myCachedHeight != componentBounds.height) { myCachedTrack = UIUtil.createImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB); myCachedHeight = componentBounds.height; myDirtyYPositions = docRange; paintTrackBasement(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height)); } if (myDirtyYPositions == WHOLE_DOCUMENT) { myDirtyYPositions = docRange; } if (myDirtyYPositions != null) { final Graphics2D imageGraphics = myCachedTrack.createGraphics(); ((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart(); try { myDirtyYPositions = myDirtyYPositions.intersection(docRange); if (myDirtyYPositions == null) myDirtyYPositions = docRange; repaint(imageGraphics, componentBounds.width, myDirtyYPositions); myDirtyYPositions = null; } finally { ((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish(); } } UIUtil.drawImage(g, myCachedTrack, null, 0, 0); }
@NotNull private ProperTextRange offsetsToYPositions(int start, int end) { if (!dimensionsAreValid) { recalcEditorDimensions(); } Document document = myEditor.getDocument(); int startLineNumber = end == -1 ? 0 : offsetToLine(start, document); int startY; int lineCount; int editorTargetHeight = Math.max(0, myEditorTargetHeight); if (myEditorSourceHeight < editorTargetHeight) { lineCount = 0; startY = myEditorScrollbarTop + startLineNumber * myEditor.getLineHeight(); } else { lineCount = myEditorSourceHeight / myEditor.getLineHeight(); startY = myEditorScrollbarTop + (int)((float)startLineNumber / lineCount * editorTargetHeight); } int endY; int endLineNumber = offsetToLine(end, document); if (end == -1 || start == -1) { endY = Math.min(myEditorSourceHeight, editorTargetHeight); } else if (start == end || offsetToLine(start, document) == endLineNumber) { endY = startY; // both offsets are on the same line, no need to recalc Y position } else { if (myEditorSourceHeight < editorTargetHeight) { endY = myEditorScrollbarTop + endLineNumber * myEditor.getLineHeight(); } else { endY = myEditorScrollbarTop + (int)((float)endLineNumber / lineCount * editorTargetHeight); } } if (endY < startY) endY = startY; return new ProperTextRange(startY, endY); }
protected void changedUpdateImpl(@NotNull DocumentEvent e) { if (!isValid()) return; ProperTextRange newRange = applyChange(e, intervalStart(), intervalEnd(), isGreedyToLeft(), isGreedyToRight()); if (newRange == null) { invalidate(e); return; } setIntervalStart(newRange.getStartOffset()); setIntervalEnd(newRange.getEndOffset()); }
@Override protected void changedUpdateImpl(@NotNull DocumentEvent e) { if (!isValid()) return; Pair<ProperTextRange, LinesCols> pair = applyChange(e, this, intervalStart(), intervalEnd(), isGreedyToLeft(), isGreedyToRight(), myLinesCols); if (pair == null) { invalidate(e); return; } setIntervalStart(pair.first.getStartOffset()); setIntervalEnd(pair.first.getEndOffset()); myLinesCols = pair.second; }
private ManualRangeMarker(@NotNull ProperTextRange range, boolean greedyLeft, boolean greedyRight, @Nullable PersistentRangeMarker.LinesCols linesCols) { myRange = range; myGreedyLeft = greedyLeft; myGreedyRight = greedyRight; myLinesCols = linesCols; }
@NotNull private static SmartPointerElementInfo createElementInfo(@NotNull PsiFile containingFile, @NotNull ProperTextRange range, boolean forInjected) { Project project = containingFile.getProject(); if (containingFile.getViewProvider() instanceof FreeThreadedFileViewProvider) { PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(project).getInjectionHost(containingFile); if (host != null) { SmartPsiElementPointer<PsiLanguageInjectionHost> hostPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(host); return new InjectedSelfElementInfo(project, containingFile, range, containingFile, hostPointer); } } if (range.equals(containingFile.getTextRange())) return new FileElementInfo(containingFile); return new SelfElementInfo(project, range, PsiElement.class, containingFile, containingFile.getLanguage(), forInjected); }
@Nullable private ProperTextRange getInjectedRange(boolean psi) { PsiElement hostContext = myHostContext.getElement(); if (hostContext == null) return null; Segment hostElementRange = psi ? myInjectedFileRangeInHostFile.getPsiRange() : myInjectedFileRangeInHostFile.getRange(); if (hostElementRange == null) return null; return hostToInjected(psi, hostElementRange, restoreFile(), myAffixOffsets); }
@Override @Nullable public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile file, @NotNull final Editor editor) { TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL); if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, editor.getDocument()); ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor); return new InjectedGeneralHighlightingPass(myProject, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor, new DefaultHighlightInfoProcessor()); }
@Override public TextEditorHighlightingPass createMainHighlightingPass(@NotNull PsiFile file, @NotNull Document document, @NotNull HighlightInfoProcessor highlightInfoProcessor) { return new InjectedGeneralHighlightingPass(myProject, file, document, 0, document.getTextLength(), true, new ProperTextRange(0,document.getTextLength()), null, highlightInfoProcessor); }
@Override public void highlightsOutsideVisiblePartAreProduced(@NotNull final HighlightingSession session, @NotNull final List<HighlightInfo> infos, @NotNull final TextRange priorityRange, @NotNull final TextRange restrictedRange, final int groupId) { final PsiFile psiFile = session.getPsiFile(); final Project project = psiFile.getProject(); final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) return; final long modificationStamp = document.getModificationStamp(); UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { if (project.isDisposed() || modificationStamp != document.getModificationStamp()) return; EditorColorsScheme scheme = session.getColorsScheme(); UpdateHighlightersUtil.setHighlightersOutsideRange(project, document, psiFile, infos, scheme, restrictedRange.getStartOffset(), restrictedRange.getEndOffset(), ProperTextRange.create(priorityRange), groupId); Editor editor = session.getEditor(); if (editor != null) { DaemonListeners.repaintErrorStripeRenderer(editor, project); } } }); }
@Override @Nullable public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile file, @NotNull final Editor editor) { TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL); if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, editor.getDocument()); ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor); return new GeneralHighlightingPass(myProject, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor, new DefaultHighlightInfoProcessor()); }
@Override public TextEditorHighlightingPass createMainHighlightingPass(@NotNull PsiFile file, @NotNull Document document, @NotNull HighlightInfoProcessor highlightInfoProcessor) { // no applying to the editor - for read-only analysis only return new GeneralHighlightingPass(myProject, file, document, 0, file.getTextLength(), true, new ProperTextRange(0, document.getTextLength()), null, highlightInfoProcessor); }
@Override public void serializeMe(UsageInfo info, StringBuilder os) throws IOException { //final SmartPsiElementPointer<?> pointer = info.getSmartPointer(); final GenericElementSignatureProvider provider = new GenericElementSignatureProvider(); final String signature = provider.getSignature(info.getElement()); append(os, info.getFile().getVirtualFile().getPath()); os.append(separator); append(os, signature); os.append(separator); final ProperTextRange rangeInElement = info.getRangeInElement(); if (rangeInElement == null) { append(os, "-1"); os.append(separator); append(os, "-1"); os.append(separator); } else { append(os, String.valueOf(rangeInElement.getStartOffset())); os.append(separator); append(os, String.valueOf(rangeInElement.getEndOffset())); os.append(separator); } append(os, String.valueOf(info.isNonCodeUsage())); os.append(separator); append(os, String.valueOf(info.isDynamicUsage())); os.append(separator); final String text = new UsageInfo2UsageAdapter(info).getPlainText(); append(os, text); os.append(separator); }