bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
function(node) {

        var parent = node.parent;

        switch (node.type) {
            case "ClassDeclaration":
            case "FunctionDeclaration":
                if (looksLikeExport(parent)) {
                    return findJSDocComment(parent.leadingComments, parent.loc.start.line);
                }
                return findJSDocComment(node.leadingComments, node.loc.start.line);

            case "ClassExpression":
                return findJSDocComment(parent.parent.leadingComments, parent.parent.loc.start.line);

            case "ArrowFunctionExpression":
            case "FunctionExpression":

                if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
                    while (parent && !parent.leadingComments && !/Function/.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
                        parent = parent.parent;
                    }

                    return parent && parent.type !== "FunctionDeclaration" ? findJSDocComment(parent.leadingComments, parent.loc.start.line) : null;
                } else if (node.leadingComments) {
                    return findJSDocComment(node.leadingComments, node.loc.start.line);
                }

            // falls through

            default:
                return null;
        }
    }
function(node) {

        var parent = node.parent;

        switch (node.type) {
            case "ClassDeclaration":
            case "FunctionDeclaration":
                if (looksLikeExport(parent)) {
                    return findJSDocComment(parent.leadingComments, parent.loc.start.line);
                }
                return findJSDocComment(node.leadingComments, node.loc.start.line);

            case "ClassExpression":
                return findJSDocComment(parent.parent.leadingComments, parent.parent.loc.start.line);

            case "ArrowFunctionExpression":
            case "FunctionExpression":

                if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
                    while (parent && !parent.leadingComments && !/Function/.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
                        parent = parent.parent;
                    }

                    return parent && parent.type !== "FunctionDeclaration" ? findJSDocComment(parent.leadingComments, parent.loc.start.line) : null;
                } else if (node.leadingComments) {
                    return findJSDocComment(node.leadingComments, node.loc.start.line);
                }

            // falls through

            default:
                return null;
        }
    }
function ( node ) { var parent = node . parent ; switch ( node . type ) { case "ClassDeclaration" : case "FunctionDeclaration" : if ( looksLikeExport ( parent ) ) { return findJSDocComment ( parent . leadingComments , parent . loc . start . line ) ; } return findJSDocComment ( node . leadingComments , node . loc . start . line ) ; case "ClassExpression" : return findJSDocComment ( parent . parent . leadingComments , parent . parent . loc . start . line ) ; case "ArrowFunctionExpression" : case "FunctionExpression" : if ( parent . type !== "CallExpression" && parent . type !== "NewExpression" ) { while ( parent && ! parent . leadingComments && ! / Function / . test ( parent . type ) && parent . type !== "MethodDefinition" && parent . type !== "Property" ) { parent = parent . parent ; } return parent && parent . type !== "FunctionDeclaration" ? findJSDocComment ( parent . leadingComments , parent . loc . start . line ) : null ; } else if ( node . leadingComments ) { return findJSDocComment ( node . leadingComments , node . loc . start . line ) ; } // falls through default : return null ; } }
Retrieves the JSDoc comment for a given node.
@param {ASTNode} node The AST node to get the comment for.
@returns {ASTNode} The BlockComment node containing the JSDoc for the
given node or null if not found.
@public
Retrieves the JSDoc comment for a given node .