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
6c78ca56
Commit
6c78ca56
authored
Sep 26, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
highlight also dependencies
parent
4d86b8f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
app.js
src/app.js
+9
-6
contextualListener.js
src/app/editor/contextualListener.js
+14
-7
No files found.
src/app.js
View file @
6c78ca56
...
...
@@ -394,25 +394,28 @@ function run () {
getCompilationResult
:
()
=>
{
return
compiler
.
lastCompilationResult
},
getCurrentFile
:
()
=>
{
return
config
.
get
(
'currentFile'
)
},
highlight
:
(
position
,
node
)
=>
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
&&
compiler
.
lastCompilationResult
.
data
.
sourceList
[
position
.
file
]
===
config
.
get
(
'currentFile'
)
)
{
positio
n
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
var
lineColum
n
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
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
=
'highlightreferenceline'
positio
n
=
{
lineColum
n
=
{
start
:
{
line
:
positio
n
.
start
.
line
,
line
:
lineColum
n
.
start
.
line
,
column
:
0
},
end
:
{
line
:
positio
n
.
start
.
line
+
1
,
line
:
lineColum
n
.
start
.
line
+
1
,
column
:
0
}
}
}
return
editor
.
addMarker
(
position
,
config
.
get
(
'currentFile'
)
,
css
)
return
editor
.
addMarker
(
lineColumn
,
compiler
.
lastCompilationResult
.
data
.
sourceList
[
position
.
file
]
,
css
)
}
return
null
},
...
...
src/app/editor/contextualListener.js
View file @
6c78ca56
...
...
@@ -22,22 +22,27 @@ class ContextualListener {
}
})
events
.
editor
.
register
(
'sessionSwitched'
,
()
=>
{
this
.
_stopHighlighting
()
})
events
.
editor
.
register
(
'contentChanged'
,
()
=>
{
this
.
_stopHighlighting
()
})
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
astWalker
=
new
AstWalker
()
setInterval
(()
=>
{
this
.
_highlightItems
(
api
.
getCursorPosition
(),
api
.
getCompilationResult
())
this
.
_highlightItems
(
api
.
getCursorPosition
(),
api
.
getCompilationResult
()
,
api
.
getCurrentFile
()
)
},
1000
)
}
_highlightItems
(
cursorPosition
,
compilationResult
)
{
_highlightItems
(
cursorPosition
,
compilationResult
,
file
)
{
if
(
this
.
currentPosition
===
cursorPosition
)
return
if
(
this
.
currentFile
!==
file
)
{
this
.
currentFile
=
file
this
.
currentPosition
=
cursorPosition
return
}
this
.
_stopHighlighting
()
this
.
currentPosition
=
cursorPosition
if
(
compilationResult
&&
compilationResult
.
data
&&
compilationResult
.
source
)
{
var
nodes
=
this
.
sourceMappingDecoder
.
nodesAtPosition
(
null
,
cursorPosition
,
compilationResult
.
data
.
sources
[
compilationResult
.
source
.
target
])
this
.
currentFile
=
file
if
(
compilationResult
&&
compilationResult
.
data
&&
compilationResult
.
data
.
sources
[
file
])
{
var
nodes
=
this
.
sourceMappingDecoder
.
nodesAtPosition
(
null
,
cursorPosition
,
compilationResult
.
data
.
sources
[
file
])
if
(
nodes
&&
nodes
.
length
&&
nodes
[
nodes
.
length
-
1
])
{
this
.
_highlightExpressions
(
nodes
[
nodes
.
length
-
1
],
compilationResult
)
}
...
...
@@ -58,7 +63,9 @@ class ContextualListener {
self
.
_index
[
'FlatReferences'
][
node
.
id
]
=
node
return
true
}
this
.
astWalker
.
walk
(
compilationResult
.
sources
[
source
.
target
].
AST
,
callback
)
for
(
var
s
in
compilationResult
.
sources
)
{
this
.
astWalker
.
walk
(
compilationResult
.
sources
[
s
].
AST
,
callback
)
}
}
}
...
...
@@ -67,7 +74,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
:
compilationResult
.
source
.
target
})
this
.
_activeHighlights
.
push
({
eventId
,
position
,
fileTarget
:
compilationResult
.
data
.
sourceList
[
position
.
file
]
})
}
}
...
...
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