use of com.intellij.psi.PsiTreeChangeAdapter in project intellij-community by JetBrains.
the class PsiEventsTest method testEditingInDocComment.
public void testEditingInDocComment() throws Exception {
final Ref<Boolean> gotIt = new Ref<>(false);
getPsiManager().addPsiTreeChangeListener(new PsiTreeChangeAdapter() {
@Override
public void childReplaced(@NotNull PsiTreeChangeEvent event) {
gotIt.set(true);
}
});
GroovyFile file = GroovyPsiElementFactory.getInstance(myProject).createGroovyFile("/** This is doc comment*/class C{}", true, null);
final PsiDocumentManager docManager = PsiDocumentManager.getInstance(myProject);
final Document doc = docManager.getDocument(file);
assertNotNull(doc);
CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
doc.insertString(3, " ");
docManager.commitDocument(doc);
}), "file text set", this);
assertTrue(gotIt.get());
}
Aggregations