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
00eba199
Unverified
Commit
00eba199
authored
Sep 07, 2018
by
yann300
Committed by
GitHub
Sep 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1491 from ethereum/addAPIs2
Improve API
parents
698d26fb
67e5f2a6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
18 deletions
+71
-18
sourceHighlighter.js
src/app/editor/sourceHighlighter.js
+28
-15
righthand-panel.js
src/app/panels/righthand-panel.js
+2
-0
pluginAPI.js
src/app/plugin/pluginAPI.js
+39
-2
pluginManager.js
src/app/plugin/pluginManager.js
+2
-1
No files found.
src/app/editor/sourceHighlighter.js
View file @
00eba199
...
...
@@ -4,20 +4,6 @@ var globlalRegistry = require('../../global/registry')
var
styleGuide
=
require
(
'../ui/styles-guide/theme-chooser'
)
var
styles
=
styleGuide
.
chooser
()
var
css
=
csjs
`
.highlightcode {
position:absolute;
z-index:20;
background-color:
${
styles
.
editor
.
backgroundColor_DebuggerMode
}
;
}
.highlightcode_fullLine {
position:absolute;
z-index:20;
background-color:
${
styles
.
editor
.
backgroundColor_DebuggerMode
}
;
opacity: 0.5;
}
`
class
SourceHighlighter
{
constructor
(
localRegistry
)
{
const
self
=
this
...
...
@@ -38,16 +24,43 @@ class SourceHighlighter {
currentSourceLocation
(
lineColumnPos
,
location
)
{
if
(
this
.
statementMarker
)
this
.
_deps
.
editor
.
removeMarker
(
this
.
statementMarker
,
this
.
source
)
if
(
this
.
fullLineMarker
)
this
.
_deps
.
editor
.
removeMarker
(
this
.
fullLineMarker
,
this
.
source
)
if
(
location
&&
location
.
file
!==
undefined
)
{
var
path
=
this
.
_deps
.
compiler
.
getSourceName
(
location
.
file
)
if
(
path
)
{
this
.
currentSourceLocationFromfileName
(
lineColumnPos
,
path
)
}
}
}
currentSourceLocationFromfileName
(
lineColumnPos
,
filePath
,
style
)
{
if
(
this
.
statementMarker
)
this
.
_deps
.
editor
.
removeMarker
(
this
.
statementMarker
,
this
.
source
)
if
(
this
.
fullLineMarker
)
this
.
_deps
.
editor
.
removeMarker
(
this
.
fullLineMarker
,
this
.
source
)
this
.
statementMarker
=
null
this
.
fullLineMarker
=
null
this
.
source
=
null
if
(
lineColumnPos
)
{
this
.
source
=
this
.
_deps
.
compiler
.
getSourceName
(
location
.
file
)
this
.
source
=
filePath
if
(
this
.
_deps
.
config
.
get
(
'currentFile'
)
!==
this
.
source
)
{
this
.
_deps
.
fileManager
.
switchFile
(
this
.
source
)
}
var
css
=
csjs
`
.highlightcode {
position:absolute;
z-index:20;
background-color:
${
style
||
styles
.
editor
.
backgroundColor_DebuggerMode
}
;
}
.highlightcode_fullLine {
position:absolute;
z-index:20;
background-color:
${
style
||
styles
.
editor
.
backgroundColor_DebuggerMode
}
;
opacity: 0.5;
}
`
this
.
statementMarker
=
this
.
_deps
.
editor
.
addMarker
(
lineColumnPos
,
this
.
source
,
css
.
highlightcode
)
this
.
_deps
.
editor
.
scrollToLine
(
lineColumnPos
.
start
.
line
,
true
,
true
,
function
()
{})
if
(
lineColumnPos
.
start
.
line
===
lineColumnPos
.
end
.
line
)
{
this
.
fullLineMarker
=
this
.
_deps
.
editor
.
addMarker
({
start
:
{
...
...
src/app/panels/righthand-panel.js
View file @
00eba199
...
...
@@ -36,6 +36,7 @@ module.exports = class RighthandPanel {
self
.
_deps
=
{
fileProviders
:
self
.
_components
.
registry
.
get
(
'fileproviders'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
udapp
:
self
.
_components
.
registry
.
get
(
'udapp'
).
api
,
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
...
...
@@ -49,6 +50,7 @@ module.exports = class RighthandPanel {
self
.
_deps
.
compiler
,
self
.
_deps
.
txlistener
,
self
.
_deps
.
fileProviders
,
self
.
_deps
.
fileManager
,
self
.
_deps
.
udapp
)
...
...
src/app/plugin/pluginAPI.js
View file @
00eba199
'use strict'
var
executionContext
=
require
(
'../../execution-context'
)
var
SourceHighlighter
=
require
(
'../editor/sourceHighlighter'
)
/*
Defines available API. `key` / `type`
*/
module
.
exports
=
(
pluginManager
,
fileProviders
,
compiler
,
udapp
)
=>
{
module
.
exports
=
(
pluginManager
,
fileProviders
,
fileManager
,
compiler
,
udapp
)
=>
{
var
highlighter
=
new
SourceHighlighter
()
return
{
app
:
{
getExecutionContextProvider
:
(
mod
,
cb
)
=>
{
...
...
@@ -63,6 +64,42 @@ module.exports = (pluginManager, fileProviders, compiler, udapp) => {
cb
(
error
,
address
)
})
}
},
editor
:
{
getCurrentFile
:
(
mod
,
cb
)
=>
{
var
path
=
fileManager
.
currentPath
()
if
(
!
path
)
{
cb
(
'no file selected'
)
}
else
{
cb
(
null
,
path
)
}
},
getFile
:
(
mod
,
path
,
cb
)
=>
{
var
provider
=
fileManager
.
fileProviderOf
(
path
)
if
(
provider
)
{
// TODO add approval to user for external plugin to get the content of the given `path`
provider
.
get
(
mod
+
'/'
+
path
,
(
error
,
content
)
=>
{
cb
(
error
,
content
)
})
}
else
{
cb
(
path
+
' not available'
)
}
},
setFile
:
(
mod
,
path
,
content
,
cb
)
=>
{
var
provider
=
fileManager
.
fileProviderOf
(
path
)
if
(
provider
)
{
// TODO add approval to user for external plugin to set the content of the given `path`
provider
.
set
(
mod
+
'/'
+
path
,
content
,
(
error
)
=>
{
cb
(
error
)
})
}
else
{
cb
(
path
+
' not available'
)
}
},
highlight
:
(
mod
,
lineColumnPos
,
filePath
,
hexColor
,
cb
)
=>
{
highlighter
.
currentSourceLocation
(
null
)
highlighter
.
currentSourceLocation
(
lineColumnPos
,
filePath
,
hexColor
)
}
}
}
}
src/app/plugin/pluginManager.js
View file @
00eba199
...
...
@@ -78,11 +78,12 @@ const PluginAPI = require('./pluginAPI')
*
*/
module
.
exports
=
class
PluginManager
{
constructor
(
app
,
compiler
,
txlistener
,
fileProviders
,
udapp
)
{
constructor
(
app
,
compiler
,
txlistener
,
fileProviders
,
fileManager
,
udapp
)
{
const
self
=
this
var
pluginAPI
=
new
PluginAPI
(
this
,
fileProviders
,
fileManager
,
compiler
,
udapp
)
...
...
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