public void markFileScopeDirty( @NotNull Document document, @NotNull TextRange scope, int fileLength) { assertAllowModifications(); if (LOG.isDebugEnabled()) { LOG.debug("********************************* Mark dirty: " + scope); } synchronized (myDocumentToStatusMap) { FileStatus status = myDocumentToStatusMap.get(document); if (status == null) return; // all dirty already if (status.defensivelyMarked) { status.defensivelyMarked = false; } status.combineScopesWith(scope, fileLength, document); } }
public void markFileUpToDate(@NotNull Document document, int passId) { synchronized (myDocumentToStatusMap) { FileStatus status = myDocumentToStatusMap.get(document); if (status == null) { status = new FileStatus(myProject); myDocumentToStatusMap.put(document, status); } status.defensivelyMarked = false; if (passId == Pass.WOLF) { status.wolfPassFinished = true; } else if (status.dirtyScopes.containsKey(passId)) { status.setDirtyScope(passId, null); } } }
public void markFileScopeDirtyDefensively(@NotNull PsiFile file) { assertAllowModifications(); if (LOG.isDebugEnabled()) { LOG.debug("********************************* Mark dirty file defensively: " + file.getName()); } // mark whole file dirty in case no subsequent PSI events will come, but file requires // rehighlighting nevertheless // e.g. in the case of quick typing/backspacing char synchronized (myDocumentToStatusMap) { Document document = PsiDocumentManager.getInstance(myProject).getCachedDocument(file); if (document == null) return; FileStatus status = myDocumentToStatusMap.get(document); if (status == null) return; // all dirty already status.defensivelyMarked = true; } }
/** * @return null for processed file, whole file for untouched or entirely dirty file, range(usually * code block) for dirty region (optimization) */ @Nullable public TextRange getFileDirtyScope(@NotNull Document document, int passId) { synchronized (myDocumentToStatusMap) { PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(document); if (!ProblemHighlightFilter.shouldHighlightFile(file)) return null; FileStatus status = myDocumentToStatusMap.get(document); if (status == null) { return file == null ? null : file.getTextRange(); } if (status.defensivelyMarked) { status.markWholeFileDirty(myProject); status.defensivelyMarked = false; } LOG.assertTrue(status.dirtyScopes.containsKey(passId), "Unknown pass " + passId); RangeMarker marker = status.dirtyScopes.get(passId); return marker == null ? null : marker.isValid() ? TextRange.create(marker) : new TextRange(0, document.getTextLength()); } }