Commit 71d5027f authored by Daniil Ovchinnikov's avatar Daniil Ovchinnikov
Browse files

[groovy] follow up IDEA-CR-41748

parent c6b2fb94
Showing with 16 additions and 23 deletions
+16 -23
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.psi;
import com.intellij.openapi.application.ApplicationManager;
......@@ -6,7 +7,6 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiTreeChangeAdapter;
import com.intellij.psi.PsiTreeChangeEvent;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
......@@ -24,28 +24,21 @@ public class GroovyPsiEventsTest extends LightCodeInsightFixtureTestCase {
gotIt.set(true);
}
};
PsiManager manager = getPsiManager();
try {
manager.addPsiTreeChangeListener(listener);
Project project = getProject();
GroovyFile file = GroovyPsiElementFactory.getInstance(project).createGroovyFile("/** This is doc comment*/class C{}", true, null);
PsiDocumentManager docManager = PsiDocumentManager.getInstance(project);
Document doc = docManager.getDocument(file);
assertNotNull(doc);
CommandProcessor.getInstance().executeCommand(project,
() -> ApplicationManager.getApplication().runWriteAction(() -> {
doc.insertString(3, " ");
docManager.commitDocument(doc);
}),
"file text set",
this
);
}
finally {
manager.removePsiTreeChangeListener(listener);
}
getPsiManager().addPsiTreeChangeListener(listener, getTestRootDisposable());
Project project = getProject();
GroovyFile file = GroovyPsiElementFactory.getInstance(project).createGroovyFile("/** This is doc comment*/class C{}", true, null);
PsiDocumentManager docManager = PsiDocumentManager.getInstance(project);
Document doc = docManager.getDocument(file);
assertNotNull(doc);
CommandProcessor.getInstance().executeCommand(
project,
() -> ApplicationManager.getApplication().runWriteAction(() -> {
doc.insertString(3, " ");
docManager.commitDocument(doc);
}),
"file text set",
this
);
assertTrue(gotIt.get());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment