diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index a9a268b73dc5..69901b6cdf05 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -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 ourPrimitiveTypesToClassNames = new HashMap(); private static final String NULL = "null"; @@ -111,6 +118,7 @@ public class TypesUtil { } private static final Map ourOperationsToOperatorNames = new HashMap(); + private static final Map ourUnaryOperationsToOperatorNames = new HashMap(); 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 TYPE_TO_RANK = new TObjectIntHashMap(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java index 35edaf526047..3d8d97747644 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java @@ -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); } };