boolean (PsiMethod method, GrExpression operand, GrUnaryExpression unary) { if (!(operand instanceof GrReferenceExpression)) return false; final GrExpression qualifier = ((GrReferenceExpression)operand).getQualifier(); final GroovyReference rValueReference = ((GrReferenceExpression)operand).getRValueReference(); final GroovyResolveResult resolveResult = rValueReference == null ? EmptyGroovyResolveResult.INSTANCE : rValueReference.advancedResolve(); final PsiElement resolved = resolveResult.getElement(); if (resolved instanceof PsiMethod getter && GroovyPropertyUtils.isSimplePropertyGetter((PsiMethod)resolved)) { final String propertyName = GroovyPropertyUtils.getPropertyNameByGetter(getter); final PsiType type; if (qualifier == null) { type = null; } else { type = qualifier.getType(); if (type == null) return false; } final PsiMethod setter = GroovyPropertyUtils.findPropertySetter(type, propertyName, unary); if (setter == null) return false; final ExpressionGenerator generator = new ExpressionGenerator(new StringBuilder(), context); if (shouldNotReplaceOperatorWithMethod(operand.getType(), null, unary.getOperationTokenType())) { writeSimpleUnary(operand, unary, generator); } else { generator.invokeMethodOn( method, operand, GrExpression.EMPTY_ARRAY, GrNamedArgument.EMPTY_ARRAY, GrClosableBlock.EMPTY_ARRAY, resolveResult.getSubstitutor(), unary ); } final GrExpression fromText = factory.createExpressionFromText(generator.toString(), unary); invokeMethodOn( setter, qualifier, new GrExpression[]{fromText}, GrNamedArgument.EMPTY_ARRAY, GrClosableBlock.EMPTY_ARRAY, resolveResult.getSubstitutor(), unary ); } else if (resolved instanceof PsiVariable) { boolean wrap = context.analyzedVars.toWrap((PsiVariable)resolved); boolean doNeedExpression = PsiUtil.isExpressionUsed(unary); StringBuilder curBuilder; ExpressionGenerator curGenerator; if (doNeedExpression && wrap) { curBuilder = new StringBuilder(); curGenerator = new ExpressionGenerator(curBuilder, context); } else { curBuilder = builder; curGenerator = this; } if (shouldNotReplaceOperatorWithMethod(operand.getType(), null, unary.getOperationTokenType())) { if (wrap) { operand.accept(curGenerator); curBuilder.append(".set("); ((GrExpression)operand.copy()).accept(curGenerator); curBuilder.append(" + 1"); } else { writeSimpleUnary((GrExpression)operand.copy(), unary, curGenerator); } } else { operand.accept(curGenerator); curBuilder.append(wrap ? ".set(" : " = "); curGenerator.invokeMethodOn( method, (GrExpression)operand.copy(), GrExpression.EMPTY_ARRAY, GrNamedArgument.EMPTY_ARRAY, GrClosableBlock.EMPTY_ARRAY, resolveResult.getSubstitutor(), unary ); } if (wrap) { curBuilder.append(')'); if (doNeedExpression) { curBuilder.append(';'); context.myStatements.add(curBuilder.toString()); operand.accept(this); builder.append(".get()"); } } } return true; }