test fix
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Wed, 20 Oct 2010 11:08:05 +0000 (15:08 +0400)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Wed, 20 Oct 2010 11:10:40 +0000 (15:10 +0400)
plugins/groovy/resources/standardDsls/defaultArithmeticOperations.gdsl
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java
plugins/groovy/test/org/jetbrains/plugins/groovy/dsl/GroovyTransformationsTest.groovy

index 1f31af2bc145c5e64cdb01350427d8a831ce7350..0d0248ac16f0e52a5a84c06cd22fd64cd9fc8c01 100644 (file)
@@ -20,6 +20,7 @@ package standardDsls
  */
 
 final String NUMBER = "java.lang.Number"
+final String STRING = "java.lang.String"
 contributor(ctype:NUMBER) {
   method name: "plus", type: NUMBER, params:[arg:NUMBER]
   method name: "minus", type: NUMBER, params:[arg:NUMBER]
@@ -34,4 +35,14 @@ contributor(ctype:NUMBER) {
   method name: "previous", type: psiType.canonicalText
   method name: "negative", type: psiType.canonicalText
   method name: "positive", type: psiType.canonicalText
+
+  method name: "plus", type: STRING, params:[arg:STRING]
+  method name: "minus", type: STRING, params:[arg:STRING]
+  method name: "multiply", type: STRING, params:[arg:STRING]
+  method name: "power", type: STRING, params:[arg:STRING]
+  method name: "div", type: STRING, params:[arg:STRING]
+  method name: "mod", type: STRING, params:[arg:STRING]
+  method name: "or", type: STRING, params:[arg:STRING]
+  method name: "and", type: STRING, params:[arg:STRING]
+  method name: "xor", type: STRING, params:[arg:STRING]
 }
index fa3e9b19316607b90575d3f8c4d2aa8bb62154e5..e4c0aa9a54313d5caeb966882d5fcc99b04628cb 100644 (file)
@@ -76,17 +76,7 @@ public class TypesUtil {
       return JavaPsiFacade.getInstance(binaryExpression.getProject()).getElementFactory().createTypeByFQClassName(qName, scope);
     }
 
-    final PsiType type = getOverloadedOperatorType(lType, binaryExpression.getOperationTokenType(), binaryExpression, new PsiType[]{rType});
-    if (type != null) {
-      return type;
-    }
-
-    if (typeEqualsToText(rType, GrStringUtil.GROOVY_LANG_GSTRING)) {
-      PsiType gstringType = JavaPsiFacade.getInstance(binaryExpression.getProject()).getElementFactory()
-        .createTypeByFQClassName(GrStringUtil.GROOVY_LANG_GSTRING, binaryExpression.getResolveScope());
-      return getOverloadedOperatorType(lType, binaryExpression.getOperationTokenType(), binaryExpression, new PsiType[]{gstringType});
-    }
-    return null;
+    return getOverloadedOperatorType(lType, binaryExpression.getOperationTokenType(), binaryExpression, new PsiType[]{rType});
   }
 
   @Nullable
index cbe09540691bb905377de968f06950ef42fc2197..5218ac2d2e13e51cd8caf7894861aca57f0d89a8 100644 (file)
@@ -48,7 +48,7 @@ class GroovyTransformationsTest extends LightCodeInsightFixtureTestCase {
 
   public void testVetoableTransform() throws Throwable { doPlainTest() }
 
-  public void testNewifyTransform1() throws Throwable { doVariantsTest('newInstance', 'new', 'new',
+  public void testNewifyTransform1() throws Throwable { doVariantsTest('negative', 'newInstance', 'new', 'new',
                                                                        'newInstance', 'newInstance0', 'newInstanceCallerCache', 'next') }
 
   public void testNewifyTransform2() throws Throwable { doVariantsTest('Leaf', 'Leaf', 'Leaf') }