private void checkSetterNeeded(final PsiExpression operand, final PsiJavaToken sign) {
   final IElementType tokenType = sign.getTokenType();
   if (!tokenType.equals(JavaTokenType.PLUSPLUS)
       && !tokenType.equals(JavaTokenType.MINUSMINUS)) {
     return;
   }
   if (isProhibitedReference(operand)) {
     final PsiField field = getReferencedField(operand);
     if (!hasSetter(field) && !isStaticFinal(field)) {
       fieldsNeedingSetter.add(field);
     }
   }
 }
Example #2
0
 @Nullable
 public static PsiExpression findExpressionInRange(PsiFile file, int startOffset, int endOffset) {
   if (!file.getViewProvider().getLanguages().contains(StdLanguages.JAVA)) return null;
   PsiExpression expression =
       findElementInRange(file, startOffset, endOffset, PsiExpression.class);
   if (expression == null && findStatementsInRange(file, startOffset, endOffset).length == 0) {
     PsiElement element2 = file.getViewProvider().findElementAt(endOffset - 1, StdLanguages.JAVA);
     if (element2 instanceof PsiJavaToken) {
       final PsiJavaToken token = (PsiJavaToken) element2;
       final IElementType tokenType = token.getTokenType();
       if (tokenType.equals(JavaTokenType.SEMICOLON)) {
         expression =
             findElementInRange(
                 file, startOffset, element2.getTextRange().getStartOffset(), PsiExpression.class);
       }
     }
   }
   if (expression == null && findStatementsInRange(file, startOffset, endOffset).length == 0) {
     PsiElement element =
         PsiTreeUtil.skipSiblingsBackward(file.findElementAt(endOffset), PsiWhiteSpace.class);
     if (element != null) {
       element =
           PsiTreeUtil.skipSiblingsBackward(
               element.getLastChild(), PsiWhiteSpace.class, PsiComment.class);
       if (element != null) {
         final int newEndOffset = element.getTextRange().getEndOffset();
         if (newEndOffset < endOffset) {
           expression = findExpressionInRange(file, startOffset, newEndOffset);
         }
       }
     }
   }
   if (expression instanceof PsiReferenceExpression
       && expression.getParent() instanceof PsiMethodCallExpression) return null;
   return expression;
 }