diff --git a/platform/testFramework/testSrc/com/intellij/psi/formatter/FormatterTestCase.java b/platform/testFramework/testSrc/com/intellij/psi/formatter/FormatterTestCase.java index 2f6b52687955..2afd09168420 100644 --- a/platform/testFramework/testSrc/com/intellij/psi/formatter/FormatterTestCase.java +++ b/platform/testFramework/testSrc/com/intellij/psi/formatter/FormatterTestCase.java @@ -1,33 +1,17 @@ /* - * Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2013 JetBrains s.r.o. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * -Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * -Redistribution in binary form must reproduct the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - * Neither the name of JetBrains or IntelliJ IDEA - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING - * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT - * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT - * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST - * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, - * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY - * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN - * IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * http://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.intellij.psi.formatter; @@ -38,6 +22,7 @@ import com.intellij.mock.MockProgressIndicator; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.command.impl.UndoManagerImpl; import com.intellij.openapi.command.undo.UndoManager; import com.intellij.openapi.editor.Document; @@ -206,38 +191,34 @@ public abstract class FormatterTestCase extends LightPlatformTestCase { editor = null; } - CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { + WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() { @Override public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - document.replaceString(0, document.getTextLength(), text); - PsiDocumentManager.getInstance(getProject()).commitDocument(document); - assertEquals(file.getText(), document.getText()); - - if (false && doCheckDocumentUpdate()) { - makeFolding(file, editor); - } - try { - if (doReformatRangeTest) { - CodeStyleManager.getInstance(getProject()).reformatRange(file, file.getTextRange().getStartOffset(), file.getTextRange().getEndOffset()); - } else if (myTextRange != null) { - CodeStyleManager.getInstance(getProject()).reformatText(file, myTextRange.getStartOffset(), myTextRange.getEndOffset()); - } - else { - CodeStyleManager.getInstance(getProject()) - .reformatText(file, file.getTextRange().getStartOffset(), file.getTextRange().getEndOffset()); - } - } - catch (IncorrectOperationException e) { - fail(); - } + document.replaceString(0, document.getTextLength(), text); + PsiDocumentManager.getInstance(getProject()).commitDocument(document); + assertEquals(file.getText(), document.getText()); + if (false && doCheckDocumentUpdate()) { + makeFolding(file, editor); + } + try { + if (doReformatRangeTest) { + CodeStyleManager.getInstance(getProject()) + .reformatRange(file, file.getTextRange().getStartOffset(), file.getTextRange().getEndOffset()); } - }); + else if (myTextRange != null) { + CodeStyleManager.getInstance(getProject()).reformatText(file, myTextRange.getStartOffset(), myTextRange.getEndOffset()); + } + else { + CodeStyleManager.getInstance(getProject()) + .reformatText(file, file.getTextRange().getStartOffset(), file.getTextRange().getEndOffset()); + } + } + catch (IncorrectOperationException e) { + fail(); + } } - }, "", ""); + }); assertEquals(textAfter, document.getText()); PsiDocumentManager.getInstance(getProject()).commitDocument(document);