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
6e83b2a4
Commit
6e83b2a4
authored
Sep 25, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- reset if edtior content changed
- highlight also the declaration
parent
1aa49cc0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
18 deletions
+43
-18
browser-solidity.css
assets/css/browser-solidity.css
+16
-2
app.js
src/app.js
+4
-3
contextualListener.js
src/app/editor/contextualListener.js
+23
-13
No files found.
assets/css/browser-solidity.css
View file @
6e83b2a4
...
@@ -290,11 +290,25 @@ input[type="file"] {
...
@@ -290,11 +290,25 @@ input[type="file"] {
display
:
none
;
display
:
none
;
}
}
.highlight
call
{
.highlight
reference
{
position
:
absolute
;
position
:
absolute
;
z-index
:
20
;
z-index
:
20
;
background-color
:
lightgrey
;
background-color
:
lightgrey
;
opacity
:
0.5
opacity
:
0.7
}
.highlightdeclaration
{
position
:
absolute
;
z-index
:
20
;
background-color
:
lightgrey
;
opacity
:
0.4
}
.highlightcurrent
{
position
:
absolute
;
z-index
:
20
;
background-color
:
lightgrey
;
opacity
:
0.4
}
}
.highlightcode
{
.highlightcode
{
...
...
src/app.js
View file @
6e83b2a4
...
@@ -394,10 +394,10 @@ function run () {
...
@@ -394,10 +394,10 @@ function run () {
getCompilationResult
:
()
=>
{
getCompilationResult
:
()
=>
{
return
compiler
.
lastCompilationResult
return
compiler
.
lastCompilationResult
},
},
highlight
:
(
position
,
node
)
=>
{
highlight
:
(
position
,
node
,
type
)
=>
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
source
&&
compiler
.
lastCompilationResult
.
source
.
target
===
config
.
get
(
'currentFile'
))
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
source
&&
compiler
.
lastCompilationResult
.
source
.
target
===
config
.
get
(
'currentFile'
))
{
position
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
position
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
return
editor
.
addMarker
(
position
,
config
.
get
(
'currentFile'
),
'highlight
call'
)
return
editor
.
addMarker
(
position
,
config
.
get
(
'currentFile'
),
'highlight
'
+
type
)
}
}
return
null
return
null
},
},
...
@@ -405,7 +405,8 @@ function run () {
...
@@ -405,7 +405,8 @@ function run () {
editor
.
removeMarker
(
event
.
eventId
,
event
.
fileTarget
)
editor
.
removeMarker
(
event
.
eventId
,
event
.
fileTarget
)
}
}
},
{
},
{
compiler
:
compiler
.
event
compiler
:
compiler
.
event
,
editor
:
editor
.
event
})
})
// ----------------- Renderer -----------------
// ----------------- Renderer -----------------
...
...
src/app/editor/contextualListener.js
View file @
6e83b2a4
...
@@ -7,7 +7,7 @@ class ContextualListener {
...
@@ -7,7 +7,7 @@ class ContextualListener {
this
.
_api
=
api
this
.
_api
=
api
this
.
_index
=
{
this
.
_index
=
{
Declarations
:
{},
Declarations
:
{},
References
:
[]
FlatReferences
:
{}
}
}
this
.
_events
=
[]
this
.
_events
=
[]
...
@@ -15,20 +15,24 @@ class ContextualListener {
...
@@ -15,20 +15,24 @@ class ContextualListener {
this
.
_stopHighlighting
()
this
.
_stopHighlighting
()
this
.
_index
=
{
this
.
_index
=
{
Declarations
:
{},
Declarations
:
{},
References
:
[]
FlatReferences
:
{}
}
}
if
(
success
)
{
if
(
success
)
{
this
.
_buildIndex
(
data
,
source
)
this
.
_buildIndex
(
data
,
source
)
}
}
})
})
events
.
editor
.
register
(
'sessionSwitched'
,
()
=>
{
this
.
_stopHighlighting
()
})
events
.
editor
.
register
(
'contentChanged'
,
()
=>
{
this
.
_stopHighlighting
()
})
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
astWalker
=
new
AstWalker
()
this
.
astWalker
=
new
AstWalker
()
setInterval
(()
=>
{
setInterval
(()
=>
{
this
.
_highlight
(
api
.
getCursorPosition
(),
api
.
getCompilationResult
())
this
.
_highlight
Items
(
api
.
getCursorPosition
(),
api
.
getCompilationResult
())
},
1000
)
},
1000
)
}
}
_highlight
(
cursorPosition
,
compilationResult
)
{
_highlight
Items
(
cursorPosition
,
compilationResult
)
{
if
(
this
.
currentPosition
===
cursorPosition
)
return
if
(
this
.
currentPosition
===
cursorPosition
)
return
this
.
_stopHighlighting
()
this
.
_stopHighlighting
()
this
.
currentPosition
=
cursorPosition
this
.
currentPosition
=
cursorPosition
...
@@ -50,33 +54,39 @@ class ContextualListener {
...
@@ -50,33 +54,39 @@ class ContextualListener {
self
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
]
=
[]
self
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
]
=
[]
}
}
self
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
].
push
(
node
)
self
.
_index
[
'Declarations'
][
node
.
attributes
.
referencedDeclaration
].
push
(
node
)
self
.
_index
[
'References'
].
push
(
node
)
}
}
self
.
_index
[
'FlatReferences'
][
node
.
id
]
=
node
return
true
return
true
}
}
this
.
astWalker
.
walk
(
compilationResult
.
sources
[
source
.
target
].
AST
,
callback
)
this
.
astWalker
.
walk
(
compilationResult
.
sources
[
source
.
target
].
AST
,
callback
)
}
}
}
}
_highlight
(
node
,
compilationResult
,
type
)
{
var
position
=
this
.
sourceMappingDecoder
.
decode
(
node
.
src
)
var
eventId
=
this
.
_api
.
highlight
(
position
,
node
,
type
)
if
(
eventId
)
{
this
.
_events
.
push
({
eventId
,
position
,
fileTarget
:
compilationResult
.
source
.
target
})
}
}
_hightlightExpressions
(
node
,
compilationResult
)
{
_hightlightExpressions
(
node
,
compilationResult
)
{
var
self
=
this
var
self
=
this
function
highlight
(
id
)
{
function
highlight
s
(
id
)
{
if
(
self
.
_index
[
'Declarations'
]
&&
self
.
_index
[
'Declarations'
][
id
])
{
if
(
self
.
_index
[
'Declarations'
]
&&
self
.
_index
[
'Declarations'
][
id
])
{
var
calls
=
self
.
_index
[
'Declarations'
][
id
]
var
calls
=
self
.
_index
[
'Declarations'
][
id
]
for
(
var
call
in
calls
)
{
for
(
var
call
in
calls
)
{
var
node
=
calls
[
call
]
var
node
=
calls
[
call
]
var
position
=
self
.
sourceMappingDecoder
.
decode
(
node
.
src
)
self
.
_highlight
(
node
,
compilationResult
,
'reference'
)
var
eventId
=
self
.
_api
.
highlight
(
position
,
node
)
if
(
eventId
)
{
self
.
_events
.
push
({
eventId
,
position
,
fileTarget
:
compilationResult
.
source
.
target
})
}
}
}
}
}
}
}
if
(
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
if
(
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
highlight
(
node
.
attributes
.
referencedDeclaration
)
highlights
(
node
.
attributes
.
referencedDeclaration
)
var
current
=
this
.
_index
[
'FlatReferences'
][
node
.
attributes
.
referencedDeclaration
]
this
.
_highlight
(
current
,
compilationResult
,
'declaration'
)
}
else
{
}
else
{
highlight
(
node
.
id
)
highlight
s
(
node
.
id
,
'current'
)
}
}
}
}
...
...
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