Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b8df4da0
Commit
b8df4da0
authored
Aug 12, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small changes
parent
e8786f49
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
astWalker.js
src/util/astWalker.js
+10
-12
No files found.
src/util/astWalker.js
View file @
b8df4da0
...
@@ -9,18 +9,16 @@ function AstWalker () {
...
@@ -9,18 +9,16 @@ function AstWalker () {
*
*
* @param {Object} ast - AST node
* @param {Object} ast - AST node
* @param {Object or Function} callback - if (Function) the function will be called for every node.
* @param {Object or Function} callback - if (Function) the function will be called for every node.
* - if (Object) callback[<Node Type>] will be called for every node of type <Node Type>. callback["*"] will be called fo all other nodes.
* - if (Object) callback[<Node Type>] will be called for
* in each case, if the callback returns false it does not descend into children. If no callback for the current type, children are visited.
* every node of type <Node Type>. callback["*"] will be called fo all other nodes.
* in each case, if the callback returns false it does not descend into children.
* If no callback for the current type, children are visited.
*/
*/
AstWalker
.
prototype
.
walk
=
function
(
ast
,
callback
)
{
AstWalker
.
prototype
.
walk
=
function
(
ast
,
callback
)
{
crawlNode
(
ast
,
callback
)
if
(
manageCallBack
(
ast
,
callback
)
&&
ast
.
children
&&
ast
.
children
.
length
>
0
)
{
}
for
(
var
k
in
ast
.
children
)
{
var
child
=
ast
.
children
[
k
]
function
crawlNode
(
node
,
callback
)
{
this
.
walk
(
child
,
callback
)
if
(
manageCallBack
(
node
,
callback
)
&&
node
.
children
&&
node
.
children
.
length
>
0
)
{
for
(
var
k
in
node
.
children
)
{
var
child
=
node
.
children
[
k
]
crawlNode
(
child
,
callback
)
}
}
}
}
}
}
...
@@ -29,8 +27,8 @@ function manageCallBack (node, callback) {
...
@@ -29,8 +27,8 @@ function manageCallBack (node, callback) {
if
(
callback
instanceof
Function
)
{
if
(
callback
instanceof
Function
)
{
return
callback
(
null
,
node
)
return
callback
(
null
,
node
)
}
else
if
(
callback
instanceof
Object
)
{
}
else
if
(
callback
instanceof
Object
)
{
if
(
callback
[
node
.
name
]
instanceof
'Function'
)
{
if
(
callback
[
node
.
name
]
instanceof
Function
)
{
return
callback
[
node
.
name
](
null
,
node
)
return
callback
[
node
.
name
](
null
,
Function
)
}
else
if
(
callback
[
'*'
]
instanceof
'Function'
)
{
}
else
if
(
callback
[
'*'
]
instanceof
'Function'
)
{
return
callback
[
'*'
](
null
,
node
)
return
callback
[
'*'
](
null
,
node
)
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment