From d6d5a6698ec33017a0aab61fe2001faae88b212a Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Sat, 7 Mar 2015 15:49:30 +0300 Subject: [PATCH] More test fixes --- .../completion/KeywordCompletionTest.java | 3 ++- .../psi/formatter/java/JavaFormatterTest.java | 5 ++++- .../refactoring/ChangeSignatureTest.java | 18 ++++++++++++------ .../refactoring/ExtractMethodTest.java | 6 ++++-- .../refactoring/RenameMethodMultiTest.java | 7 +++++-- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index b9511edf4a20..c5c00a12c9ad 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.completion; import com.intellij.JavaTestUtil; +import com.intellij.lang.java.JavaLanguage; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -66,7 +67,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testSynchronized1() throws Exception { doTest(false); } public void testSynchronized2() throws Exception { - CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false; + CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE).SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false; doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java index f14615280fed..3408467baaac 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java @@ -1960,12 +1960,14 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testCommentAfterDeclaration() throws Exception { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()); + CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE); int oldMargin = codeStyleSettings.getDefaultRightMargin(); + int oldWrap = javaSettings.ASSIGNMENT_WRAP; try { codeStyleSettings.setDefaultRightMargin(20); - codeStyleSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; + javaSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doMethodTest( "int i=0; //comment comment", "int i =\n" + @@ -1975,6 +1977,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } finally { codeStyleSettings.setDefaultRightMargin(oldMargin); + javaSettings.ASSIGNMENT_WRAP = oldWrap; } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java index 546c8c69d91c..7d9d730ea1ac 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java @@ -16,7 +16,9 @@ package com.intellij.refactoring; import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.lang.java.JavaLanguage; import com.intellij.psi.*; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor; import com.intellij.refactoring.changeSignature.JavaThrownExceptionInfo; import com.intellij.refactoring.changeSignature.ParameterInfoImpl; @@ -31,6 +33,10 @@ import java.util.HashSet; */ public class ChangeSignatureTest extends ChangeSignatureBaseTest { + private CommonCodeStyleSettings getJavaSettings() { + return getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE); + } + public void testSimple() { doTest(null, null, null, new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false); } @@ -363,20 +369,20 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest { } public void testMethodParametersAlignmentAfterMethodNameChange() { - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS = true; - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; + getJavaSettings().ALIGN_MULTILINE_PARAMETERS = true; + getJavaSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; doTest(null, "test123asd", null, new SimpleParameterGen(), new SimpleExceptionsGen(), false); } public void testMethodParametersAlignmentAfterMethodVisibilityChange() { - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS = true; - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; + getJavaSettings().ALIGN_MULTILINE_PARAMETERS = true; + getJavaSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; doTest(PsiModifier.PROTECTED, null, null, new SimpleParameterGen(), new SimpleExceptionsGen(), false); } public void testMethodParametersAlignmentAfterMethodReturnTypeChange() { - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS = true; - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; + getJavaSettings().ALIGN_MULTILINE_PARAMETERS = true; + getJavaSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; doTest(null, null, "Exception", new SimpleParameterGen(), new SimpleExceptionsGen(), false); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java index 1a2b9a6c9b1e..8889d010f5cc 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java @@ -17,12 +17,14 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.CodeInsightUtil; +import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.extractMethod.ExtractMethodHandler; import com.intellij.refactoring.extractMethod.ExtractMethodProcessor; @@ -397,9 +399,9 @@ public class ExtractMethodTest extends LightCodeInsightTestCase { } public void testForceBraces() throws Exception { - final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()); + final CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE); int old = settings.IF_BRACE_FORCE; - settings.IF_BRACE_FORCE = CodeStyleSettings.FORCE_BRACES_ALWAYS; + settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS; try { doTest(); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/RenameMethodMultiTest.java b/java/java-tests/testSrc/com/intellij/refactoring/RenameMethodMultiTest.java index 9df3bebcd6dd..0bd3fc0ff24c 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/RenameMethodMultiTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/RenameMethodMultiTest.java @@ -16,6 +16,7 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; +import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.vfs.VirtualFile; @@ -23,6 +24,7 @@ import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiMethod; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.rename.RenameProcessor; import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory; @@ -82,8 +84,9 @@ public class RenameMethodMultiTest extends MultiFileTestCase { } public void testAlignedMultilineParameters() throws Exception { - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS = true; - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; + CommonCodeStyleSettings javaSettings = getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE); + javaSettings.ALIGN_MULTILINE_PARAMETERS = true; + javaSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; doTest("void test123(int i, int j)", "test123asd"); }