Returns true if the ASTNode is a declaration of a closure, either as a declaration
or a field.
@param expression
the target expression
@return
as described
352642
public static boolean isClosureDeclaration(ASTNode expression) {
        if (expression instanceof DeclarationExpression) {
            if (((DeclarationExpression) expression).getRightExpression() instanceof ClosureExpression) {
                return true;
            }
        }
        if (expression instanceof FieldNode) {
            ClassNode type = ((FieldNode) expression).getType();
            if (AstUtil.classNodeImplementsType(type, Closure.class)) {
                return true;
            } else if (((FieldNode) expression).getInitialValueExpression() instanceof ClosureExpression) {
                return true;
            }
        }
        return false;
    }
548013
public static boolean isConstructorCall(Expression expression, List<String> classNames) {
        return expression instanceof ConstructorCallExpression && classNames.contains(expression.getType().getName());
    }
91859
function (node) {
            if (node.type !== "VariableDeclaration") {
                return false;
            }
            // 
            var firstDeclaration = node.declarations[0];
            if(firstDeclaration.init == null) {
                return false;
            }
            if (firstDeclaration.init.type === "CallExpression" &&
                firstDeclaration.init.callee.name === "require") {
                return true;
            }
            // .add
            if (firstDeclaration.init.type === "MemberExpression" &&
                firstDeclaration.init.object.type === "CallExpression" &&
                firstDeclaration.init.object.callee.name === "require") {
                return true;
            }
        }
457672
public static boolean isBinaryExpressionType(Expression expression, List<String> tokens) {
        if (expression instanceof BinaryExpression) {
            if (tokens.contains(((BinaryExpression) expression).getOperation().getText())) {
                return true;
            }
        }
        return false;
    }
1235774
private ClassNode checkForTargetType(final Expression expr, final ClassNode type) {
        BinaryExpression enclosingBinaryExpression = typeCheckingContext.getEnclosingBinaryExpression();
        if (enclosingBinaryExpression instanceof DeclarationExpression
                && isEmptyCollection(expr) && isAssignment(enclosingBinaryExpression.getOperation().getType())) {
            VariableExpression target = (VariableExpression) enclosingBinaryExpression.getLeftExpression();
            return adjustForTargetType(target.getType(), type);
        }
        if (currentField != null) {
            return adjustForTargetType(currentField.getType(), type);
        }
        if (currentProperty != null) {
            return adjustForTargetType(currentProperty.getType(), type);
        }
        MethodNode enclosingMethod = typeCheckingContext.getEnclosingMethod();
        if (enclosingMethod != null) {
            return adjustForTargetType(enclosingMethod.getReturnType(), type);
        }
        return type;
    }
1304175
public static boolean isValidationMatcherExpression(String expression) {
        return expression.startsWith(Citrus.VALIDATION_MATCHER_PREFIX) &&
                expression.endsWith(Citrus.VALIDATION_MATCHER_SUFFIX);
    }
425175
function toExpression(node) {
  if (t.isExpressionStatement(node)) {
    node = node.expression;
  }

  if (t.isClass(node)) {
    node.type = "ClassExpression";
  } else if (t.isFunction(node)) {
    node.type = "FunctionExpression";
  }

  if (t.isExpression(node)) {
    return node;
  } else {
    throw new Error("cannot turn " + node.type + " to an expression");
  }
}
411585
private boolean validOperationExpression(Node expr) {
    String name = getCallName(expr);
    Keywords keyword = nameToKeyword(name);
    switch (keyword) {
      case COND:
        return validConditionalExpression(expr);
      case MAPUNION:
        return validMapunionExpression(expr);
      case MAPRECORD:
        return validMaprecordExpression(expr);
      case TYPEOFVAR:
        return validTypeOfVarExpression(expr);
      case INSTANCEOF:
        return validInstanceOfExpression(expr);
      case PRINTTYPE:
        return validPrintTypeExpression(expr);
      case PROPTYPE:
        return validPropTypeExpression(expr);
      default:
        throw new IllegalStateException("Invalid type transformation operation");
    }
  }
1118940
function isVariableDeclarator(expression) {
    var id;

    id = expression.id;
    return expression.type === 'VariableDeclarator' && id && id.type === 'Identifier';
}
819529
private boolean markAsDeadCode(XExpression expression) {
		if (expression instanceof XBlockExpression) {
			final XBlockExpression block = (XBlockExpression) expression;
			final EList<XExpression> expressions = block.getExpressions();
			if (!expressions.isEmpty()) {
				markAsDeadCode(expressions.get(0));
				return true;
			}
		}
		if (expression != null) {
			error("Unreachable expression.", expression, null, IssueCodes.UNREACHABLE_CODE); //$NON-NLS-1$
			return true;
		}
		return false;
	}
776359
public Node getNode(String expression) {
		return (Node) evalXPath(expression, null, XPathConstants.NODE);
	}
40429
@Nullable
  public static JSTypeExpression getDeclaredTypeExpression(Node declaration) {
    checkArgument(declaration.isName() || declaration.isStringKey());
    JSDocInfo nameJsdoc = getBestJSDocInfo(declaration);
    if (nameJsdoc != null) {
      return nameJsdoc.getType();
    }
    Node parent = declaration.getParent();
    if (parent.isRest() || parent.isDefaultValue()) {
      parent = parent.getParent();
    }
    if (parent.isParamList()) {
      JSDocInfo functionJsdoc = getBestJSDocInfo(parent.getParent());
      if (functionJsdoc != null) {
        return functionJsdoc.getParameterType(declaration.getString());
      }
    }
    return null;
  }
760120
function isDefineStatement(expression) {

    var callee, type;

    type = expression.type;
    callee = expression.callee;

    return type === "CallExpression" && callee && callee.type === 'Identifier' && callee.name === "define";
}
102782
function isCallbackExpression(node, parentNode) {

            // ensure the parent node exists and is an expression
            if (!parentNode || parentNode.type !== "ExpressionStatement") {
                return false;
            }

            // cb()
            if (parentNode.expression === node) {
                return true;
            }

            // special case for cb && cb() and similar
            if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") {
                if (parentNode.expression.right === node) {
                    return true;
                }
            }

            return false;
        }
537695
public static boolean isWellFormed(Expression2 expression) {
    for (int i = 0; i < expression.size; i++) {
      Expression2 subexpression = expression.getSubexpression(i);
      if (subexpression.isConstant() && subexpression.getConstant().equals(LAMBDA)) {
        // lambdas must appear as the first argument of a nested expression.
        int parentIndex = expression.getParentExpressionIndex(i);
        if (parentIndex == -1) {
          return false;
        }

        Expression2 lambdaExpression = expression.getSubexpression(parentIndex);
        List<Expression2> children = lambdaExpression.getSubexpressions();

        // Parent expression must have 3 subexpressions: lambda, argument list, body
        if (children.size() != 3) {
          return false;
        }
        if (children.get(0) != subexpression) {
          return false;
        }

        // Argument list must be an application expression containing only constants
        Expression2 argListExpr = children.get(1);
        if (argListExpr.isConstant()) {
          return false;
        }
        List<Expression2> arguments = argListExpr.getSubexpressions(); 
        for (int j = 0; j < arguments.size(); j++) {
          if (!arguments.get(j).isConstant()) {
            return false;
          }
        }
      }
    }
    return true;
  }
393939
public boolean isLvalue() {
    Node parent = getParent();
    Token parentType = parent.getToken();
    switch (parentType) {
      case VAR:
      case LET:
      case CONST:
        return (nameNode.hasChildren() || isLhsOfEnhancedForExpression(nameNode));
      case DEFAULT_VALUE:
        return parent.getFirstChild() == nameNode;
      case INC:
      case DEC:
      case CATCH:
      case REST:
      case PARAM_LIST:
        return true;
      case FOR:
      case FOR_IN:
      case FOR_OF:
      case FOR_AWAIT_OF:
        return NodeUtil.isEnhancedFor(parent) && parent.getFirstChild() == nameNode;
      case ARRAY_PATTERN:
      case STRING_KEY:
      case COMPUTED_PROP:
        return NodeUtil.isLhsByDestructuring(nameNode);
      default:
        return (NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == nameNode);
    }
  }
109103
public static boolean isVariableName(final String expression) {
        if (expression == null || expression.length() == 0) {
            return false;
        }

        if (expression.startsWith(Citrus.VARIABLE_PREFIX) && expression.endsWith(Citrus.VARIABLE_SUFFIX)) {
            return true;
        }

        return false;
    }