Groovy: fix inline in GString, replaceWithExpression
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Mon, 5 Oct 2009 12:33:50 +0000 (16:33 +0400)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Mon, 5 Oct 2009 12:34:38 +0000 (16:34 +0400)
plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineVariableTest.java
plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test [new file with mode: 0644]
plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test [new file with mode: 0644]
plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test [new file with mode: 0644]

index 9552ca9dfa2315794b359f75ee7fedde3c8fb33e..3c9685e18b55d040cafc7c241df3a6fc91413694 100644 (file)
@@ -100,6 +100,7 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
   public void testParameterIsUsedAfterCall() throws Throwable { doTest(); }
   public void testFieldAsParameter() throws Throwable { doTest(); }
   public void testWritableVariable() throws Throwable { doTest(); }
+  public void testInlineInGString() throws Throwable {doTest(); }
 
   public void testInlineAll() throws Throwable {
     doTest(new GroovyInlineHandler() {
index 491426c479fcefe33d2db829a1f0e52eb5d24bc0..f4a9473ebbf7d14b78d2a5bc702f3def0a680c0d 100644 (file)
@@ -39,6 +39,8 @@ public class InlineVariableTest extends LightCodeInsightFixtureTestCase {
   public void testVar4() throws Throwable { doTest(); }
   public void testVar5() throws Throwable { doTest(); }
   public void testVar6() throws Throwable { doTest(); }
+  public void testVarInGString() throws Throwable { doTest(); }
+  public void testVarInGString2() throws Throwable { doTest(); }
 
   protected void doTest() throws IncorrectOperationException, InvalidDataException, IOException {
     InlineMethodTest.doInlineTest(myFixture, getTestDataPath() + getTestName(true) + ".test", true, new GroovyInlineHandler());
diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test
new file mode 100644 (file)
index 0000000..2c4c76f
--- /dev/null
@@ -0,0 +1,4 @@
+def <begin>s<end>="$x+$y"
+print "${s}wow+$s"
+-----
+<caret>print "$x+${y}wow+$x+$y"
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test
new file mode 100644 (file)
index 0000000..e499157
--- /dev/null
@@ -0,0 +1,4 @@
+def <begin>s<end>='abc"cde';
+print "$s"
+-----
+<caret>print "abc\"cde"
diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test
new file mode 100644 (file)
index 0000000..4c49868
--- /dev/null
@@ -0,0 +1,11 @@
+def foo(int x) {
+  return "foo(x = $x)";
+}
+
+print "foo(2) = ${<begin>foo<end>(2)}";
+-----
+def foo(int x) {
+  return "foo(x = $x)";
+}
+
+print "foo(2) = foo(x = 2)";