IDEA-66809 Inline method changes map key semantics

This commit is contained in:
Maxim Medvedev
2011-03-28 18:06:26 +04:00
parent 732a71fcd9
commit 9c350f87da
3 changed files with 18 additions and 1 deletions
@@ -43,6 +43,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
@@ -83,7 +84,9 @@ public class PsiImplUtil {
}
// Remove unnecessary parentheses
if (removeUnnecessaryParentheses && oldParent instanceof GrParenthesizedExpression) {
if (removeUnnecessaryParentheses &&
oldParent instanceof GrParenthesizedExpression &&
!(oldParent.getParent() instanceof GrArgumentLabel)) {
return ((GrExpression)oldParent).replaceWithExpression(newExpr, removeUnnecessaryParentheses);
}
@@ -96,6 +96,7 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
public void testFieldAsParameter() throws Throwable { doTest(); }
public void testWritableVariable() throws Throwable { doTest(); }
public void testSingleExpression() {doTest();}
public void testNamedArg() {doTest();}
public void _testInlineInGString() throws Throwable {doTest(); }
public void testInlineAll() throws Throwable {
@@ -0,0 +1,13 @@
def foo(name) {
[(name):2]
}
def bar = 3+4
def x = <selection>foo</selection>(bar)
-----
def foo(name) {
[(name):2]
}
def bar = 3+4
def x = [(bar):2]