This commit is contained in:
Maxim Medvedev
2010-10-20 15:10:40 +04:00
parent f4ec594a69
commit 27d067cfb3
3 changed files with 13 additions and 12 deletions
@@ -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]
}
@@ -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
@@ -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') }