mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more logging
This commit is contained in:
+13
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,18 +53,18 @@ public class FileStatusMap implements Disposable {
|
||||
private final Map<Document,FileStatus> myDocumentToStatusMap = new WeakHashMap<Document, FileStatus>(); // all dirty if absent
|
||||
private volatile boolean myAllowDirt = true;
|
||||
|
||||
public FileStatusMap(@NotNull Project project) {
|
||||
FileStatusMap(@NotNull Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// clear dangling references to PsiFiles/Documents. SCR#10358
|
||||
markAllFilesDirty();
|
||||
markAllFilesDirty("FileStatusMap dispose");
|
||||
}
|
||||
|
||||
@Nullable("null means the file is clean")
|
||||
public static TextRange getDirtyTextRange(@NotNull Editor editor, int passId) {
|
||||
static TextRange getDirtyTextRange(@NotNull Editor editor, int passId) {
|
||||
Document document = editor.getDocument();
|
||||
|
||||
FileStatusMap me = DaemonCodeAnalyzerEx.getInstanceEx(editor.getProject()).getFileStatusMap();
|
||||
@@ -87,7 +87,7 @@ public class FileStatusMap implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean wasErrorFound(@NotNull Document document) {
|
||||
boolean wasErrorFound(@NotNull Document document) {
|
||||
synchronized(myDocumentToStatusMap) {
|
||||
FileStatus status = myDocumentToStatusMap.get(document);
|
||||
return status != null && status.errorFound;
|
||||
@@ -164,9 +164,9 @@ public class FileStatusMap implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public void markAllFilesDirty() {
|
||||
void markAllFilesDirty(@NotNull @NonNls Object reason) {
|
||||
assertAllowModifications();
|
||||
LOG.debug("********************************* Mark all dirty");
|
||||
LOG.debug("Mark all dirty: ", reason);
|
||||
synchronized (myDocumentToStatusMap) {
|
||||
myDocumentToStatusMap.clear();
|
||||
}
|
||||
@@ -220,10 +220,10 @@ public class FileStatusMap implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public void markFileScopeDirtyDefensively(@NotNull PsiFile file) {
|
||||
void markFileScopeDirtyDefensively(@NotNull PsiFile file, @NotNull @NonNls Object reason) {
|
||||
assertAllowModifications();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("********************************* Mark dirty file defensively: "+file.getName());
|
||||
LOG.debug("Mark dirty file defensively: "+file.getName()+": "+reason);
|
||||
}
|
||||
// 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
|
||||
@@ -236,10 +236,10 @@ public class FileStatusMap implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public void markFileScopeDirty(@NotNull Document document, @NotNull TextRange scope, int fileLength) {
|
||||
void markFileScopeDirty(@NotNull Document document, @NotNull TextRange scope, int fileLength, @NotNull @NonNls Object reason) {
|
||||
assertAllowModifications();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("********************************* Mark dirty: "+scope);
|
||||
LOG.debug("Mark scope dirty: "+scope+" : "+reason);
|
||||
}
|
||||
synchronized(myDocumentToStatusMap) {
|
||||
FileStatus status = myDocumentToStatusMap.get(document);
|
||||
@@ -270,7 +270,7 @@ public class FileStatusMap implements Disposable {
|
||||
return document.createRangeMarker(union);
|
||||
}
|
||||
|
||||
public boolean allDirtyScopesAreNull(@NotNull Document document) {
|
||||
boolean allDirtyScopesAreNull(@NotNull Document document) {
|
||||
synchronized (myDocumentToStatusMap) {
|
||||
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
|
||||
if (!ProblemHighlightFilter.shouldHighlightFile(file)) return true;
|
||||
@@ -342,7 +342,7 @@ public class FileStatusMap implements Disposable {
|
||||
|
||||
@Override
|
||||
public <T> T getUserData(@NotNull Key<T> key) {
|
||||
throw null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ public class PsiTreeChangeEventImpl extends PsiTreeChangeEvent{
|
||||
|
||||
private PsiEventType myCode;
|
||||
|
||||
public PsiTreeChangeEventImpl(PsiManager manager) {
|
||||
public PsiTreeChangeEventImpl(@NotNull PsiManager manager) {
|
||||
super(manager);
|
||||
}
|
||||
|
||||
@@ -124,8 +124,9 @@ public class PsiTreeChangeEventImpl extends PsiTreeChangeEvent{
|
||||
isGenericChange = genericChange;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiTreeChangeEventImpl{myCode=" + myCode + (isGenericChange ? " (generic)" : "") + '}';
|
||||
return "PsiTreeChangeEventImpl{" + myCode + (isGenericChange ? " (generic)" : "") + '}';
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -143,7 +143,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
|
||||
myInitialized = true;
|
||||
myDisposed = false;
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty("DCAI init");
|
||||
Disposer.register(this, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
@@ -477,7 +477,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty("Global restart");
|
||||
stopProcess(true, "Global restart");
|
||||
}
|
||||
|
||||
@@ -485,8 +485,9 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
public void restart(@NotNull PsiFile file) {
|
||||
Document document = myPsiDocumentManager.getCachedDocument(file);
|
||||
if (document == null) return;
|
||||
myFileStatusMap.markFileScopeDirty(document, new TextRange(0, document.getTextLength()), file.getTextLength());
|
||||
stopProcess(true, "Psi file restart");
|
||||
String reason = "Psi file restart: " + file.getName();
|
||||
myFileStatusMap.markFileScopeDirty(document, new TextRange(0, document.getTextLength()), file.getTextLength(), reason);
|
||||
stopProcess(true, reason);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -178,7 +178,7 @@ class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable {
|
||||
// mark file dirty just in case
|
||||
PsiFile psiFile = event.getFile();
|
||||
if (psiFile != null) {
|
||||
myFileStatusMap.markFileScopeDirtyDefensively(psiFile);
|
||||
myFileStatusMap.markFileScopeDirtyDefensively(psiFile, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,15 +186,15 @@ class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable {
|
||||
public void propertyChanged(@NotNull PsiTreeChangeEvent event) {
|
||||
String propertyName = event.getPropertyName();
|
||||
if (!propertyName.equals(PsiTreeChangeEvent.PROP_WRITABLE)) {
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty(event);
|
||||
}
|
||||
}
|
||||
|
||||
private void queueElement(PsiElement child, final boolean whitespaceOptimizationAllowed, PsiTreeChangeEvent event) {
|
||||
private void queueElement(@NotNull PsiElement child, final boolean whitespaceOptimizationAllowed, @NotNull PsiTreeChangeEvent event) {
|
||||
PsiFile file = event.getFile();
|
||||
if (file == null) file = child.getContainingFile();
|
||||
if (file == null) {
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty(child);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -216,30 +216,30 @@ class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable {
|
||||
file = child.getContainingFile();
|
||||
}
|
||||
catch (PsiInvalidElementAccessException e) {
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty(e);
|
||||
return;
|
||||
}
|
||||
if (file == null || file instanceof PsiCompiledElement) {
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty(child);
|
||||
return;
|
||||
}
|
||||
|
||||
int fileLength = file.getTextLength();
|
||||
if (!file.getViewProvider().isPhysical()) {
|
||||
myFileStatusMap.markFileScopeDirty(document, new TextRange(0, fileLength), fileLength);
|
||||
myFileStatusMap.markFileScopeDirty(document, new TextRange(0, fileLength), fileLength, "Non-physical file update: "+file);
|
||||
return;
|
||||
}
|
||||
|
||||
PsiElement element = whitespaceOptimizationAllowed && UpdateHighlightersUtil.isWhitespaceOptimizationAllowed(document) ? child : child.getParent();
|
||||
while (true) {
|
||||
if (element == null || element instanceof PsiFile || element instanceof PsiDirectory) {
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
myFileStatusMap.markAllFilesDirty("Top element: "+element);
|
||||
return;
|
||||
}
|
||||
|
||||
final PsiElement scope = getChangeHighlightingScope(element);
|
||||
if (scope != null) {
|
||||
myFileStatusMap.markFileScopeDirty(document, scope.getTextRange(), fileLength);
|
||||
myFileStatusMap.markFileScopeDirty(document, scope.getTextRange(), fileLength, "Scope: "+scope);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user