Remove usages of deprecated CodeStyleSettings.RIGHT_MARGIN field
authorRustam Vishnyakov <rustam.vishnyakov@jetbrains.com>
Tue, 19 Aug 2014 12:39:28 +0000 (16:39 +0400)
committerRustam Vishnyakov <rustam.vishnyakov@jetbrains.com>
Tue, 19 Aug 2014 13:07:45 +0000 (17:07 +0400)
python/testSrc/com/jetbrains/python/PyFillParagraphTest.java
python/testSrc/com/jetbrains/python/PyFormatterTest.java
python/testSrc/com/jetbrains/python/PyWrapTest.java

index 0a26253aec5657b249f8934b49f98a4c35fe4cf1..287c65f9e8a1faa06cb1e0810ce250139a71e953 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.psi.codeStyle.CodeStyleSettings;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import com.jetbrains.python.fixtures.PyTestCase;
 
 /**
@@ -62,7 +63,8 @@ public class PyFillParagraphTest extends PyTestCase {
   }
 
   public void testEnter() {
-    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
+    final CommonCodeStyleSettings settings =
+      CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings().getCommonSettings(PythonLanguage.getInstance());
     int oldValue = settings.RIGHT_MARGIN;
     settings.RIGHT_MARGIN = 80;
     try {
index 36805442a1ea914935fede12498e27b59fe97b61..ca0520c7b6a581b41cd94fa7bb522ebd81661544 100644 (file)
@@ -273,19 +273,19 @@ public class PyFormatterTest extends PyTestCase {
   }
 
   public void testWrapDefinitionWithLongLine() { // IDEA-92081
-    settings().RIGHT_MARGIN = 30;
+    settings().setRightMargin(PythonLanguage.getInstance(), 30);
     settings().WRAP_LONG_LINES = true;
     doTest();
   }
 
   public void testWrapAssignment() {  // PY-8572
-    settings().RIGHT_MARGIN = 120;
+    settings().setRightMargin(PythonLanguage.getInstance(), 120);
     settings().WRAP_LONG_LINES = false;
     doTest();
   }
 
   public void testIndentInSlice() {  // PY-8572
-    settings().RIGHT_MARGIN = 120;
+    settings().setRightMargin(PythonLanguage.getInstance(), 120);
     settings().WRAP_LONG_LINES = false;
     doTest();
   }
@@ -352,7 +352,7 @@ public class PyFormatterTest extends PyTestCase {
   }
 
   public void testWrapInBinaryExpression() {  // PY-9032
-    settings().RIGHT_MARGIN = 80;
+    settings().setRightMargin(PythonLanguage.getInstance(), 80);
     doTest(true);
   }
 
@@ -370,7 +370,7 @@ public class PyFormatterTest extends PyTestCase {
   }
 
   public void testWrapImports() {  // PY-9163
-    settings().RIGHT_MARGIN = 80;
+    settings().setRightMargin(PythonLanguage.getInstance(), 80);
     doTest();
   }
 
index 05c21b8af21a909418b0c25e91291b408282389e..4146391ea5d8d2fc3f2ac6537f881951c1818bd4 100644 (file)
@@ -17,6 +17,7 @@ package com.jetbrains.python;
 
 import com.intellij.psi.codeStyle.CodeStyleSettings;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import com.jetbrains.python.fixtures.PyTestCase;
 
 /**
@@ -30,17 +31,19 @@ public class PyWrapTest extends PyTestCase {
   protected void setUp() throws Exception {
     super.setUp();
     final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
+    final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
     myOldWrap = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
-    myOldMargin = settings.RIGHT_MARGIN;
+    myOldMargin = pythonSettings.RIGHT_MARGIN;
     settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
-    settings.RIGHT_MARGIN = 80;
+    pythonSettings.RIGHT_MARGIN = 80;
   }
 
   @Override
   protected void tearDown() throws Exception {
     final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
+    final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
     settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myOldWrap;
-    settings.RIGHT_MARGIN = myOldMargin;
+    pythonSettings.RIGHT_MARGIN = myOldMargin;
     super.tearDown();
   }
 
@@ -71,9 +74,10 @@ public class PyWrapTest extends PyTestCase {
 
   public void testWrapRightMargin() {
     final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
-    int oldValue = settings.RIGHT_MARGIN;
+    final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
+    int oldValue = pythonSettings.RIGHT_MARGIN;
     boolean oldMarginValue = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
-    settings.RIGHT_MARGIN = 100;
+    pythonSettings.RIGHT_MARGIN = 100;
     settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
     try {
       final String testName = "wrap/" + getTestName(true);
@@ -84,7 +88,7 @@ public class PyWrapTest extends PyTestCase {
       myFixture.checkResultByFile(testName + ".after.py");
     }
     finally {
-      settings.RIGHT_MARGIN = oldValue;
+      pythonSettings.RIGHT_MARGIN = oldValue;
       settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = oldMarginValue;
     }
   }