mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
convert reference expressions with member pointer
This commit is contained in:
+3
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.util;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
@@ -32,6 +34,7 @@ public final class GroovyCommonClassNames {
|
||||
public static final String JAVA_UTIL_REGEX_PATTERN = "java.util.regex.Pattern";
|
||||
public static final String JAVA_MATH_BIG_DECIMAL = "java.math.BigDecimal";
|
||||
public static final String JAVA_MATH_BIG_INTEGER = "java.math.BigInteger";
|
||||
@NonNls public static final String ORG_CODEHAUS_GROOVY_RUNTIME_METHOD_CLOSURE = "org.codehaus.groovy.runtime.MethodClosure";
|
||||
|
||||
private GroovyCommonClassNames() {
|
||||
}
|
||||
|
||||
+8
@@ -486,6 +486,14 @@ public class ExpressionGenerator extends Generator {
|
||||
|
||||
GrExpression qualifierToUse = qualifier;
|
||||
|
||||
if (type == GroovyTokenTypes.mMEMBER_POINTER) {
|
||||
LOG.assertTrue(qualifier != null);
|
||||
builder.append("new ").append(GroovyCommonClassNames.ORG_CODEHAUS_GROOVY_RUNTIME_METHOD_CLOSURE).append("(");
|
||||
qualifier.accept(this);
|
||||
builder.append(", ").append(referenceExpression.getReferenceName()).append(')');
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == GroovyTokenTypes.mOPTIONAL_DOT) {
|
||||
LOG.assertTrue(qualifier != null);
|
||||
|
||||
|
||||
+3
-1
@@ -60,7 +60,7 @@ public class CodeBlockGenerationTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
final String testName = getTestName(false)
|
||||
final String testName = getTestName(true)
|
||||
final PsiFile file = myFixture.configureByFile(testName + ".groovy");
|
||||
assertInstanceOf file, GroovyFile
|
||||
|
||||
@@ -104,4 +104,6 @@ class MyCat {
|
||||
|
||||
doTest()
|
||||
}
|
||||
|
||||
void testMemberPointer() {doTest()}
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def a = new ArrayList<String>().&add
|
||||
a("2")
|
||||
Reference in New Issue
Block a user