public void visitBinaryExpression(BinaryExpression expression) {
    if (expression.getOperation().getType() == Types.LEFT_SQUARE_BRACKET
        && expression.getRightExpression() instanceof MapEntryExpression) {
      addError(
          "You tried to use a map entry for an index operation, this is not allowed. "
              + "Maybe something should be set in parentheses or a comma is missing?",
          expression.getRightExpression());
    }
    super.visitBinaryExpression(expression);

    switch (expression.getOperation().getType()) {
      case Types.EQUAL: // = assignment
      case Types.BITWISE_AND_EQUAL:
      case Types.BITWISE_OR_EQUAL:
      case Types.BITWISE_XOR_EQUAL:
      case Types.PLUS_EQUAL:
      case Types.MINUS_EQUAL:
      case Types.MULTIPLY_EQUAL:
      case Types.DIVIDE_EQUAL:
      case Types.INTDIV_EQUAL:
      case Types.MOD_EQUAL:
      case Types.POWER_EQUAL:
      case Types.LEFT_SHIFT_EQUAL:
      case Types.RIGHT_SHIFT_EQUAL:
      case Types.RIGHT_SHIFT_UNSIGNED_EQUAL:
        checkFinalFieldAccess(expression.getLeftExpression());
        break;
      default:
        break;
    }
  }
 public void visitField(FieldNode node) {
   if (currentClass.getDeclaredField(node.getName()) != node) {
     addError("The " + getDescription(node) + " is declared multiple times.", node);
   }
   checkInterfaceFieldModifiers(node);
   checkGenericsUsage(node, node.getType());
   super.visitField(node);
 }
 public void visitMethod(MethodNode node) {
   inConstructor = false;
   inStaticConstructor = node.isStaticConstructor();
   checkAbstractDeclaration(node);
   checkRepetitiveMethod(node);
   checkOverloadingPrivateAndPublic(node);
   checkMethodModifiers(node);
   checkGenericsUsage(node, node.getParameters());
   checkGenericsUsage(node, node.getReturnType());
   super.visitMethod(node);
 }
 public void visitMethodCallExpression(MethodCallExpression mce) {
   super.visitMethodCallExpression(mce);
   Expression aexp = mce.getArguments();
   if (aexp instanceof TupleExpression) {
     TupleExpression arguments = (TupleExpression) aexp;
     for (Expression e : arguments.getExpressions()) {
       checkForInvalidDeclaration(e);
     }
   } else {
     checkForInvalidDeclaration(aexp);
   }
 }
 @Override
 public void visitDeclarationExpression(DeclarationExpression expression) {
   super.visitDeclarationExpression(expression);
   if (expression.isMultipleAssignmentDeclaration()) return;
   checkInvalidDeclarationModifier(expression, ACC_ABSTRACT, "abstract");
   checkInvalidDeclarationModifier(expression, ACC_NATIVE, "native");
   checkInvalidDeclarationModifier(expression, ACC_PRIVATE, "private");
   checkInvalidDeclarationModifier(expression, ACC_PROTECTED, "protected");
   checkInvalidDeclarationModifier(expression, ACC_PUBLIC, "public");
   checkInvalidDeclarationModifier(expression, ACC_STATIC, "static");
   checkInvalidDeclarationModifier(expression, ACC_STRICT, "strictfp");
   checkInvalidDeclarationModifier(expression, ACC_SYNCHRONIZED, "synchronized");
   checkInvalidDeclarationModifier(expression, ACC_TRANSIENT, "transient");
   checkInvalidDeclarationModifier(expression, ACC_VOLATILE, "volatile");
 }
 public void visitClass(ClassNode node) {
   ClassNode oldClass = currentClass;
   currentClass = node;
   checkImplementsAndExtends(node);
   if (source != null && !source.getErrorCollector().hasErrors()) {
     checkClassForIncorrectModifiers(node);
     checkInterfaceMethodVisibility(node);
     checkClassForOverwritingFinal(node);
     checkMethodsForIncorrectModifiers(node);
     checkMethodsForWeakerAccess(node);
     checkMethodsForOverridingFinal(node);
     checkNoAbstractMethodsNonabstractClass(node);
     checkGenericsUsage(node, node.getUnresolvedInterfaces());
     checkGenericsUsage(node, node.getUnresolvedSuperClass());
   }
   super.visitClass(node);
   currentClass = oldClass;
 }
 public void visitGStringExpression(GStringExpression expression) {
   super.visitGStringExpression(expression);
   for (ConstantExpression ce : expression.getStrings()) {
     checkStringExceedingMaximumLength(ce);
   }
 }
 public void visitConstantExpression(ConstantExpression expression) {
   super.visitConstantExpression(expression);
   checkStringExceedingMaximumLength(expression);
 }
 public void visitCatchStatement(CatchStatement cs) {
   if (!(cs.getExceptionType().isDerivedFrom(ClassHelper.make(Throwable.class)))) {
     addError("Catch statement parameter type is not a subclass of Throwable.", cs);
   }
   super.visitCatchStatement(cs);
 }
 public void visitConstructor(ConstructorNode node) {
   inConstructor = true;
   inStaticConstructor = node.isStaticConstructor();
   checkGenericsUsage(node, node.getParameters());
   super.visitConstructor(node);
 }
 public void visitProperty(PropertyNode node) {
   checkDuplicateProperties(node);
   checkGenericsUsage(node, node.getType());
   super.visitProperty(node);
 }