Return the node that represents the expression returned
by the method, given a FUNCTION node.
340949
private static Node returnedExpression(Node fn) {
    Node expectedBlock = NodeUtil.getFunctionBody(fn);
    if (!expectedBlock.hasOneChild()) {
      return null;
    }

    Node expectedReturn = expectedBlock.getFirstChild();
    if (!expectedReturn.isReturn()) {
      return null;
    }

    if (!expectedReturn.hasOneChild()) {
      return null;
    }

    return expectedReturn.getOnlyChild();
  }
962114
function isCallWithFunctionExpression(node) {
  const callObj = isMemberExpression(node.callee) ? node.callee.object : node;
  const firstArg = callObj.arguments ? callObj.arguments[0] : null;
  return callObj !== undefined && isCallExpression(callObj) &&
    firstArg && isFunctionExpression(firstArg);
}
259578
function(node, method) {
            node = Y.Dom.get(node);
            if (!node) {
                YAHOO.log('getFirstChild failed: invalid node argument', 'error', 'Dom');
                return null;
            }
            return Y.Dom.getFirstChildBy(node);
        }
41275
function(type, node) {
    return seen.indexOf(node) == -1 && ((type == 'AssignmentExpression' && node.right == expr) || (type == 'VariableDeclarator' && node.init == expr));
  }
195219
function getRegExp(node) {

        if (node.value instanceof RegExp) {
            return node.value;
        } else if (typeof node.value === "string") {

            var parent = context.getAncestors().pop();
            if ((parent.type === "NewExpression" || parent.type === "CallExpression") &&
            parent.callee.type === "Identifier" && parent.callee.name === "RegExp") {

                // there could be an invalid regular expression string
                try {
                    return new RegExp(node.value);
                } catch (ex) {
                    return null;
                }

            }
        } else {
            return null;
        }

    }
1160919
def wrap_as_node(self, func):
        ''
        name = self.get_name(func)

        @wraps(func)
        def wrapped(*args, **kwargs):
            'wrapped version of func'
            message = self.get_message_from_call(*args, **kwargs)
            self.logger.info('calling "%s" with %r', name, message)
            result = func(message)

            # functions can return multiple values ("emit" multiple times)
            # by yielding instead of returning. Handle this case by making
            # a list of the results and processing them all after the
            # generator successfully exits. If we were to process them as
            # they came out of the generator, we might get a partially
            # processed input sent down the graph. This may be possible in
            # the future via a flag.
            if isinstance(result, GeneratorType):
                results = [
                    self.wrap_result(name, item)
                    for item in result
                    if item is not NoResult
                ]
                self.logger.debug(
                    '%s returned generator yielding %d items', func, len(results)
                )

                [self.route(name, item) for item in results]
                return tuple(results)

            # the case of a direct return is simpler. wrap, route, and
            # return the value.
            else:
                if result is NoResult:
                    return result

                result = self.wrap_result(name, result)
                self.logger.debug(
                    '%s returned single value %s', func, result
                )
                self.route(name, result)
                return result

        return wrapped
808144
public Node getNode(Object node, String expression) {
		return (Node) evalXPath(expression, node, XPathConstants.NODE);
	}
1256306
function getEncloseFunctionDeclaration(reference) {
    let node = reference.identifier;

    while (node) {
        if (node.type === "FunctionDeclaration") {
            return node.id ? node : null;
        }

        node = node.parent;
    }

    return null;
}
475545
function getMethodReturnDoc(methodPath) {
  const functionExpression = methodPath.get('value');

  if (functionExpression.node.returnType) {
    const returnType = getTypeAnnotation(functionExpression.get('returnType'));
    if (returnType && t.Flow.check(returnType.node)) {
      return { type: getFlowType(returnType) };
    } else if (returnType) {
      return { type: getTSType(returnType) };
    }
  }

  return null;
}
658099
Node createThisForFunction(Node functionNode) {
    final Node result = IR.thisNode();
    if (isAddingTypes()) {
      result.setJSType(getTypeOfThisForFunctionNode(functionNode));
    }
    return result;
  }
1093638
function isArgumentToFunctionCall (node) {
        return isCallExpression(node.parent()) &&
          node.parent().arguments.length &&
          node.parent().arguments.indexOf(node) !== -1
      }
1265081
function getFunctionCallType (func) {
  if (!(isExternalDirectCall(func) || isThisLocalCall(func) || isSuperLocalCall(func) || isLocalCall(func) || isLibraryCall(func))) throw new Error('staticAnalysisCommon.js: not function call Node')
  if (isExternalDirectCall(func) || isThisLocalCall(func) || isSuperLocalCall(func) || isLibraryCall(func)) return func.attributes.type
  return findFirstSubNodeLTR(func, exactMatch(nodeTypes.IDENTIFIER)).attributes.type
}
520027
def visit(self, node: AST, dfltChaining: bool = True) -> str:
        """"""
        # print(node.__class__.__name__)
        if node is None:
            return ''
        if isinstance(node, ast.Expression):
            return self.visit(node.body)
        # dispatch to specific or generic method
        method = 'visit_' + node.__class__.__name__
        visitor = getattr(self, method, self.generic_visit)
        return visitor(node, dfltChaining)
449961
public static Node getFunctionBody(Node fn) {
    checkArgument(fn.isFunction(), fn);
    return fn.getLastChild();
  }
1088100
function CallExpression(node) {
    if (t.isFunction(node.callee) || isHelper(node)) {
      return {
        before: true,
        after: true
      };
    }
  }
340452
static Node getArgumentForFunction(Node function, int index) {
    checkState(function.isFunction());
    return getNthSibling(
        function.getSecondChild().getFirstChild(), index);
  }
158014
def visit_FunctionDeclaration(self, node):
        """"""
        for parameter in node.parameters:
            try:
                var_name = parameter.variable.identifier.name
                var_is_mutable = parameter.variable.is_mutable
            except AttributeError:
                raise SementicError('Invalid parameter.')

            var_symbol = VariableSymbol(var_name, var_is_mutable)

            if self.table[var_name] is not None:
                raise SementicError(f"Duplicated `{var_name}` function parameter.")

            self.table[var_name] = var_symbol

        self.visit(node.body)