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
7945b25d
Commit
7945b25d
authored
Sep 09, 2020
by
aniket-engg
Committed by
Aniket
Sep 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
latest AST used
parent
f68fde6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
36 deletions
+36
-36
contextView.js
apps/remix-ide/src/app/editor/contextView.js
+9
-9
contextualListener.js
apps/remix-ide/src/app/editor/contextualListener.js
+27
-27
No files found.
apps/remix-ide/src/app/editor/contextView.js
View file @
7945b25d
...
@@ -125,7 +125,7 @@ class ContextView {
...
@@ -125,7 +125,7 @@ class ContextView {
_render
(
node
,
nodeAtCursorPosition
)
{
_render
(
node
,
nodeAtCursorPosition
)
{
if
(
!
node
)
return
yo
`<div></div>`
if
(
!
node
)
return
yo
`<div></div>`
let
references
=
this
.
contextualListener
.
referencesOf
(
node
)
let
references
=
this
.
contextualListener
.
referencesOf
(
node
)
const
type
=
(
node
.
attributes
&&
node
.
attributes
.
type
)
?
node
.
attributes
.
type
:
node
.
name
const
type
=
node
&&
node
.
typeDescriptions
.
typeString
?
node
.
typeDescriptions
.
typeString
:
node
.
name
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
let
ref
=
0
let
ref
=
0
...
@@ -155,7 +155,7 @@ class ContextView {
...
@@ -155,7 +155,7 @@ class ContextView {
}
}
const
showGasEstimation
=
()
=>
{
const
showGasEstimation
=
()
=>
{
if
(
node
.
n
am
e
===
'FunctionDefinition'
)
{
if
(
node
.
n
odeTyp
e
===
'FunctionDefinition'
)
{
const
result
=
this
.
contextualListener
.
gasEstimation
(
node
)
const
result
=
this
.
contextualListener
.
gasEstimation
(
node
)
const
executionCost
=
' Execution cost: '
+
result
.
executionCost
+
' gas'
const
executionCost
=
' Execution cost: '
+
result
.
executionCost
+
' gas'
const
codeDepositCost
=
'Code deposit cost: '
+
result
.
codeDepositCost
+
' gas'
const
codeDepositCost
=
'Code deposit cost: '
+
result
.
codeDepositCost
+
' gas'
...
@@ -172,7 +172,7 @@ class ContextView {
...
@@ -172,7 +172,7 @@ class ContextView {
return
yo
`
return
yo
`
<div class=
${
css
.
line
}
>
${
showGasEstimation
()}
<div class=
${
css
.
line
}
>
${
showGasEstimation
()}
<div title=
${
type
}
class=
${
css
.
type
}
>
${
type
}
</div>
<div title=
${
type
}
class=
${
css
.
type
}
>
${
type
}
</div>
<div title=
${
node
.
attributes
.
name
}
class=
${
css
.
name
}
>
${
node
.
attributes
.
name
}
</div>
<div title=
${
node
.
name
}
class=
${
css
.
name
}
>
${
node
.
name
}
</div>
<i class="fas fa-share
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jumpTo
}
></i>
<i class="fas fa-share
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jumpTo
}
></i>
<span class=
${
css
.
referencesnb
}
>
${
references
}
</span>
<span class=
${
css
.
referencesnb
}
>
${
references
}
</span>
<i data-action='previous' class="fas fa-chevron-up
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jump
}
></i>
<i data-action='previous' class="fas fa-chevron-up
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jump
}
></i>
...
@@ -183,12 +183,12 @@ class ContextView {
...
@@ -183,12 +183,12 @@ class ContextView {
}
}
function
isDefinition
(
node
)
{
function
isDefinition
(
node
)
{
return
node
.
n
am
e
===
'ContractDefinition'
||
return
node
.
n
odeTyp
e
===
'ContractDefinition'
||
node
.
n
am
e
===
'FunctionDefinition'
||
node
.
n
odeTyp
e
===
'FunctionDefinition'
||
node
.
n
am
e
===
'ModifierDefinition'
||
node
.
n
odeTyp
e
===
'ModifierDefinition'
||
node
.
n
am
e
===
'VariableDeclaration'
||
node
.
n
odeTyp
e
===
'VariableDeclaration'
||
node
.
n
am
e
===
'StructDefinition'
||
node
.
n
odeTyp
e
===
'StructDefinition'
||
node
.
n
am
e
===
'EventDefinition'
node
.
n
odeTyp
e
===
'EventDefinition'
}
}
module
.
exports
=
ContextView
module
.
exports
=
ContextView
apps/remix-ide/src/app/editor/contextualListener.js
View file @
7945b25d
...
@@ -65,8 +65,8 @@ class ContextualListener extends Plugin {
...
@@ -65,8 +65,8 @@ class ContextualListener extends Plugin {
}
}
declarationOf
(
node
)
{
declarationOf
(
node
)
{
if
(
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
if
(
node
&&
node
.
referencedDeclaration
)
{
return
this
.
_index
[
'FlatReferences'
][
node
.
attributes
.
referencedDeclaration
]
return
this
.
_index
[
'FlatReferences'
][
node
.
referencedDeclaration
]
}
}
return
null
return
null
}
}
...
@@ -99,17 +99,17 @@ class ContextualListener extends Plugin {
...
@@ -99,17 +99,17 @@ class ContextualListener extends Plugin {
if
(
compilationResult
&&
compilationResult
.
sources
)
{
if
(
compilationResult
&&
compilationResult
.
sources
)
{
const
callback
=
{}
const
callback
=
{}
callback
[
'*'
]
=
(
node
)
=>
{
callback
[
'*'
]
=
(
node
)
=>
{
if
(
node
&&
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
if
(
node
&&
node
.
referencedDeclaration
)
{
if
(
!
this
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
])
{
if
(
!
this
.
_index
[
'Declarations'
][
node
.
referencedDeclaration
])
{
this
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
]
=
[]
this
.
_index
[
'Declarations'
][
node
.
referencedDeclaration
]
=
[]
}
}
this
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
].
push
(
node
)
this
.
_index
[
'Declarations'
][
node
.
referencedDeclaration
].
push
(
node
)
}
}
this
.
_index
[
'FlatReferences'
][
node
.
id
]
=
node
this
.
_index
[
'FlatReferences'
][
node
.
id
]
=
node
return
true
return
true
}
}
for
(
const
s
in
compilationResult
.
sources
)
{
for
(
const
s
in
compilationResult
.
sources
)
{
this
.
astWalker
.
walk
(
compilationResult
.
sources
[
s
].
legacyAST
,
callback
)
this
.
astWalker
.
walk
(
compilationResult
.
sources
[
s
].
ast
,
callback
)
}
}
}
}
}
}
...
@@ -136,7 +136,7 @@ class ContextualListener extends Plugin {
...
@@ -136,7 +136,7 @@ class ContextualListener extends Plugin {
background-color: var(--info);
background-color: var(--info);
}
}
`
`
if
(
node
.
children
&&
node
.
children
.
length
)
{
if
(
node
.
nodes
&&
node
.
nodes
.
length
)
{
// If node has children, highlight the entire line. if not, just highlight the current source position of the node.
// If node has children, highlight the entire line. if not, just highlight the current source position of the node.
lineColumn
=
{
lineColumn
=
{
start
:
{
start
:
{
...
@@ -167,9 +167,9 @@ class ContextualListener extends Plugin {
...
@@ -167,9 +167,9 @@ class ContextualListener extends Plugin {
}
}
}
}
}
}
if
(
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
if
(
node
&&
node
.
referencedDeclaration
)
{
highlights
(
node
.
attributes
.
referencedDeclaration
)
highlights
(
node
.
referencedDeclaration
)
const
current
=
this
.
_index
[
'FlatReferences'
][
node
.
attributes
.
referencedDeclaration
]
const
current
=
this
.
_index
[
'FlatReferences'
][
node
.
referencedDeclaration
]
this
.
_highlight
(
current
,
compilationResult
)
this
.
_highlight
(
current
,
compilationResult
)
}
else
{
}
else
{
highlights
(
node
.
id
)
highlights
(
node
.
id
)
...
@@ -190,10 +190,10 @@ class ContextualListener extends Plugin {
...
@@ -190,10 +190,10 @@ class ContextualListener extends Plugin {
gasEstimation
(
node
)
{
gasEstimation
(
node
)
{
this
.
_loadContractInfos
(
node
)
this
.
_loadContractInfos
(
node
)
let
executionCost
,
codeDepositCost
let
executionCost
,
codeDepositCost
if
(
node
.
n
am
e
===
'FunctionDefinition'
)
{
if
(
node
.
n
odeTyp
e
===
'FunctionDefinition'
)
{
const
visibility
=
node
.
attributes
.
visibility
const
visibility
=
node
.
visibility
if
(
!
node
.
attributes
.
isConstructor
)
{
if
(
!
node
.
kind
===
'constructor'
)
{
const
fnName
=
node
.
attributes
.
name
const
fnName
=
node
.
name
const
fn
=
fnName
+
this
.
_getInputParams
(
node
)
const
fn
=
fnName
+
this
.
_getInputParams
(
node
)
if
(
visibility
===
'public'
||
visibility
===
'external'
)
{
if
(
visibility
===
'public'
||
visibility
===
'external'
)
{
executionCost
=
this
.
estimationObj
.
external
[
fn
]
executionCost
=
this
.
estimationObj
.
external
[
fn
]
...
@@ -212,9 +212,9 @@ class ContextualListener extends Plugin {
...
@@ -212,9 +212,9 @@ class ContextualListener extends Plugin {
_loadContractInfos
(
node
)
{
_loadContractInfos
(
node
)
{
for
(
const
i
in
this
.
nodes
)
{
for
(
const
i
in
this
.
nodes
)
{
if
(
this
.
nodes
[
i
].
id
===
node
.
attributes
.
scope
)
{
if
(
this
.
nodes
[
i
].
id
===
node
.
scope
)
{
const
contract
=
this
.
nodes
[
i
]
const
contract
=
this
.
nodes
[
i
]
this
.
contract
=
this
.
results
.
data
.
contracts
[
this
.
results
.
source
.
target
][
contract
.
attributes
.
name
]
this
.
contract
=
this
.
results
.
data
.
contracts
[
this
.
results
.
source
.
target
][
contract
.
name
]
this
.
estimationObj
=
this
.
contract
.
evm
.
gasEstimates
this
.
estimationObj
=
this
.
contract
.
evm
.
gasEstimates
this
.
creationCost
=
this
.
estimationObj
.
creation
.
totalCost
this
.
creationCost
=
this
.
estimationObj
.
creation
.
totalCost
this
.
codeDepositCost
=
this
.
estimationObj
.
creation
.
codeDepositCost
this
.
codeDepositCost
=
this
.
estimationObj
.
creation
.
codeDepositCost
...
@@ -224,18 +224,18 @@ class ContextualListener extends Plugin {
...
@@ -224,18 +224,18 @@ class ContextualListener extends Plugin {
_getInputParams
(
node
)
{
_getInputParams
(
node
)
{
const
params
=
[]
const
params
=
[]
let
target
let
target
=
node
.
parameters
for
(
const
i
in
node
.
children
)
{
//
for (const i in node.children) {
if
(
node
.
children
[
i
].
name
===
'ParameterList'
)
{
//
if (node.children[i].name === 'ParameterList') {
target
=
node
.
children
[
i
]
//
target = node.children[i]
break
//
break
}
//
}
}
//
}
if
(
target
)
{
if
(
target
)
{
const
children
=
target
.
children
const
children
=
target
.
parameters
for
(
const
j
in
children
)
{
for
(
const
j
in
children
)
{
if
(
children
[
j
].
n
am
e
===
'VariableDeclaration'
)
{
if
(
children
[
j
].
n
odeTyp
e
===
'VariableDeclaration'
)
{
params
.
push
(
children
[
j
].
attributes
.
type
)
params
.
push
(
children
[
j
].
typeDescriptions
.
typeString
)
}
}
}
}
}
}
...
...
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