private void changeBaseScriptTypeFromDeclaration(
      final DeclarationExpression de, final AnnotationNode node) {
    if (de.isMultipleAssignmentDeclaration()) {
      addError(
          "Annotation " + MY_TYPE_NAME + " not supported with multiple assignment notation.", de);
      return;
    }

    if (!(de.getRightExpression() instanceof EmptyExpression)) {
      addError("Annotation " + MY_TYPE_NAME + " not supported with variable assignment.", de);
      return;
    }
    Expression value = node.getMember("value");
    if (value != null) {
      addError(
          "Annotation " + MY_TYPE_NAME + " cannot have member 'value' if used on a declaration.",
          value);
      return;
    }

    ClassNode cNode = de.getDeclaringClass();
    ClassNode baseScriptType = de.getVariableExpression().getType().getPlainNodeReference();
    de.setRightExpression(new VariableExpression("this"));

    changeBaseScriptType(de, cNode, baseScriptType);
  }
  public void visitDeclarationExpression(DeclarationExpression expression) {
    // visit right side first to avoid the usage of a
    // variable before its declaration
    expression.getRightExpression().visit(this);

    if (expression.isMultipleAssignmentDeclaration()) {
      TupleExpression list = expression.getTupleExpression();
      for (Expression e : list.getExpressions()) {
        declare((VariableExpression) e);
      }
    } else {
      declare(expression.getVariableExpression());
    }
  }
 @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");
 }
  private void setScriptURIOnDeclaration(
      final DeclarationExpression de, final AnnotationNode node) {
    if (de.isMultipleAssignmentDeclaration()) {
      addError(
          "Annotation " + MY_TYPE_NAME + " not supported with multiple assignment notation.", de);
      return;
    }

    if (!(de.getRightExpression() instanceof EmptyExpression)) {
      addError("Annotation " + MY_TYPE_NAME + " not supported with variable assignment.", de);
      return;
    }

    URI uri = getSourceURI(node);

    if (uri == null) {
      addError("Unable to get the URI for the source of this script!", de);
    } else {
      // Set the RHS to '= URI.create("string for this URI")'.
      // That may throw an IllegalArgumentExpression wrapping the URISyntaxException.
      de.setRightExpression(getExpression(uri));
    }
  }