function analyzeCode(text, scopes, srcScope, destScope, start, end) {
        var identifiers          = {},
            inThisScope          = {},
            thisPointerUsed      = false,
            returnStatementUsed  = false,
            variableDeclarations = {},
            changedValues        = {},
            dependentValues      = {},
            ast                  = RefactoringUtils.getAST(text),
            doc                  = session.editor.document,
            restScopeStr;

        ASTWalker.full(ast, function(node) {
            var value, name;
            switch (node.type) {
                case "AssignmentExpression":
                    value = node.left;
                    break;
                case "VariableDeclarator":
                    inThisScope[node.id.name] = true;
                    value = node.init && node.id;
                    var variableDeclarationNode = RefactoringUtils.findSurroundASTNode(ast, node, ["VariableDeclaration"]);
                    variableDeclarations[node.id.name] = variableDeclarationNode.kind;
                    break;
                case "ThisExpression":
                    thisPointerUsed = true;
                    break;
                case "UpdateExpression":
                    value = node.argument;
                    break;
                case "Identifier":
                    identifiers[node.name] = true;
                    break;
                case "ReturnStatement":
                    returnStatementUsed = true;
                    break;
            }
            if (value){
                if (value.type === "MemberExpression") {
                    name = value.object.name;
                } else {
                    name = value.name;
                }
                changedValues[name] = true;
            }
        });

        if (srcScope.originNode) {
            restScopeStr = doc.getText().substr(end, srcScope.originNode.end - end);
        } else {
            restScopeStr = doc.getText().substr(end);
        }

        ASTWalker.simple(RefactoringUtils.getAST(restScopeStr), {
            Identifier: function(node) {
                var name = node.name;
                dependentValues[name] = true;
            },
            Expression: function(node) {
                if (node.type === "MemberExpression") {
                    var name = node.object.name;
                    dependentValues[name] = true;
                }
            }
        });

        var passProps = scopes.slice(srcScope.id, destScope.id).reduce(function(props, scope) {
            return _.union(props, _.keys(scope.props));
        }, []);

        var retProps = scopes.slice(srcScope.id, destScope.id + 1).reduce(function(props, scope) {
            return _.union(props, _.keys(scope.props));
        }, []);

        return {
            passParams:           _.intersection(_.difference(_.keys(identifiers), _.keys(inThisScope)), passProps),
            retParams:            _.intersection( _.keys(changedValues), _.keys(dependentValues), retProps),
            thisPointerUsed:      thisPointerUsed,
            returnStatementUsed:  returnStatementUsed,
            variableDeclarations: variableDeclarations
        };
    }
Analyzes the code and finds values required for extract to function
@param {!string} text - text to be extracted
@param {!Array.<Scope>} - scopes
@param {!Scope} srcScope - source scope of the extraction
@param {!Scope} destScope - destination scope of the extraction
@param {!number} start - the start offset
@param {!number} end - the end offset
@return {!{
         passParams: Array.<string>,
         retParams: Array.<string>,
         thisPointerUsed: boolean,
         varaibleDeclarations: {} // variable-name: kind
}}