mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
psi/document sync cleanup
This commit is contained in:
@@ -36,7 +36,6 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiLock;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.text.DiffLog;
|
||||
import com.intellij.psi.impl.source.tree.FileElement;
|
||||
@@ -163,7 +162,6 @@ public abstract class DocumentCommitProcessor {
|
||||
}
|
||||
finally {
|
||||
textBlock.clear();
|
||||
SmartPointerManagerImpl.synchronizePointers(file); //todo it's empty anyway, remove
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -365,9 +365,6 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
});
|
||||
}
|
||||
|
||||
public void commitOtherFilesAssociatedWithDocument(final Document document, final PsiFile psiFile) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T commitAndRunReadAction(@NotNull final Computable<T> computation) {
|
||||
final Ref<T> ref = Ref.create(null);
|
||||
|
||||
@@ -50,11 +50,6 @@ public class ClsElementInfo implements SmartPointerElementInfo {
|
||||
public void unfastenBelt(int offset) {
|
||||
}
|
||||
|
||||
// commit
|
||||
@Override
|
||||
public void documentAndPsiInSync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement restoreElement() {
|
||||
return myStubIndexReference.retrieve();
|
||||
|
||||
@@ -53,10 +53,6 @@ class FileElementInfo implements SmartPointerElementInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentAndPsiInSync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastenBelt(int offset, RangeMarker[] cachedRangeMarker) {
|
||||
}
|
||||
|
||||
@@ -42,10 +42,6 @@ class HardElementInfo implements SmartPointerElementInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentAndPsiInSync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastenBelt(int offset, RangeMarker[] cachedRangeMarker) {
|
||||
}
|
||||
|
||||
@@ -161,11 +161,6 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
myRangeMarker = null; // clear hard ref to avoid leak, hold soft ref for not recreating marker later
|
||||
}
|
||||
|
||||
// commit
|
||||
@Override
|
||||
public void documentAndPsiInSync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement restoreElement() {
|
||||
if (!mySyncMarkerIsValid) return null;
|
||||
|
||||
-1
@@ -29,7 +29,6 @@ interface SmartPointerElementInfo {
|
||||
@Nullable
|
||||
Document getDocumentToSynchronize();
|
||||
|
||||
void documentAndPsiInSync();
|
||||
void fastenBelt(int offset, RangeMarker[] cachedRangeMarkers);
|
||||
|
||||
void unfastenBelt(int offset);
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface SmartPointerEx<E extends PsiElement> extends SmartPsiElementPointer<E> {
|
||||
void fastenBelt(int offset, @Nullable RangeMarker[] cachedRangeMarkers);
|
||||
void documentAndPsiInSync();
|
||||
|
||||
void unfastenBelt(int offset);
|
||||
|
||||
|
||||
-33
@@ -17,11 +17,9 @@
|
||||
package com.intellij.psi.impl.smartPointers;
|
||||
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -37,7 +35,6 @@ import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl");
|
||||
@@ -108,36 +105,6 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void synchronizePointers(@NotNull PsiFile file) {
|
||||
final Set<Language> languages = file.getViewProvider().getLanguages();
|
||||
for (Language language : languages) {
|
||||
final PsiFile f = file.getViewProvider().getPsi(language);
|
||||
synchronized (f) {
|
||||
_synchronizePointers(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void _synchronizePointers(@NotNull PsiFile file) {
|
||||
List<SmartPointerEx> pointers = getPointers(file);
|
||||
if (pointers == null) return;
|
||||
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < pointers.size(); i++) {
|
||||
SmartPointerEx pointer = pointers.get(i);
|
||||
if (pointer != null) {
|
||||
pointer.documentAndPsiInSync();
|
||||
}
|
||||
}
|
||||
|
||||
final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject());
|
||||
for (Document document : InjectedLanguageManager.getInstance(file.getProject()).getCachedInjectedDocuments(file)) {
|
||||
PsiFile injectedfile = psiDocumentManager.getPsiFile(document);
|
||||
if (injectedfile == null) continue;
|
||||
_synchronizePointers(injectedfile);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Key<Reference<SmartPsiElementPointer>> CACHED_SMART_POINTER_KEY = Key.create("CACHED_SMART_POINTER_KEY");
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
-5
@@ -175,11 +175,6 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
return new SelfElementInfo(project, proper, element.getClass(), containingFile, containingFile.getLanguage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentAndPsiInSync() {
|
||||
myElementInfo.documentAndPsiInSync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unfastenBelt(int offset) {
|
||||
myElementInfo.unfastenBelt(offset);
|
||||
|
||||
@@ -140,20 +140,6 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
|
||||
return super.finishCommitInWriteAction(document, finishProcessors, synchronously);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commitOtherFilesAssociatedWithDocument(final Document document, final PsiFile psiFile) {
|
||||
super.commitOtherFilesAssociatedWithDocument(document, psiFile);
|
||||
final FileViewProvider viewProvider = getCachedViewProvider(document);
|
||||
if (viewProvider != null && viewProvider.getAllFiles().size() > 1) {
|
||||
PostprocessReformattingAspect.getInstance(myProject).disablePostprocessFormattingInside(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doCommit(document, psiFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDocumentBlockedByPsi(@NotNull Document doc) {
|
||||
final FileViewProvider viewProvider = getCachedViewProvider(doc);
|
||||
|
||||
Reference in New Issue
Block a user