use of com.intellij.psi.util.PsiModificationTracker in project intellij-community by JetBrains.
the class PsiModificationTrackerTest method testJavaStructureModificationChangesAfterPackageDelete.
public void testJavaStructureModificationChangesAfterPackageDelete() throws IOException {
final VirtualFile baseDir = getProject().getBaseDir();
VirtualFile virtualFile = createChildData(createChildDirectory(createChildDirectory(baseDir, "x"), "y"), "Z.java");
setFileText(virtualFile, "text");
configureByFile(virtualFile);
PsiFile file = getFile();
PsiModificationTracker modificationTracker = PsiManager.getInstance(getProject()).getModificationTracker();
long count = modificationTracker.getJavaStructureModificationCount();
ApplicationManager.getApplication().runWriteAction(() -> file.getContainingDirectory().delete());
assertTrue(count + ":" + modificationTracker.getJavaStructureModificationCount(), modificationTracker.getJavaStructureModificationCount() > count);
}
use of com.intellij.psi.util.PsiModificationTracker in project intellij-community by JetBrains.
the class PsiModificationTrackerTest method doTest.
private void doTest(@NonNls String text, Processor<PsiFile> run) {
PsiFile file = configureByText(JavaFileType.INSTANCE, text);
PsiModificationTracker modificationTracker = PsiManager.getInstance(getProject()).getModificationTracker();
long count = modificationTracker.getModificationCount();
WriteCommandAction.runWriteCommandAction(getProject(), () -> {
run.process(file);
});
assertFalse(modificationTracker.getModificationCount() == count);
}
use of com.intellij.psi.util.PsiModificationTracker in project intellij-community by JetBrains.
the class JavaCodeBlockModificationListener method onTreeChanged.
@Override
protected void onTreeChanged(@NotNull PsiTreeChangeEventImpl event) {
PsiModificationTracker tracker = myPsiManager.getModificationTracker();
long cur = tracker.getOutOfCodeBlockModificationCount();
super.onTreeChanged(event);
if (cur == tracker.getOutOfCodeBlockModificationCount()) {
PsiEventType code = event.getCode();
if (code == PsiEventType.CHILD_ADDED || code == PsiEventType.CHILD_REMOVED || code == PsiEventType.CHILD_REPLACED) {
if (hasClassesInside(event.getOldChild()) || event.getOldChild() != event.getChild() && hasClassesInside(event.getChild())) {
onOutOfCodeBlockModification(event);
doIncOutOfCodeBlockCounter();
}
}
}
}
Aggregations