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
143ab334
Commit
143ab334
authored
Oct 01, 2020
by
aniket-engg
Committed by
Aniket
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
collection of AST nodes
parent
ac818121
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
astWalker.ts
libs/remix-astwalker/src/astWalker.ts
+28
-2
No files found.
libs/remix-astwalker/src/astWalker.ts
View file @
143ab334
...
@@ -59,9 +59,35 @@ export class AstWalker extends EventEmitter {
...
@@ -59,9 +59,35 @@ export class AstWalker extends EventEmitter {
}
}
}
}
normalizeNodes
(
nodes
:
AstNode
[]):
AstNode
[]
{
// TODO: If any element in nodes is array, extract its members in nodes and delete it
// TODO: Traverse through nodes to check deplicate nodes using id field
return
nodes
}
getASTNodeChildren
(
ast
:
AstNode
):
AstNode
[]
{
getASTNodeChildren
(
ast
:
AstNode
):
AstNode
[]
{
const
nodes
=
ast
.
nodes
||
(
ast
.
body
&&
ast
.
body
.
statements
)
||
ast
.
declarations
||
[]
const
nodes
=
ast
.
nodes
// for ContractDefinition
if
(
ast
.
body
&&
ast
.
initializationExpression
)
{
// 'for' loop handling
||
(
ast
.
body
&&
ast
.
body
.
statements
)
// // for FunctionDefinition
||
ast
.
members
// for StructDefinition, EnumDefinition
||
ast
.
overrides
// for OverrideSpecifier
||
ast
.
parameters
// for ParameterList
||
ast
.
declarations
||
[]
if
(
ast
.
body
&&
ast
.
overrides
&&
ast
.
parameters
&&
ast
.
returnParameters
&&
ast
.
modifiers
)
{
// for FunctionDefinition
nodes
.
push
(
ast
.
overrides
)
nodes
.
push
(
ast
.
parameters
)
nodes
.
push
(
ast
.
returnParameters
)
nodes
.
push
(
ast
.
modifiers
)
}
else
if
(
ast
.
overrides
&&
ast
.
typeName
)
{
// for VariableDeclaration
nodes
.
push
(
ast
.
typeName
)
}
else
if
(
ast
.
body
&&
ast
.
overrides
&&
ast
.
parameters
)
{
// for ModifierDefinition
nodes
.
push
(
ast
.
overrides
)
nodes
.
push
(
ast
.
parameters
)
}
else
if
(
ast
.
modifierName
&&
ast
.
arguments
)
{
// for ModifierInvocation
nodes
.
push
(
ast
.
modifierName
)
nodes
.
push
(
ast
.
arguments
)
}
else
if
(
ast
.
body
&&
ast
.
initializationExpression
)
{
// for ForStatement
nodes
.
push
(
ast
.
initializationExpression
)
nodes
.
push
(
ast
.
initializationExpression
)
}
}
return
nodes
return
nodes
...
...
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