resolve unary +, -, ~, !

This commit is contained in:
Maxim Medvedev
2011-04-16 19:25:59 +04:00
parent 8bcadd36fb
commit 19d921dc29
2 changed files with 16 additions and 3 deletions
@@ -92,6 +92,13 @@ public class TypesUtil {
return ResolveUtil.getMethodCandidates(thisType, ourOperationsToOperatorNames.get(tokenType), place, argumentTypes);
}
public static GroovyResolveResult[] getOverloadedUnaryOperatorCandidates(@NotNull PsiType thisType,
IElementType tokenType,
@NotNull GroovyPsiElement place,
PsiType[] argumentTypes) {
return ResolveUtil.getMethodCandidates(thisType, ourUnaryOperationsToOperatorNames.get(tokenType), place, argumentTypes);
}
private static final Map<IElementType, String> ourPrimitiveTypesToClassNames = new HashMap<IElementType, String>();
private static final String NULL = "null";
@@ -111,6 +118,7 @@ public class TypesUtil {
}
private static final Map<IElementType, String> ourOperationsToOperatorNames = new HashMap<IElementType, String>();
private static final Map<IElementType, String> ourUnaryOperationsToOperatorNames = new HashMap<IElementType, String>();
static {
ourOperationsToOperatorNames.put(mPLUS, "plus");
@@ -121,14 +129,19 @@ public class TypesUtil {
ourOperationsToOperatorNames.put(mDIV, "div");
ourOperationsToOperatorNames.put(mMOD, "mod");
ourOperationsToOperatorNames.put(mSTAR, "multiply");
ourOperationsToOperatorNames.put(mDEC, "previous");
ourOperationsToOperatorNames.put(mINC, "next");
ourOperationsToOperatorNames.put(kAS, "asType");
ourOperationsToOperatorNames.put(mCOMPARE_TO, "compareTo");
ourOperationsToOperatorNames.put(mGT, "compareTo");
ourOperationsToOperatorNames.put(mGE, "compareTo");
ourOperationsToOperatorNames.put(mLT, "compareTo");
ourOperationsToOperatorNames.put(mLE, "compareTo");
ourUnaryOperationsToOperatorNames.put(mLNOT, "asBoolean");
ourUnaryOperationsToOperatorNames.put(mPLUS, "positive");
ourUnaryOperationsToOperatorNames.put(mMINUS, "negative");
ourUnaryOperationsToOperatorNames.put(mDEC, "previous");
ourUnaryOperationsToOperatorNames.put(mINC, "next");
ourUnaryOperationsToOperatorNames.put(mBNOT, "bitwiseNegate");
}
private static final TObjectIntHashMap<String> TYPE_TO_RANK = new TObjectIntHashMap<String>();
@@ -79,7 +79,7 @@ public class GrUnaryExpressionImpl extends GrExpressionImpl implements GrUnaryEx
final PsiType type = operand.getType();
if (type == null) return GroovyResolveResult.EMPTY_ARRAY;
return TypesUtil.getOverloadedOperatorCandidates(type, unary.getOperationTokenType(), unary, PsiType.EMPTY_ARRAY);
return TypesUtil.getOverloadedUnaryOperatorCandidates(type, unary.getOperationTokenType(), unary, PsiType.EMPTY_ARRAY);
}
};