Rearranger: commit document before processing (IDEA-144637)

This commit is contained in:
Yaroslav Lepenkin
2015-09-04 15:03:46 +03:00
parent ac370231fc
commit 161cfae7c9
4 changed files with 21 additions and 1 deletions
@@ -0,0 +1,7 @@
public class TestClass {
public static void main() {
}
static class InnerClass {
}
}
@@ -0,0 +1,8 @@
public class TestClass {
static class InnerClass {
}
<caret>
public static void main() {
}
}
@@ -102,6 +102,10 @@ public class ReformatCodeActionInEditorTest extends LightPlatformCodeInsightFixt
public void testFormatOptimizeRearrangeVcsChanges() {
doTest(new ReformatCodeRunOptions(VCS_CHANGED_TEXT).setOptimizeImports(true).setRearrangeCode(true));
}
public void testReformatRearrange_NotBreaksCode_WhenCaretOnEmptyLine() {
doTest(new ReformatCodeRunOptions(WHOLE_FILE).setRearrangeCode(true));
}
public void testFormatSelection_DoNotTouchTrailingWhiteSpaces() {
//todo actually test is not working, and working test is not working
@@ -80,8 +80,9 @@ public class RearrangeCodeProcessor extends AbstractLayoutCodeProcessor {
Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);
if (document != null && Rearranger.EXTENSION.forLanguage(file.getLanguage()) != null) {
Runnable command = prepareRearrangeCommand(file, ranges);
PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(document);
PsiDocumentManager.getInstance(myProject).commitDocument(document);
Runnable command = prepareRearrangeCommand(file, ranges);
try {
CommandProcessor.getInstance().executeCommand(myProject, command, COMMAND_NAME, null);
}