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
5398e18b
Commit
5398e18b
authored
Feb 14, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make specific API for each component
parent
1afd56c3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
96 deletions
+64
-96
app.js
src/app.js
+49
-21
debugger.js
src/app/debugger.js
+3
-58
editor.js
src/app/editor.js
+4
-2
renderer.js
src/app/renderer.js
+8
-15
No files found.
src/app.js
View file @
5398e18b
...
@@ -515,29 +515,38 @@ var run = function () {
...
@@ -515,29 +515,38 @@ var run = function () {
}
}
}
}
var
editorAPI
=
{
var
editorAPIDebug
=
{
currentOpenedFile
:
()
=>
{
statementMarker
:
null
,
return
editor
.
getCacheFile
()
fullLineMarker
:
null
,
sourceLocation
:
(
lineColumnPos
,
location
)
=>
{
if
(
this
.
statementMarker
)
editor
.
removeMarker
(
this
.
statementMarker
)
if
(
this
.
fullLineMarker
)
editor
.
removeMarker
(
this
.
fullLineMarker
)
this
.
statementMarker
=
null
this
.
fullLineMarker
=
null
if
(
lineColumnPos
)
{
var
name
=
editor
.
getCacheFile
()
// current opened tab
var
source
=
compiler
.
lastCompilationResult
.
data
.
sourceList
[
location
.
file
]
// auto switch to that tab
if
(
name
!==
source
)
{
switchToFile
(
source
)
}
this
.
statementMarker
=
editor
.
addMarker
(
lineColumnPos
,
'highlightcode'
)
if
(
lineColumnPos
.
start
.
line
===
lineColumnPos
.
end
.
line
)
{
this
.
fullLineMarker
=
editor
.
addMarker
({
start
:
{
line
:
lineColumnPos
.
start
.
line
,
column
:
0
},
},
addMarker
:
(
range
,
css
)
=>
{
end
:
{
return
editor
.
addMarker
(
range
,
css
)
line
:
lineColumnPos
.
start
.
line
+
1
,
},
column
:
0
removeMarker
:
(
markerId
)
=>
{
}
return
editor
.
removeMarker
(
markerId
)
},
'highlightcode_fullLine'
)
},
}
addAnnotation
:
(
info
)
=>
{
}
return
editor
.
addAnnotation
(
info
)
}
},
hasFile
:
(
file
)
=>
{
return
editor
.
hasFile
(
file
)
},
gotoLine
:
(
line
,
col
)
=>
{
return
editor
.
gotoLine
(
line
,
col
)
},
switchToFile
:
switchToFile
}
}
var
transactionDebugger
=
new
Debugger
(
'#debugger'
,
executionContext
.
event
,
editor
.
event
,
editorAPI
,
compilerAPI
,
contentToolAPI
)
var
transactionDebugger
=
new
Debugger
(
'#debugger'
,
executionContext
.
event
,
editor
.
event
,
editorAPI
Debug
,
compilerAPI
,
contentToolAPI
)
transactionDebugger
.
addProvider
(
'vm'
,
executionContext
.
vm
())
transactionDebugger
.
addProvider
(
'vm'
,
executionContext
.
vm
())
transactionDebugger
.
addProvider
(
'injected'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'injected'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'web3'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'web3'
,
executionContext
.
web3
())
...
@@ -564,7 +573,26 @@ var run = function () {
...
@@ -564,7 +573,26 @@ var run = function () {
startdebugging
(
txResult
.
transactionHash
)
startdebugging
(
txResult
.
transactionHash
)
})
})
var
renderer
=
new
Renderer
(
editorAPI
,
udappAPI
,
ethToolAPI
,
formalVerification
.
event
,
compiler
.
event
)
// eslint-disable-line
var
editorAPIRenderer
=
{
error
:
(
file
,
error
)
=>
{
if
(
file
===
editor
.
getCacheFile
())
{
editor
.
addAnnotation
(
error
)
}
},
errorClick
:
(
errFile
,
errLine
,
errCol
)
=>
{
if
(
errFile
!==
editor
.
getCacheFile
()
&&
editor
.
hasFile
(
errFile
))
{
switchToFile
(
errFile
)
}
editor
.
gotoLine
(
errLine
,
errCol
)
},
currentCompiledSourceCode
:
()
=>
{
if
(
compiler
.
lastCompilationResult
.
source
)
{
return
compiler
.
lastCompilationResult
.
source
.
sources
[
compiler
.
lastCompilationResult
.
source
.
target
]
}
return
''
}
}
var
renderer
=
new
Renderer
(
editorAPIRenderer
,
udappAPI
,
ethToolAPI
,
formalVerification
.
event
,
compiler
.
event
)
// eslint-disable-line
var
rendererAPI
=
{
var
rendererAPI
=
{
renderItem
:
(
label
,
warningContainer
,
type
)
=>
{
renderItem
:
(
label
,
warningContainer
,
type
)
=>
{
return
renderer
.
error
(
label
,
warningContainer
,
type
)
return
renderer
.
error
(
label
,
warningContainer
,
type
)
...
...
src/app/debugger.js
View file @
5398e18b
'use strict'
'use strict'
var
remix
=
require
(
'ethereum-remix'
)
var
remix
=
require
(
'ethereum-remix'
)
var
ace
=
require
(
'brace'
)
var
Range
=
ace
.
acequire
(
'ace/range'
).
Range
/**
/**
* Manage remix and source highlighting
* Manage remix and source highlighting
...
@@ -22,7 +20,7 @@ function Debugger (id, executionContextEvent, editorEvent, editorAPI, compilerAP
...
@@ -22,7 +20,7 @@ function Debugger (id, executionContextEvent, editorEvent, editorAPI, compilerAP
})
})
this
.
debugger
.
event
.
register
(
'traceUnloaded'
,
this
,
function
()
{
this
.
debugger
.
event
.
register
(
'traceUnloaded'
,
this
,
function
()
{
self
.
removeMarkers
(
)
self
.
editorAPI
.
sourceLocation
(
null
)
})
})
// unload if a file has changed (but not if tabs were switched)
// unload if a file has changed (but not if tabs were switched)
...
@@ -36,9 +34,9 @@ function Debugger (id, executionContextEvent, editorEvent, editorAPI, compilerAP
...
@@ -36,9 +34,9 @@ function Debugger (id, executionContextEvent, editorEvent, editorAPI, compilerAP
this
.
debugger
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromInstructionIndex
(
address
,
index
,
self
.
compilerAPI
.
lastCompilationResult
().
data
.
contracts
,
function
(
error
,
rawLocation
)
{
this
.
debugger
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromInstructionIndex
(
address
,
index
,
self
.
compilerAPI
.
lastCompilationResult
().
data
.
contracts
,
function
(
error
,
rawLocation
)
{
if
(
!
error
)
{
if
(
!
error
)
{
var
lineColumnPos
=
self
.
contentToolAPI
.
offsetToLineColumn
(
rawLocation
,
rawLocation
.
file
)
var
lineColumnPos
=
self
.
contentToolAPI
.
offsetToLineColumn
(
rawLocation
,
rawLocation
.
file
)
self
.
highlight
(
lineColumnPos
,
rawLocation
)
self
.
editorAPI
.
sourceLocation
(
lineColumnPos
,
rawLocation
)
}
else
{
}
else
{
self
.
unhighlight
(
)
self
.
editorAPI
.
sourceLocation
(
null
)
}
}
})
})
}
}
...
@@ -61,40 +59,6 @@ Debugger.prototype.debug = function (txHash) {
...
@@ -61,40 +59,6 @@ Debugger.prototype.debug = function (txHash) {
}
}
/**
/**
* highlight the given @arg lineColumnPos
*
* @param {Object} lineColumnPos - position of the source code to hightlight {start: {line, column}, end: {line, column}}
* @param {Object} rawLocation - raw position of the source code to hightlight {start, length, file, jump}
*/
Debugger
.
prototype
.
highlight
=
function
(
lineColumnPos
,
rawLocation
)
{
var
name
=
this
.
editorAPI
.
currentOpenedFile
()
// current opened tab
var
source
=
this
.
compilerAPI
.
lastCompilationResult
().
data
.
sourceList
[
rawLocation
.
file
]
// auto switch to that tab
this
.
removeCurrentMarker
()
if
(
name
!==
source
)
{
this
.
editorAPI
.
switchToFile
(
source
)
// command the app to swicth to the next file
}
var
range
=
new
Range
(
lineColumnPos
.
start
.
line
,
lineColumnPos
.
start
.
column
,
lineColumnPos
.
end
.
line
,
lineColumnPos
.
end
.
column
)
this
.
markers
[
'highlightcode'
]
=
this
.
editor
.
addMarker
(
range
,
'highlightcode'
)
if
(
lineColumnPos
.
start
.
line
===
lineColumnPos
.
end
.
line
)
{
var
fullrange
=
new
Range
(
lineColumnPos
.
start
.
line
,
0
,
lineColumnPos
.
start
.
line
+
1
,
0
)
this
.
markers
[
'highlightcode_fullLine'
]
=
this
.
editor
.
addMarker
(
fullrange
,
'highlightcode_fullLine'
)
}
}
/**
* unhighlight the given @arg lineColumnPos
*
* @param {Object} lineColumnPos - position of the source code to hightlight {start: {line, column}, end: {line, column}}
* @param {Object} rawLocation - raw position of the source code to hightlight {start, length, file, jump}
*/
Debugger
.
prototype
.
unhighlight
=
function
(
lineColumnPos
,
rawLocation
,
cssCode
)
{
this
.
removeMarker
(
'highlightcode'
)
this
.
removeMarker
(
'highlightcode_fullLine'
)
this
.
currentRange
=
new
Range
(
lineColumnPos
.
start
.
line
,
lineColumnPos
.
start
.
column
,
lineColumnPos
.
end
.
line
,
lineColumnPos
.
end
.
column
)
this
.
currentMarker
=
this
.
editorAPI
.
addMarker
(
this
.
currentRange
,
'highlightcode'
)
}
/**
* add a new web3 provider to remix
* add a new web3 provider to remix
*
*
* @param {String} type - type/name of the provider to add
* @param {String} type - type/name of the provider to add
...
@@ -120,23 +84,4 @@ Debugger.prototype.web3 = function (type) {
...
@@ -120,23 +84,4 @@ Debugger.prototype.web3 = function (type) {
return
this
.
debugger
.
web3
()
return
this
.
debugger
.
web3
()
}
}
/**
* unhighlight highlighted statements
*/
Debugger
.
prototype
.
removeMarkers
=
function
()
{
for
(
var
k
in
this
.
markers
)
{
this
.
removeMarker
(
k
)
}
}
/**
* unhighlight the current highlighted statement
*/
Debugger
.
prototype
.
removeMarker
=
function
(
key
)
{
if
(
this
.
markers
[
key
])
{
this
.
editor
.
removeMarker
(
this
.
markers
[
key
])
this
.
markers
[
key
]
=
null
}
}
module
.
exports
=
Debugger
module
.
exports
=
Debugger
src/app/editor.js
View file @
5398e18b
...
@@ -5,6 +5,7 @@ var EventManager = require('../lib/eventManager')
...
@@ -5,6 +5,7 @@ var EventManager = require('../lib/eventManager')
var
examples
=
require
(
'./example-contracts'
)
var
examples
=
require
(
'./example-contracts'
)
var
ace
=
require
(
'brace'
)
var
ace
=
require
(
'brace'
)
var
Range
=
ace
.
acequire
(
'ace/range'
).
Range
require
(
'../mode-solidity.js'
)
require
(
'../mode-solidity.js'
)
function
Editor
(
doNotLoadStorage
,
storage
)
{
function
Editor
(
doNotLoadStorage
,
storage
)
{
...
@@ -17,8 +18,9 @@ function Editor (doNotLoadStorage, storage) {
...
@@ -17,8 +18,9 @@ function Editor (doNotLoadStorage, storage) {
var
sessions
=
{}
var
sessions
=
{}
var
sourceAnnotations
=
[]
var
sourceAnnotations
=
[]
this
.
addMarker
=
function
(
range
,
cssClass
)
{
this
.
addMarker
=
function
(
lineColumnPos
,
cssClass
)
{
return
editor
.
session
.
addMarker
(
range
,
cssClass
)
var
currentRange
=
new
Range
(
lineColumnPos
.
start
.
line
,
lineColumnPos
.
start
.
column
,
lineColumnPos
.
end
.
line
,
lineColumnPos
.
end
.
column
)
return
editor
.
session
.
addMarker
(
currentRange
,
cssClass
)
}
}
this
.
removeMarker
=
function
(
markerId
)
{
this
.
removeMarker
=
function
(
markerId
)
{
...
...
src/app/renderer.js
View file @
5398e18b
...
@@ -54,8 +54,8 @@ Renderer.prototype.error = function (message, container, options) {
...
@@ -54,8 +54,8 @@ Renderer.prototype.error = function (message, container, options) {
var
errFile
=
err
[
1
]
var
errFile
=
err
[
1
]
var
errLine
=
parseInt
(
err
[
2
],
10
)
-
1
var
errLine
=
parseInt
(
err
[
2
],
10
)
-
1
var
errCol
=
err
[
4
]
?
parseInt
(
err
[
4
],
10
)
:
0
var
errCol
=
err
[
4
]
?
parseInt
(
err
[
4
],
10
)
:
0
if
(
!
opt
.
noAnnotations
&&
(
errFile
===
''
||
errFile
===
self
.
editorAPI
.
currentOpenedFile
())
)
{
if
(
!
opt
.
noAnnotations
)
{
self
.
editorAPI
.
addAnnotation
(
{
self
.
editorAPI
.
error
(
errFile
,
{
row
:
errLine
,
row
:
errLine
,
column
:
errCol
,
column
:
errCol
,
text
:
message
,
text
:
message
,
...
@@ -63,11 +63,7 @@ Renderer.prototype.error = function (message, container, options) {
...
@@ -63,11 +63,7 @@ Renderer.prototype.error = function (message, container, options) {
})
})
}
}
$error
.
click
(
function
(
ev
)
{
$error
.
click
(
function
(
ev
)
{
if
(
errFile
!==
''
&&
errFile
!==
self
.
editorAPI
.
currentOpenedFile
()
&&
self
.
editorAPI
.
hasFile
(
errFile
))
{
self
.
editorAPI
.
errorClick
(
errFile
,
errLine
,
errCol
)
// Switch to file
self
.
editorAPI
.
switchToFile
(
errFile
)
}
self
.
editorAPI
.
gotoLine
(
errLine
,
errCol
)
})
})
}
}
$error
.
find
(
'.close'
).
click
(
function
(
ev
)
{
$error
.
find
(
'.close'
).
click
(
function
(
ev
)
{
...
@@ -261,6 +257,7 @@ Renderer.prototype.contracts = function (data, source) {
...
@@ -261,6 +257,7 @@ Renderer.prototype.contracts = function (data, source) {
return
$
(
'<div class="contractDetails"/>'
).
append
(
button
).
append
(
details
)
return
$
(
'<div class="contractDetails"/>'
).
append
(
button
).
append
(
details
)
}
}
var
self
=
this
var
renderOutputModifier
=
function
(
contractName
,
$contractOutput
)
{
var
renderOutputModifier
=
function
(
contractName
,
$contractOutput
)
{
var
contract
=
data
.
contracts
[
contractName
]
var
contract
=
data
.
contracts
[
contractName
]
if
(
contract
.
bytecode
)
{
if
(
contract
.
bytecode
)
{
...
@@ -279,15 +276,11 @@ Renderer.prototype.contracts = function (data, source) {
...
@@ -279,15 +276,11 @@ Renderer.prototype.contracts = function (data, source) {
}
}
}
}
var
ctrSource
=
getSource
(
contractName
,
source
,
data
)
var
ctrSource
=
self
.
editorAPI
.
currentCompiledSourceCode
()
return
$contractOutput
.
append
(
getDetails
(
contract
,
ctrSource
,
contractName
))
if
(
ctrSource
)
{
$contractOutput
.
append
(
getDetails
(
contract
,
ctrSource
,
contractName
))
}
}
return
$contractOutput
var
self
=
this
var
getSource
=
function
(
contractName
,
source
,
data
)
{
var
currentFile
=
self
.
editorAPI
.
currentOpenedFile
()
return
source
.
sources
[
currentFile
]
}
}
var
getAddress
=
function
(
cb
)
{
var
getAddress
=
function
(
cb
)
{
...
...
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