src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js
function getExpressions(ast, start, end) {
        var expns = [],
            s     = start,
            e     = end,
            expn;

        while (true) {
            expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
            if (!expn) {
                break;
            }
            expns.push(expn);
            s = expn.start - 1;
        }

        s = start;
        e = end;

        function checkExpnEquality(e) {
            return e.start === expn.start && e.end === expn.end;
        }

        while (true) {
            expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
            if (!expn) {
                break;
            }
            e = expn.end + 1;

            // if expn already added, continue
            if (expns.find(checkExpnEquality)) {
                 continue;
            }

            expns.push(expn);
        }

        return expns;
    }
function getExpressions(ast, start, end) {
        var expns = [],
            s     = start,
            e     = end,
            expn;

        while (true) {
            expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
            if (!expn) {
                break;
            }
            expns.push(expn);
            s = expn.start - 1;
        }

        s = start;
        e = end;

        function checkExpnEquality(e) {
            return e.start === expn.start && e.end === expn.end;
        }

        while (true) {
            expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
            if (!expn) {
                break;
            }
            e = expn.end + 1;

            // if expn already added, continue
            if (expns.find(checkExpnEquality)) {
                 continue;
            }

            expns.push(expn);
        }

        return expns;
    }
function getExpressions ( ast , start , end ) { var expns = [ ] , s = start , e = end , expn ; while ( true ) { expn = RefactoringUtils . findSurroundExpression ( ast , { start : s , end : e } ) ; if ( ! expn ) { break ; } expns . push ( expn ) ; s = expn . start - 1 ; } s = start ; e = end ; function checkExpnEquality ( e ) { return e . start === expn . start && e . end === expn . end ; } while ( true ) { expn = RefactoringUtils . findSurroundExpression ( ast , { start : s , end : e } ) ; if ( ! expn ) { break ; } e = expn . end + 1 ; // if expn already added, continue if ( expns . find ( checkExpnEquality ) ) { continue ; } expns . push ( expn ) ; } return expns ; }
Gets the surrounding expressions of start and end offset
@param {!ASTNode} ast - the ast of the complete file
@param {!number} start - the start offset
@param {!number} end - the end offset
@return {!Array.<ASTNode>}
Gets the surrounding expressions of start and end offset