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
6e8e7af9
Commit
6e8e7af9
authored
Dec 06, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify Jump next/previous
parent
2f087c98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
39 deletions
+26
-39
contextView.js
src/app/editor/contextView.js
+26
-39
No files found.
src/app/editor/contextView.js
View file @
6e8e7af9
...
@@ -59,6 +59,7 @@ class ContextView {
...
@@ -59,6 +59,7 @@ class ContextView {
this
.
_nodes
this
.
_nodes
this
.
_current
this
.
_current
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
previousElement
=
null
event
.
contextualListener
.
register
(
'contextChanged'
,
nodes
=>
{
event
.
contextualListener
.
register
(
'contextChanged'
,
nodes
=>
{
this
.
_nodes
=
nodes
this
.
_nodes
=
nodes
this
.
update
()
this
.
update
()
...
@@ -98,7 +99,7 @@ class ContextView {
...
@@ -98,7 +99,7 @@ class ContextView {
}
}
_renderTarget
()
{
_renderTarget
()
{
this
.
_current
=
null
var
previous
=
this
.
_current
if
(
this
.
_nodes
&&
this
.
_nodes
.
length
)
{
if
(
this
.
_nodes
&&
this
.
_nodes
.
length
)
{
var
last
=
this
.
_nodes
[
this
.
_nodes
.
length
-
1
]
var
last
=
this
.
_nodes
[
this
.
_nodes
.
length
-
1
]
if
(
isDefinition
(
last
))
{
if
(
isDefinition
(
last
))
{
...
@@ -107,64 +108,50 @@ class ContextView {
...
@@ -107,64 +108,50 @@ class ContextView {
var
target
=
this
.
_api
.
contextualListener
.
declarationOf
(
last
)
var
target
=
this
.
_api
.
contextualListener
.
declarationOf
(
last
)
if
(
target
)
{
if
(
target
)
{
this
.
_current
=
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>`
if
(
!
node
)
return
yo
`<div></div>`
var
self
=
this
var
self
=
this
var
references
=
this
.
_api
.
contextualListener
.
referencesOf
(
node
)
var
references
=
this
.
_api
.
contextualListener
.
referencesOf
(
node
)
var
type
=
node
.
attributes
.
type
?
node
.
attributes
.
type
:
node
.
name
var
type
=
node
.
attributes
.
type
?
node
.
attributes
.
type
:
node
.
name
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
references
=
`
${
references
?
references
.
length
:
'0'
}
reference(s)`
function
jumpTo
()
{
var
ref
=
0
if
(
node
&&
node
.
src
)
{
var
nodes
=
self
.
_api
.
contextualListener
.
getActiveHighlights
()
var
position
=
self
.
sourceMappingDecoder
.
decode
(
node
.
src
)
for
(
var
k
in
nodes
)
{
if
(
position
)
{
if
(
nodeAtCursorPosition
.
id
===
nodes
[
k
].
nodeId
)
{
self
.
_api
.
jumpTo
(
position
)
ref
=
k
}
break
}
}
}
}
// JUMP BETWEEN REFERENCES
// JUMP BETWEEN REFERENCES
function
jump
(
e
)
{
function
jump
(
e
)
{
var
nodes
=
self
.
_api
.
contextualListener
.
getActiveHighlights
()
e
.
target
.
dataset
.
action
===
'next'
?
ref
++
:
ref
--
var
searchTerm
=
node
.
attributes
.
name
if
(
ref
<
0
)
ref
=
nodes
.
length
-
1
var
currentAction
=
e
.
target
.
dataset
.
action
if
(
ref
>=
nodes
.
length
)
ref
=
0
self
.
_api
.
jumpTo
(
nodes
[
ref
].
position
)
if
(
currentAction
===
'next'
)
{
next
(
searchTerm
,
nodes
,
currentAction
)
}
else
if
(
currentAction
===
'previous'
)
{
previous
(
searchTerm
,
nodes
,
currentAction
)
}
self
.
refName
=
searchTerm
self
.
action
=
currentAction
}
function
next
(
searchTerm
,
nodes
,
currentAction
)
{
if
(
searchTerm
!==
self
.
refName
)
self
.
ref
=
0
if
(
currentAction
!==
self
.
action
)
self
.
ref
=
(
nodes
.
length
-
1
)
-
self
.
ref
// adapting self.ref to switching between previous() and next()
self
.
ref
=
(
self
.
ref
+
1
)
%
nodes
.
length
self
.
_api
.
jumpTo
(
getPos
(
nodes
,
self
.
ref
))
}
function
previous
(
searchTerm
,
nodes
,
currentAction
)
{
if
(
searchTerm
!==
self
.
refName
)
self
.
ref
=
nodes
.
length
-
1
if
(
currentAction
!==
self
.
action
)
self
.
ref
=
(
nodes
.
length
-
1
)
-
self
.
ref
// adapting self.ref to switching between previous() and next()
self
.
ref
=
(
self
.
ref
+
1
)
%
nodes
.
length
self
.
_api
.
jumpTo
(
getPos
(
nodes
,
nodes
.
length
-
1
-
self
.
ref
))
}
}
function
getPos
(
nodes
,
k
)
{
function
jumpTo
()
{
var
i
=
(
k
+
(
nodes
.
length
-
1
))
%
nodes
.
length
// to get to nodes[0] position, jumpTo function needs nodes[node.length-1], for nodes[1], jumpTo(nodes[0].position) etc.
if
(
node
&&
node
.
src
)
{
return
nodes
[
i
].
position
var
position
=
self
.
sourceMappingDecoder
.
decode
(
node
.
src
)
if
(
position
)
{
self
.
_api
.
jumpTo
(
position
)
}
}
}
}
return
yo
`<div class=
${
css
.
line
}
>
return
yo
`<div class=
${
css
.
line
}
>
<div title=
${
type
}
class=
${
css
.
type
}
>
${
type
}
</div>
<div title=
${
type
}
class=
${
css
.
type
}
>
${
type
}
</div>
<div title=
${
node
.
attributes
.
name
}
class=
${
css
.
name
}
>
${
node
.
attributes
.
name
}
</div>
<div title=
${
node
.
attributes
.
name
}
class=
${
css
.
name
}
>
${
node
.
attributes
.
name
}
</div>
...
...
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