public PropertiesAnchorizer(Project project) { PsiManager.getInstance(project).addPsiTreeChangeListener(new PsiTreeChangeAdapter() { @Override public void childRemoved(@NotNull PsiTreeChangeEvent event) { final PsiElement removed = event.getChild(); if (removed instanceof IProperty) { myAnchors.remove(removed); } } }); }
public void testEditingInDocComment() throws Exception { final Ref<Boolean> gotIt = new Ref<Boolean>(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, new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { doc.insertString(3, " "); docManager.commitDocument(doc); } }); } }, "file text set", this ); assertTrue(gotIt.get()); }