Exemplo n.º 1
0
 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);
   }
 }
Exemplo n.º 2
0
 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);
     }
   }
 }
Exemplo n.º 3
0
 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;
   }
 }
Exemplo n.º 4
0
 /**
  * @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());
   }
 }