use more orthodox way of specifying selection

This commit is contained in:
peter
2011-02-02 21:58:57 +01:00
parent 5b5f95cccf
commit 612facfc73
62 changed files with 63 additions and 70 deletions
@@ -42,9 +42,6 @@ import java.util.List;
* @author ilyas
*/
public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
public static final String CARET_MARKER = "<caret>";
public static final String BEGIN_MARKER = "<begin>";
public static final String END_MARKER = "<end>";
@Override
protected String getBasePath() {
@@ -130,17 +127,13 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
final List<String> data = TestUtils.readInput(testFile);
String fileText = data.get(0);
int startOffset = fileText.indexOf(BEGIN_MARKER);
fileText = TestUtils.removeBeginMarker(fileText);
int endOffset = fileText.indexOf(END_MARKER);
fileText = TestUtils.removeEndMarker(fileText);
fixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, fileText);
final PsiFile file = fixture.getFile();
final Editor editor = fixture.getEditor();
setIndentationToNode(file.getNode());
editor.getSelectionModel().setSelection(startOffset, endOffset);
int startOffset = editor.getSelectionModel().getSelectionStart();
int endOffset = editor.getSelectionModel().getSelectionEnd();
editor.getCaretModel().moveToOffset(endOffset);
GroovyPsiElement selectedArea = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) file), startOffset, endOffset, GrReferenceExpression.class);
@@ -1,6 +1,6 @@
{
int a = 1
<begin>a<end> + b
<selection>a</selection> + b
}
-----
{
@@ -1,4 +1,4 @@
New var = new New();
<begin>var<end>.foo()
<selection>var</selection>.foo()
-----
new New()<caret>.foo()
@@ -1,5 +1,5 @@
class Foo {
final def <begin>foo<end> = 2+2
final def <selection>foo</selection> = 2+2
def a() {
print foo.intValue()
@@ -1,4 +1,4 @@
def var = 1
<begin>var<end>
<selection>var</selection>
-----
1<caret>
@@ -1,4 +1,4 @@
def <begin>preved<end> = 42
def <selection>preved</selection> = 42
println preved + preved * preved
-----
<caret>println 42 + 42 * 42
@@ -1,4 +1,4 @@
def sum = 2 + 2
def mul = 3 * <begin>sum<end>
def mul = 3 * <selection>sum</selection>
-----
def mul = 3 * (2 + 2)<caret>
@@ -1,4 +1,4 @@
def sum = 2 + 2
def diff = 3 - <begin>sum<end>
def diff = 3 - <selection>sum</selection>
-----
def diff = 3 - (2 + 2)<caret>
@@ -1,4 +1,4 @@
def sum = (2 + 2)
def diff = <begin>sum<end> - 3
def diff = <selection>sum</selection> - 3
-----
def diff = 2 + 2<caret> - 3
@@ -1,4 +1,4 @@
def sum = new A()
def diff = <begin>sum<end>.dec()
def diff = <selection>sum</selection>.dec()
-----
def diff = new A()<caret>.dec()
@@ -1,4 +1,4 @@
def <begin>s<end>="$x+$y"
def <selection>s</selection>="$x+$y"
print "${s}wow+$s"
-----
<caret>print "$x+${y}wow+$x+$y"
@@ -1,4 +1,4 @@
def <begin>s<end>='abc"cde';
def <selection>s</selection>='abc"cde';
print "$s"
-----
<caret>print "abc\"cde"
@@ -3,7 +3,7 @@ abstract class A{
abstract def foo()
def boo() {
<begin>foo<end>()
<selection>foo</selection>()
}
}
@@ -2,7 +2,7 @@ def tail(int jjj) {
println jjj
if (true)
return <begin>fact<end>(jjj)
return <selection>fact</selection>(jjj)
else
return fact(jjj)
}
@@ -4,7 +4,7 @@ def tail(int jjj) {
if (true)
return fact(jjj)
else
return <begin>fact<end>(jjj)
return <selection>fact</selection>(jjj)
}
@@ -2,7 +2,7 @@ def tail(int jjj) {
println jjj
if (true)
return 1 + fact(jjj)
else 1 + <begin>fact<end>(jjj)
else 1 + <selection>fact</selection>(jjj)
}
int fact(int n) {
@@ -1,6 +1,6 @@
def baal(int jjj) {
while (true)
println(<begin>fact<end>(jjj))
println(<selection>fact</selection>(jjj))
}
@@ -5,7 +5,7 @@ int fact(int n) {
def foo(int i) {
switch (i) {
case 42: return <begin>fact<end>(5)
case 42: return <selection>fact</selection>(5)
default:
return fact(7)
}
@@ -7,7 +7,7 @@ def foo(int i) {
switch (i) {
case 42: return fact(5)
default:
return <begin>fact<end>(7)
return <selection>fact</selection>(7)
}
}
-----
@@ -1,4 +1,4 @@
def cl = <begin>qwerty<end>({int x -> return x + 1})
def cl = <selection>qwerty</selection>({int x -> return x + 1})
def qwerty(Closure cl){
def call = cl.call()
@@ -1,4 +1,4 @@
def cl = <begin>qwerty<end>{int x -> return x + 1}{int x -> return x + 1}
def cl = <selection>qwerty</selection>{int x -> return x + 1}{int x -> return x + 1}
def qwerty(Closure cl, Closure cl2){
def call = cl(42)
@@ -1,4 +1,4 @@
def cl = <begin>qwerty<end>(45){int x -> return x + 1}
def cl = <selection>qwerty</selection>(45){int x -> return x + 1}
def qwerty(int i, Closure cl){
def call = cl(42)
@@ -1,6 +1,6 @@
def cond = true
if (<begin>qqqqq<end>(cond)) {
if (<selection>qqqqq</selection>(cond)) {
println "a"
} else {
println ("b")
@@ -2,7 +2,7 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
return a + b + c + t + m + n + d + e
}
println(<begin>foo<end>())
println(<selection>foo</selection>())
-----
int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
return a + b + c + t + m + n + d + e
@@ -2,7 +2,7 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
return a + b + c + t + m + n + d + e
}
println(<begin>foo<end>(1,2,3,4))
println(<selection>foo</selection>(1,2,3,4))
-----
int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
return a + b + c + t + m + n + d + e
@@ -2,7 +2,7 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
return a + b + c + t + m + n + d + e
}
println(<begin>foo<end>(1,2,3,4,5,6,7))
println(<selection>foo</selection>(1,2,3,4,5,6,7))
-----
int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
return a + b + c + t + m + n + d + e
@@ -2,7 +2,7 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
a + b + c + t + m + n + d + e
}
println(<begin>foo<end>(1,2,3,4,5,6,7,8,9,10))
println(<selection>foo</selection>(1,2,3,4,5,6,7,8,9,10))
-----
int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) {
a + b + c + t + m + n + d + e
@@ -5,7 +5,7 @@ class X {
}
int x(final int x, int y) {
return <begin>foo<end>(x + y);
return <selection>foo</selection>(x + y);
}
}
-----
@@ -3,7 +3,7 @@ int fact(int n) {
else return 1;
}
println(<begin>fact<end>(3))
println(<selection>fact</selection>(3))
-----
int fact(int n) {
if (n > 0) return n * fact(n-1);
@@ -1,5 +1,5 @@
int fact(int n) {
if (n > 0) return n * <begin>fact<end>(n - 1);
if (n > 0) return n * <selection>fact</selection>(n - 1);
else return 1;
}
-----
@@ -6,7 +6,7 @@ class X {
}
{
<begin>foo<end>(a);
<selection>foo</selection>(a);
}
}
-----
@@ -4,7 +4,7 @@ def foo(int x) {
}
final i = 5;
print <begin>foo<end>(i);
print <selection>foo</selection>(i);
-----
def foo(int x) {
x++;
@@ -1,6 +1,6 @@
def result = 26
def bar(int h = <begin>foo<end>(42, 239)) {}
def bar(int h = <selection>foo</selection>(42, 239)) {}
def foo(int i, def j) {
if (i > 42) {
@@ -6,7 +6,7 @@ class X {
{
int x = 6, y = 3;
return foo(foo(x) + <begin>foo<end>(y))
return foo(foo(x) + <selection>foo</selection>(y))
}
}
-----
@@ -2,7 +2,7 @@ def foo(int x) {
return "foo(x = $x)";
}
print "foo(2) = ${<begin>foo<end>(2)}";
print "foo(2) = ${<selection>foo</selection>(2)}";
-----
def foo(int x) {
return "foo(x = $x)";
@@ -2,7 +2,7 @@ int bar(args1, i, k = 5, j) {
return args1.c + i + k + j
}
def t = <begin>bar<end>(24, a: 1, b: 2, c: 3, d: 1, e: 2, f: 3, 23)
def t = <selection>bar</selection>(24, a: 1, b: 2, c: 3, d: 1, e: 2, f: 3, 23)
-----
int bar(args1, i, k = 5, j) {
return args1.c + i + k + j
@@ -4,7 +4,7 @@ def foo(def x) {
}
int i = 5;
<begin>foo<end>(i);
<selection>foo</selection>(i);
i++;
-----
def foo(def x) {
@@ -1,6 +1,6 @@
def getGeneratedFileNames() {
if (true) {
return <begin>QasdWfsdEdfgh.foo().f.test<end>()
return <selection>QasdWfsdEdfgh.foo().f.test</selection>()
}
else 42
}
@@ -1,6 +1,6 @@
def getGeneratedFileNames() {
if (true) {
return <begin>QQQ.test<end>()
return <selection>QQQ.test</selection>()
}
else 42
}
@@ -1,6 +1,6 @@
def getGeneratedFileNames() {
if (true) {
return <begin>new QQQ().test<end>()
return <selection>new QQQ().test</selection>()
}
else 42
}
@@ -1,7 +1,7 @@
def getGeneratedFileNames() {
def qqq = 239
if (true)
return <begin>new QQQ().test<end>()
return <selection>new QQQ().test</selection>()
else 42
}
@@ -2,7 +2,7 @@ def getGeneratedFileNames() {
def qqq = 239
if (true) {
def qqq1 = new QQQ()
return <begin>qqq1.test<end>()
return <selection>qqq1.test</selection>()
}
else 42
}
@@ -1,7 +1,7 @@
protected static def getGeneratedFileNames() {
def foo = 0
while (true) {
foo = <begin>asd<end>()
foo = <selection>asd</selection>()
}
int t = foo
@@ -1,7 +1,7 @@
protected static def getGeneratedFileNames() {
foo = 0
while (true) {
foo = <begin>test<end>()
foo = <selection>test</selection>()
}
int t = foo
}
@@ -1,7 +1,7 @@
protected static def getGeneratedFileNames() {
foo = 0
while (true) {
foo = <begin>test<end>()
foo = <selection>test</selection>()
}
int t = foo
}
@@ -4,7 +4,7 @@ int bar(i = 8, k = i + 1, j = k) {
return i + k + j + q + q + q
}
def t = <begin>bar<end>()
def t = <selection>bar</selection>()
-----
int bar(i = 8, k = i + 1, j = k) {
def q = 6
@@ -4,7 +4,7 @@ int bar(i = 8, k = i + 1, j = k) {
return i + k + j + q + q + q
}
println(<begin>bar<end>())
println(<selection>bar</selection>())
-----
int bar(i = 8, k = i + 1, j = k) {
def q = 6
@@ -1,6 +1,6 @@
def result = 26
int i = <begin>foo<end>(42, 239)
int i = <selection>foo</selection>(42, 239)
def foo(int i, def j) {
if (i > 42) {
@@ -1,6 +1,6 @@
def result = 26
int i = <begin>foo<end>(42, 239)
int i = <selection>foo</selection>(42, 239)
def foo(int i, def j) {
if (i > 42) {
@@ -1,6 +1,6 @@
def result = 26
int i = <begin>foo<end>(42, 239)
int i = <selection>foo</selection>(42, 239)
def foo(int i, def j) {
if (i > 42) {
@@ -8,7 +8,7 @@ class Child {
class User {
void meth() {
<begin>new Child().doSmth<end>()
<selection>new Child().doSmth</selection>()
}
}
-----
@@ -1,7 +1,7 @@
def result = 26
def cl = { int x ->
<begin>foo<end>(x, 239)
<selection>foo</selection>(x, 239)
}
def foo(int i, def j) {
@@ -1,7 +1,7 @@
def tail(int jjj) {
println jjj
println (<begin>fact<end>(jjj))
println (<selection>fact</selection>(jjj))
}
int fact(int n) {
@@ -1,7 +1,7 @@
def tail(int jjj) {
println jjj
<begin>fact<end>(jjj)
<selection>fact</selection>(jjj)
}
int fact(int n) {
@@ -1,7 +1,7 @@
def tail(int jjj) {
println jjj
return <begin>fact<end>(jjj)
return <selection>fact</selection>(jjj)
}
int fact(int n) {
@@ -2,7 +2,7 @@ def tail(int jjj) {
println jjj
if (true) {
return <begin>fact<end>(jjj)
return <selection>fact</selection>(jjj)
}
return 42
}
@@ -2,7 +2,7 @@ def tail(int jjj) {
println jjj
if (true) {
return <begin>fact<end>(jjj)
return <selection>fact</selection>(jjj)
}
else {
return 42
@@ -1,7 +1,7 @@
def tail = { jjj ->
println jjj
return <begin>fact<end>(jjj)
return <selection>fact</selection>(jjj)
}
int fact(int n) {
@@ -1,7 +1,7 @@
class DC {
def r() {
String s1 = ""
return <begin>getBytes<end>(s1)
return <selection>getBytes</selection>(s1)
}
private byte[] getBytes(String s1) {
@@ -1,7 +1,7 @@
class DC {
def r() {
String s1 = ""
<begin>getBytes<end>(s1)
<selection>getBytes</selection>(s1)
}
private byte[] getBytes(String s1) {
@@ -1,4 +1,4 @@
def foo = <begin>edronax<end>(32)
def foo = <selection>edronax</selection>(32)
void edronax(int g) {
if (g > 40) {
@@ -9,7 +9,7 @@ class X {
{
int i = 5;
i++;
print <begin>foo<end>(i);
print <selection>foo</selection>(i);
}
}
-----