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
e8786f49
Commit
e8786f49
authored
Aug 10, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astcrawler
parent
5f5c4c7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
index.js
src/index.js
+3
-1
astWalker.js
src/util/astWalker.js
+40
-0
No files found.
src/index.js
View file @
e8786f49
...
...
@@ -5,6 +5,7 @@ var BasicPanel = require('./ui/BasicPanel')
var
TraceManager
=
require
(
'./trace/traceManager'
)
var
CodeManager
=
require
(
'./code/codeManager'
)
var
SourceMappingDecoder
=
require
(
'./util/sourceMappingDecoder'
)
var
AstWalker
=
require
(
'./util/astWalker'
)
if
(
typeof
(
module
)
!==
'undefined'
&&
typeof
(
module
.
exports
)
!==
'undefined'
)
{
module
.
exports
=
modules
()
...
...
@@ -24,7 +25,8 @@ function modules () {
BasicPanel
:
BasicPanel
},
util
:
{
SourceMappingDecoder
:
SourceMappingDecoder
SourceMappingDecoder
:
SourceMappingDecoder
,
AstWalker
:
AstWalker
}
}
}
...
...
src/util/astWalker.js
0 → 100644
View file @
e8786f49
'use strict'
/*
Crawl the given AST through the function walk(ast, callback)
*/
function
AstWalker
()
{
}
/*
* visit all the AST nodes
*
* @param {Object} ast - AST 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.
* 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
)
{
crawlNode
(
ast
,
callback
)
}
function
crawlNode
(
node
,
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
)
}
}
}
function
manageCallBack
(
node
,
callback
)
{
if
(
callback
instanceof
Function
)
{
return
callback
(
null
,
node
)
}
else
if
(
callback
instanceof
Object
)
{
if
(
callback
[
node
.
name
]
instanceof
'Function'
)
{
return
callback
[
node
.
name
](
null
,
node
)
}
else
if
(
callback
[
'*'
]
instanceof
'Function'
)
{
return
callback
[
'*'
](
null
,
node
)
}
else
{
return
true
}
}
}
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