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
1030ea58
Commit
1030ea58
authored
Sep 16, 2020
by
yann300
Committed by
Aniket
Sep 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove astwalker from remix-debug
parent
09c98ed1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
59 deletions
+0
-59
astWalker.js
libs/remix-debug/src/source/astWalker.js
+0
-59
No files found.
libs/remix-debug/src/source/astWalker.js
deleted
100644 → 0
View file @
09c98ed1
'use strict'
/**
* Crawl the given AST through the function walk(ast, callback)
*/
function
AstWalker
()
{}
// eslint-disable-line
/**
* 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 for 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
)
{
if
(
callback
instanceof
Function
)
{
callback
=
{
'*'
:
callback
}
}
if
(
!
(
'*'
in
callback
))
{
callback
[
'*'
]
=
function
()
{
return
true
}
}
if
(
ast
)
{
const
nodes
=
ast
.
nodes
||
(
ast
.
body
&&
ast
.
body
.
statements
)
||
ast
.
declarations
||
[]
if
(
ast
.
body
&&
ast
.
initializationExpression
)
{
// 'for' loop handling
nodes
.
push
(
ast
.
initializationExpression
)
}
if
(
manageCallBack
(
ast
,
callback
)
&&
nodes
&&
nodes
.
length
>
0
)
{
for
(
let
k
in
nodes
)
{
const
child
=
nodes
[
k
]
this
.
walk
(
child
,
callback
)
}
}
}
}
/**
* walk the given @astList
*
* @param {Object} sourcesList - sources list (containing root AST node)
* @param {Function} - callback used by AstWalker to compute response
*/
AstWalker
.
prototype
.
walkAstList
=
function
(
sourcesList
,
callback
)
{
const
walker
=
new
AstWalker
()
for
(
let
k
in
sourcesList
)
{
walker
.
walk
(
sourcesList
[
k
].
ast
,
callback
)
}
}
function
manageCallBack
(
node
,
callback
)
{
if
(
node
.
nodeType
in
callback
)
{
return
callback
[
node
.
nodeType
](
node
)
}
else
{
return
callback
[
'*'
](
node
)
}
}
module
.
exports
=
AstWalker
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