/*
 * Find scopes from AST
 * @lastmodifiedBy ChengFuLin(chengfulin0806@gmail.com)
 * @lastmodifiedDate 2015-07-27
 */
var walkes = require('walkes');

/**
 * ScopeFinder
 * @constructor
 */
function ScopeFinder() {
}

/**
 * Find function scopes of AST parsed from source
 * @param {Object} ast JS parsed AST
 * @returns {Object} Array of ASTs, each corresponds to global or function scope
 */
ScopeFinder.prototype.findScopes = function (ast) {
	'use strict';
	var scopes = [];
	function handleInnerFunction(astNode, recurse) {
		scopes.push(astNode);
		recurse(astNode.body);
	}

	walkes(ast, {
		Program: function (node, recurse) {
			scopes.push(node);
			node.body.forEach(function (elem) {
				recurse(elem);
			});
		},
		FunctionDeclaration: handleInnerFunction,
		FunctionExpression: handleInnerFunction
	});
	return scopes;
};

var finder = new ScopeFinder();
module.exports = finder;
@@ -1,11 +1,10 @@
 /*
-%0D
 %0A * Find
@@ -15,25 +15,24 @@
 pes from AST
-%0D
 %0A * @lastmod
@@ -75,17 +75,16 @@
 ail.com)
-%0D
 %0A * @las
@@ -107,22 +107,20 @@
 15-07-27
-%0D
 %0A */
-%0D
 %0Avar wal
@@ -143,24 +143,21 @@
 alkes');
-%0D%0A%0D
+%0A
 %0A/**
-%0D
 %0A * Scop
@@ -163,17 +163,16 @@
 peFinder
-%0D
 %0A * @con
@@ -179,22 +179,20 @@
 structor
-%0D
 %0A */
-%0D
 %0Afunctio
@@ -212,19 +212,15 @@
 () %7B
-%0D
 %0A%7D
-%0D%0A%0D
+%0A
 %0A/**
-%0D
 %0A * 
@@ -265,17 +265,16 @@
 m source
-%0D
 %0A * @par
@@ -302,17 +302,16 @@
 rsed AST
-%0D
 %0A * @ret
@@ -387,14 +387,12 @@
 cope
-%0D
 %0A */
-%0D
 %0ASco
@@ -439,17 +439,16 @@
  (ast) %7B
-%0D
 %0A%09'use s
@@ -454,17 +454,16 @@
 strict';
-%0D
 %0A%09var sc
@@ -472,17 +472,16 @@
 es = %5B%5D;
-%0D
 %0A%09functi
@@ -522,17 +522,16 @@
 curse) %7B
-%0D
 %0A%09%09scope
@@ -546,17 +546,16 @@
 stNode);
-%0D
 %0A%09%09recur
@@ -575,15 +575,12 @@
 dy);
-%0D
 %0A%09%7D
-%0D%0A%0D
+%0A
 %0A%09wa
@@ -590,17 +590,16 @@
 s(ast, %7B
-%0D
 %0A%09%09Progr
@@ -628,17 +628,16 @@
 curse) %7B
-%0D
 %0A%09%09%09scop
@@ -650,17 +650,16 @@
 h(node);
-%0D
 %0A%09%09%09node
@@ -689,17 +689,16 @@
 (elem) %7B
-%0D
 %0A%09%09%09%09rec
@@ -712,23 +712,20 @@
 em);
-%0D
 %0A%09%09%09%7D);
-%0D
 %0A%09%09%7D,
-%0D
 %0A%09%09F
@@ -764,17 +764,16 @@
 unction,
-%0D
 %0A%09%09Funct
@@ -810,15 +810,13 @@
 tion
-%0D
 %0A%09%7D);
-%0D
 %0A%09re
@@ -831,15 +831,12 @@
 pes;
-%0D
 %0A%7D;
-%0D%0A%0D
+%0A
 %0Avar
@@ -867,9 +867,8 @@
 r();
-%0D
 %0Amod

Modify default line separator from CRLF to LF