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
ca8261f4
Commit
ca8261f4
authored
Jun 27, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
context view
parent
978e1b32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
51 deletions
+62
-51
app.js
src/app.js
+16
-41
contextView.js
src/app/editor/contextView.js
+46
-10
No files found.
src/app.js
View file @
ca8261f4
...
@@ -506,39 +506,26 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -506,39 +506,26 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
var
editor
=
self
.
_components
.
editor
// shortcut for the editor
var
editor
=
self
.
_components
.
editor
// shortcut for the editor
registry
.
put
({
api
:
editor
,
name
:
'editor'
})
registry
.
put
({
api
:
editor
,
name
:
'editor'
})
var
config
=
self
.
_api
.
config
var
filesProviders
=
self
.
_api
.
filesProviders
// ----------------- file manager ----------------------------
self
.
_components
.
fileManager
=
new
FileManager
({
config
:
config
,
editor
:
editor
,
filesProviders
:
filesProviders
,
compilerImport
:
self
.
_components
.
compilerImport
})
var
fileManager
=
self
.
_components
.
fileManager
registry
.
put
({
api
:
fileManager
,
name
:
'filemanager'
})
// ---------------- ContextualListener -----------------------
// ---------------- ContextualListener -----------------------
this
.
_components
.
contextualListener
=
new
ContextualListener
()
this
.
_components
.
contextualListener
=
new
ContextualListener
()
registry
.
put
({
api
:
this
.
_components
.
contextualListener
,
name
:
'contextualListener'
})
// ---------------- ContextView -----------------------
// ---------------- ContextView -----------------------
this
.
_components
.
contextView
=
new
ContextView
({
this
.
_components
.
contextView
=
new
ContextView
()
contextualListener
:
this
.
_components
.
contextualListener
,
jumpTo
:
(
position
)
=>
{
function
jumpToLine
(
lineColumn
)
{
if
(
lineColumn
.
start
&&
lineColumn
.
start
.
line
&&
lineColumn
.
start
.
column
)
{
editor
.
gotoLine
(
lineColumn
.
start
.
line
,
lineColumn
.
end
.
column
+
1
)
}
}
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
var
lineColumn
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
var
filename
=
compiler
.
getSourceName
(
position
.
file
)
// TODO: refactor with rendererAPI.errorClick
if
(
filename
!==
config
.
get
(
'currentFile'
))
{
var
provider
=
fileManager
.
fileProviderOf
(
filename
)
if
(
provider
)
{
provider
.
exists
(
filename
,
(
error
,
exist
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
fileManager
.
switchFile
(
filename
)
jumpToLine
(
lineColumn
)
})
}
}
else
{
jumpToLine
(
lineColumn
)
}
}
}
},
{
contextualListener
:
this
.
_components
.
contextualListener
.
event
})
// ----------------- editor panel ----------------------
// ----------------- editor panel ----------------------
this
.
_components
.
editorpanel
=
new
EditorPanel
({
this
.
_components
.
editorpanel
=
new
EditorPanel
({
...
@@ -572,18 +559,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -572,18 +559,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
this
.
event
=
new
EventManager
()
this
.
event
=
new
EventManager
()
var
config
=
self
.
_api
.
config
var
filesProviders
=
self
.
_api
.
filesProviders
self
.
_components
.
fileManager
=
new
FileManager
({
config
:
config
,
editor
:
editor
,
filesProviders
:
filesProviders
,
compilerImport
:
self
.
_components
.
compilerImport
})
var
fileManager
=
self
.
_components
.
fileManager
registry
.
put
({
api
:
fileManager
,
name
:
'filemanager'
})
// Add files received from remote instance (i.e. another remix-ide)
// Add files received from remote instance (i.e. another remix-ide)
function
loadFiles
(
filesSet
,
fileProvider
,
callback
)
{
function
loadFiles
(
filesSet
,
fileProvider
,
callback
)
{
if
(
!
fileProvider
)
fileProvider
=
'browser'
if
(
!
fileProvider
)
fileProvider
=
'browser'
...
...
src/app/editor/contextView.js
View file @
ca8261f4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
remixLib
=
require
(
'remix-lib'
)
var
remixLib
=
require
(
'remix-lib'
)
var
SourceMappingDecoder
=
remixLib
.
SourceMappingDecoder
var
SourceMappingDecoder
=
remixLib
.
SourceMappingDecoder
var
globalRegistry
=
require
(
'../../global/registry'
)
var
css
=
require
(
'./styles/contextView-styles'
)
var
css
=
require
(
'./styles/contextView-styles'
)
...
@@ -13,15 +14,24 @@ var css = require('./styles/contextView-styles')
...
@@ -13,15 +14,24 @@ var css = require('./styles/contextView-styles')
- rename declaration/references
- rename declaration/references
*/
*/
class
ContextView
{
class
ContextView
{
constructor
(
api
,
event
)
{
constructor
(
localRegistry
)
{
this
.
_api
=
api
const
self
=
this
this
.
_event
=
event
self
.
_components
=
{}
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_deps
=
{
contextualListener
:
self
.
_components
.
registry
.
get
(
'contextualListener'
).
api
,
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
,
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
offsetToLineColumnConverter
:
self
.
_components
.
registry
.
get
(
'offsetToLineColumnConverter'
).
api
,
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
}
this
.
_view
this
.
_view
this
.
_nodes
this
.
_nodes
this
.
_current
this
.
_current
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
previousElement
=
null
this
.
previousElement
=
null
event
.
contextualListener
.
register
(
'contextChanged'
,
nodes
=>
{
self
.
_deps
.
contextualListener
.
event
.
register
(
'contextChanged'
,
nodes
=>
{
this
.
_nodes
=
nodes
this
.
_nodes
=
nodes
this
.
update
()
this
.
update
()
})
})
...
@@ -66,7 +76,7 @@ class ContextView {
...
@@ -66,7 +76,7 @@ class ContextView {
if
(
isDefinition
(
last
))
{
if
(
isDefinition
(
last
))
{
this
.
_current
=
last
this
.
_current
=
last
}
else
{
}
else
{
var
target
=
this
.
_
api
.
contextualListener
.
declarationOf
(
last
)
var
target
=
this
.
_
deps
.
contextualListener
.
declarationOf
(
last
)
if
(
target
)
{
if
(
target
)
{
this
.
_current
=
target
this
.
_current
=
target
}
else
{
}
else
{
...
@@ -80,15 +90,41 @@ class ContextView {
...
@@ -80,15 +90,41 @@ class ContextView {
return
this
.
previousElement
return
this
.
previousElement
}
}
_jumpToInternal
(
position
)
{
var
self
=
this
function
jumpToLine
(
lineColumn
)
{
if
(
lineColumn
.
start
&&
lineColumn
.
start
.
line
&&
lineColumn
.
start
.
column
)
{
self
.
_deps
.
editor
.
gotoLine
(
lineColumn
.
start
.
line
,
lineColumn
.
end
.
column
+
1
)
}
}
if
(
self
.
_deps
.
compiler
.
lastCompilationResult
&&
self
.
_deps
.
compiler
.
lastCompilationResult
.
data
)
{
var
lineColumn
=
self
.
_deps
.
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
self
.
_deps
.
compiler
.
lastCompilationResult
)
var
filename
=
self
.
_deps
.
compiler
.
getSourceName
(
position
.
file
)
// TODO: refactor with rendererAPI.errorClick
if
(
filename
!==
self
.
_deps
.
config
.
get
(
'currentFile'
))
{
var
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
filename
)
if
(
provider
)
{
provider
.
exists
(
filename
,
(
error
,
exist
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
self
.
_deps
.
fileManager
.
switchFile
(
filename
)
jumpToLine
(
lineColumn
)
})
}
}
else
{
jumpToLine
(
lineColumn
)
}
}
}
_render
(
node
,
nodeAtCursorPosition
)
{
_render
(
node
,
nodeAtCursorPosition
)
{
if
(
!
node
)
return
yo
`<div></div>`
if
(
!
node
)
return
yo
`<div></div>`
var
self
=
this
var
self
=
this
var
references
=
this
.
_api
.
contextualListener
.
referencesOf
(
node
)
var
references
=
self
.
_deps
.
contextualListener
.
referencesOf
(
node
)
var
type
=
(
node
.
attributes
&&
node
.
attributes
.
type
)
?
node
.
attributes
.
type
:
node
.
name
var
type
=
(
node
.
attributes
&&
node
.
attributes
.
type
)
?
node
.
attributes
.
type
:
node
.
name
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
var
ref
=
0
var
ref
=
0
var
nodes
=
self
.
_
api
.
contextualListener
.
getActiveHighlights
()
var
nodes
=
self
.
_
deps
.
contextualListener
.
getActiveHighlights
()
for
(
var
k
in
nodes
)
{
for
(
var
k
in
nodes
)
{
if
(
nodeAtCursorPosition
.
id
===
nodes
[
k
].
nodeId
)
{
if
(
nodeAtCursorPosition
.
id
===
nodes
[
k
].
nodeId
)
{
ref
=
k
ref
=
k
...
@@ -101,14 +137,14 @@ class ContextView {
...
@@ -101,14 +137,14 @@ class ContextView {
e
.
target
.
dataset
.
action
===
'next'
?
ref
++
:
ref
--
e
.
target
.
dataset
.
action
===
'next'
?
ref
++
:
ref
--
if
(
ref
<
0
)
ref
=
nodes
.
length
-
1
if
(
ref
<
0
)
ref
=
nodes
.
length
-
1
if
(
ref
>=
nodes
.
length
)
ref
=
0
if
(
ref
>=
nodes
.
length
)
ref
=
0
self
.
_
api
.
jumpTo
(
nodes
[
ref
].
position
)
self
.
_
jumpToInternal
(
nodes
[
ref
].
position
)
}
}
function
jumpTo
()
{
function
jumpTo
()
{
if
(
node
&&
node
.
src
)
{
if
(
node
&&
node
.
src
)
{
var
position
=
self
.
sourceMappingDecoder
.
decode
(
node
.
src
)
var
position
=
self
.
sourceMappingDecoder
.
decode
(
node
.
src
)
if
(
position
)
{
if
(
position
)
{
self
.
_
api
.
jumpTo
(
position
)
self
.
_
jumpToInternal
(
position
)
}
}
}
}
}
}
...
@@ -125,7 +161,7 @@ class ContextView {
...
@@ -125,7 +161,7 @@ class ContextView {
function
showGasEstimation
()
{
function
showGasEstimation
()
{
if
(
node
.
name
===
'FunctionDefinition'
)
{
if
(
node
.
name
===
'FunctionDefinition'
)
{
var
result
=
self
.
_
api
.
contextualListener
.
gasEstimation
(
node
)
var
result
=
self
.
_
deps
.
contextualListener
.
gasEstimation
(
node
)
var
executionCost
=
'Execution cost: '
+
result
.
executionCost
+
' gas'
var
executionCost
=
'Execution cost: '
+
result
.
executionCost
+
' gas'
var
codeDepositCost
=
'Code deposit cost: '
+
result
.
codeDepositCost
+
' gas'
var
codeDepositCost
=
'Code deposit cost: '
+
result
.
codeDepositCost
+
' gas'
var
estimatedGas
=
result
.
codeDepositCost
?
`
${
codeDepositCost
}
,
${
executionCost
}
`
:
`
${
executionCost
}
`
var
estimatedGas
=
result
.
codeDepositCost
?
`
${
codeDepositCost
}
,
${
executionCost
}
`
:
`
${
executionCost
}
`
...
...
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