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
403b82f3
Unverified
Commit
403b82f3
authored
Dec 06, 2017
by
yann300
Committed by
GitHub
Dec 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #930 from ethereum/ide2
More IDE/editor Features
parents
b7b09951
6e8e7af9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
16 deletions
+51
-16
app.js
src/app.js
+2
-2
contextView.js
src/app/editor/contextView.js
+35
-10
contextualListener.js
src/app/editor/contextualListener.js
+10
-2
editor.js
src/app/editor/editor.js
+3
-1
mode-solidity.js
src/app/editor/mode-solidity.js
+1
-1
No files found.
src/app.js
View file @
403b82f3
...
...
@@ -319,7 +319,7 @@ function run () {
var
css
=
'highlightreference'
if
(
node
.
children
&&
node
.
children
.
length
)
{
// If node has children, highlight the entire line. if not, just highlight the current source position of the node.
css
=
'highlightreference
line
'
css
=
'highlightreference'
lineColumn
=
{
start
:
{
line
:
lineColumn
.
start
.
line
,
...
...
@@ -357,7 +357,7 @@ function run () {
fileManager
.
switchFile
(
filename
)
}
if
(
lineColumn
.
start
&&
lineColumn
.
start
.
line
&&
lineColumn
.
start
.
column
)
{
editor
.
gotoLine
(
lineColumn
.
start
.
line
,
lineColumn
.
start
.
column
+
1
)
editor
.
gotoLine
(
lineColumn
.
start
.
line
,
lineColumn
.
end
.
column
+
1
)
}
}
}
...
...
src/app/editor/contextView.js
View file @
403b82f3
...
...
@@ -29,18 +29,18 @@ var css = csjs`
}
.name {
font-weight : bold;
margin-right : 15px;
}
.jump
to
{
.jump
{
cursor : pointer;
margin
-right :
5px;
margin
: 0
5px;
color :
${
styles
.
editor
.
icon_Color_Editor
}
;
}
jumpto:hover
{
.jump:hover
{
color :
${
styles
.
editor
.
icon_HoverColor_Editor
}
;
}
.referencesnb {
float : right;
margin-left : 15px;
}
`
...
...
@@ -59,6 +59,7 @@ class ContextView {
this
.
_nodes
this
.
_current
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
previousElement
=
null
event
.
contextualListener
.
register
(
'contextChanged'
,
nodes
=>
{
this
.
_nodes
=
nodes
this
.
update
()
...
...
@@ -98,7 +99,7 @@ class ContextView {
}
_renderTarget
()
{
this
.
_current
=
null
var
previous
=
this
.
_current
if
(
this
.
_nodes
&&
this
.
_nodes
.
length
)
{
var
last
=
this
.
_nodes
[
this
.
_nodes
.
length
-
1
]
if
(
isDefinition
(
last
))
{
...
...
@@ -107,19 +108,41 @@ class ContextView {
var
target
=
this
.
_api
.
contextualListener
.
declarationOf
(
last
)
if
(
target
)
{
this
.
_current
=
target
}
else
{
this
.
_current
=
last
}
}
}
return
this
.
_render
(
this
.
_current
)
if
(
!
this
.
_current
||
!
previous
||
previous
.
id
!==
this
.
_current
.
id
)
{
this
.
previousElement
=
this
.
_render
(
this
.
_current
,
last
)
}
return
this
.
previousElement
}
_render
(
node
)
{
_render
(
node
,
nodeAtCursorPosition
)
{
if
(
!
node
)
return
yo
`<div></div>`
var
self
=
this
var
references
=
this
.
_api
.
contextualListener
.
referencesOf
(
node
)
var
type
=
node
.
attributes
.
type
?
node
.
attributes
.
type
:
node
.
name
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
var
ref
=
0
var
nodes
=
self
.
_api
.
contextualListener
.
getActiveHighlights
()
for
(
var
k
in
nodes
)
{
if
(
nodeAtCursorPosition
.
id
===
nodes
[
k
].
nodeId
)
{
ref
=
k
break
}
}
// JUMP BETWEEN REFERENCES
function
jump
(
e
)
{
e
.
target
.
dataset
.
action
===
'next'
?
ref
++
:
ref
--
if
(
ref
<
0
)
ref
=
nodes
.
length
-
1
if
(
ref
>=
nodes
.
length
)
ref
=
0
self
.
_api
.
jumpTo
(
nodes
[
ref
].
position
)
}
function
jumpTo
()
{
if
(
node
&&
node
.
src
)
{
var
position
=
self
.
sourceMappingDecoder
.
decode
(
node
.
src
)
...
...
@@ -130,10 +153,12 @@ class ContextView {
}
return
yo
`<div class=
${
css
.
line
}
>
<div title=
${
type
}
class=
${
css
.
type
}
>
${
type
}
</div>
<div title=
${
node
.
attributes
.
name
}
class=
${
css
.
name
}
>
${
node
.
attributes
.
name
}
</div>
<i
title='Go to Definition' class="fa fa-share
${
css
.
jumpto
}
" aria-hidden="true" onclick=
${
jumpTo
}
></i>
<div title=
${
type
}
class=
${
css
.
type
}
>
${
type
}
</div>
<div title=
${
node
.
attributes
.
name
}
class=
${
css
.
name
}
>
${
node
.
attributes
.
name
}
</div>
<i
class="fa fa-share
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jumpTo
}
></i>
<span class=
${
css
.
referencesnb
}
>
${
references
}
</span>
<i data-action='previous' class="fa fa-chevron-up
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jump
}
></i>
<i data-action='next' class="fa fa-chevron-down
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jump
}
></i>
</div>`
}
}
...
...
src/app/editor/contextualListener.js
View file @
403b82f3
...
...
@@ -37,6 +37,13 @@ class ContextualListener {
},
1000
)
}
getActiveHighlights
()
{
return
[...
this
.
_activeHighlights
]
// return [...this._activeHighlights].sort((a,b) => {
// return a.position.start - b.position.start
// })
}
declarationOf
(
node
)
{
if
(
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
return
this
.
_index
[
'FlatReferences'
][
node
.
attributes
.
referencedDeclaration
]
...
...
@@ -60,10 +67,10 @@ class ContextualListener {
this
.
currentFile
=
file
if
(
compilationResult
&&
compilationResult
.
data
&&
compilationResult
.
data
.
sources
[
file
])
{
var
nodes
=
this
.
sourceMappingDecoder
.
nodesAtPosition
(
null
,
cursorPosition
,
compilationResult
.
data
.
sources
[
file
])
this
.
event
.
trigger
(
'contextChanged'
,
[
nodes
])
if
(
nodes
&&
nodes
.
length
&&
nodes
[
nodes
.
length
-
1
])
{
this
.
_highlightExpressions
(
nodes
[
nodes
.
length
-
1
],
compilationResult
)
}
this
.
event
.
trigger
(
'contextChanged'
,
[
nodes
])
}
}
...
...
@@ -92,7 +99,7 @@ class ContextualListener {
var
position
=
this
.
sourceMappingDecoder
.
decode
(
node
.
src
)
var
eventId
=
this
.
_api
.
highlight
(
position
,
node
)
if
(
eventId
)
{
this
.
_activeHighlights
.
push
({
eventId
,
position
,
fileTarget
:
this
.
_api
.
getSourceName
(
position
.
file
)
})
this
.
_activeHighlights
.
push
({
eventId
,
position
,
fileTarget
:
this
.
_api
.
getSourceName
(
position
.
file
)
,
nodeId
:
node
.
id
})
}
}
...
...
@@ -113,6 +120,7 @@ class ContextualListener {
this
.
_highlight
(
current
,
compilationResult
)
}
else
{
highlights
(
node
.
id
)
this
.
_highlight
(
node
,
compilationResult
)
}
}
...
...
src/app/editor/editor.js
View file @
403b82f3
...
...
@@ -6,6 +6,7 @@ var csjs = require('csjs-inject')
var
ace
=
require
(
'brace'
)
var
Range
=
ace
.
acequire
(
'ace/range'
).
Range
require
(
'brace/ext/language_tools'
)
require
(
'brace/ext/searchbox'
)
var
langTools
=
ace
.
acequire
(
'ace/ext/language_tools'
)
require
(
'./mode-solidity.js'
)
var
styleGuide
=
remixLib
.
ui
.
styleGuide
...
...
@@ -225,6 +226,8 @@ function Editor (opts = {}) {
editor
.
gotoLine
(
line
+
1
,
col
-
1
,
true
)
}
this
.
find
=
(
string
)
=>
editor
.
find
(
string
)
// Do setup on initialisation here
editor
.
on
(
'changeSession'
,
function
()
{
event
.
trigger
(
'sessionSwitched'
,
[])
...
...
@@ -236,7 +239,6 @@ function Editor (opts = {}) {
// Unmap ctrl-t & ctrl-f
editor
.
commands
.
bindKeys
({
'ctrl-t'
:
null
})
editor
.
commands
.
bindKeys
({
'ctrl-f'
:
null
})
editor
.
resize
(
true
)
}
...
...
src/app/editor/mode-solidity.js
View file @
403b82f3
...
...
@@ -68,7 +68,7 @@ var JavaScriptHighlightRules = function(options) {
"contract|library|constant|event|modifier|"
+
"struct|mapping|enum|break|continue|delete|else|for|function|"
+
"if|new|return|returns|var|while|using|"
+
"private|public|external|internal|storage|memory"
,
"private|public|external|internal|storage|memory
|payable|view|pure|
"
,
"storage.type"
:
"constant|var|function"
,
"constant.language.boolean"
:
"true|false"
...
...
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