/**
   * @param scalar
   * @return true if the scalar is defines as $GLOBALS call
   */
  private static boolean checkGLOBALS(Scalar scalar) {
    final String stringValue = scalar.getStringValue();
    if (scalar.getScalarType() != Scalar.TYPE_STRING || stringValue.length() < 3) {
      return false;
    }
    final char charAtZero = stringValue.charAt(0);
    final char charAtEnd = stringValue.charAt(stringValue.length() - 1);

    if (!detectString(charAtZero) || !detectString(charAtEnd)) {
      return false;
    }

    if (scalar.getParent().getType() == ASTNode.ARRAY_ACCESS) {
      ArrayAccess arrayAccess = (ArrayAccess) scalar.getParent();
      final Expression variableName = arrayAccess.getName();
      if (variableName.getType() == ASTNode.VARIABLE) {
        Variable var = (Variable) variableName;
        if (var.isDollared() && var.getName() instanceof Identifier) {
          final Identifier id = (Identifier) var.getName();
          return id.getName().equals("_GLOBALS") // $NON-NLS-1$
              || id.getName().equals("GLOBALS"); // $NON-NLS-1$
        }
      }
    }
    return false;
  }
    public boolean apply(ASTNode node) {
      // stops when found - that's the reason to use ApplyAll
      if (exists) return false;

      if (node.getType() == ASTNode.SCALAR) {
        final Scalar scalar = (Scalar) node;

        final String stringValue = scalar.getStringValue();
        if (scalar.getScalarType() != Scalar.TYPE_STRING || stringValue == null) {
          return false;
        }

        final int length = stringValue.length() - 1;
        if (stringValue.charAt(0) != '"'
            && stringValue.charAt(length) != '"'
            && stringValue.equals(name)) {
          exists = true;
        }
      } else if (node.getType() == ASTNode.FUNCTION_INVOCATION) {
        FunctionInvocation functionInvocation = (FunctionInvocation) node;
        final Expression functionName = functionInvocation.getFunctionName().getName();
        if (!(functionName instanceof Identifier)) {
          return false;
        }

        final Identifier identifier = (Identifier) functionName;
        final List<Expression> parameters = functionInvocation.parameters();
        if (!"define".equalsIgnoreCase(identifier.getName())
            || parameters == null
            || parameters.size() == 0) { // $NON-NLS-1$
          return false;
        }

        final Expression expression = parameters.get(0);
        if (expression.getType() != ASTNode.SCALAR) {
          return false;
        }

        Scalar scalar = (Scalar) expression;
        final String stringValue = scalar.getStringValue();
        if (stringValue.length() < 2 || stringValue.charAt(0) != '"') {
          return false;
        }
        exists = name.equals(stringValue.substring(1, stringValue.length() - 1));
      }
      return true;
    }