|
|
@ -29,18 +29,18 @@ var css = csjs` |
|
|
|
} |
|
|
|
} |
|
|
|
.name { |
|
|
|
.name { |
|
|
|
font-weight : bold; |
|
|
|
font-weight : bold; |
|
|
|
margin-right : 15px; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
.jumpto { |
|
|
|
.jump { |
|
|
|
cursor : pointer; |
|
|
|
cursor : pointer; |
|
|
|
margin-right : 5px; |
|
|
|
margin : 0 5px; |
|
|
|
color : ${styles.editor.icon_Color_Editor}; |
|
|
|
color : ${styles.editor.icon_Color_Editor}; |
|
|
|
} |
|
|
|
} |
|
|
|
jumpto:hover { |
|
|
|
.jump:hover { |
|
|
|
color : ${styles.editor.icon_HoverColor_Editor}; |
|
|
|
color : ${styles.editor.icon_HoverColor_Editor}; |
|
|
|
} |
|
|
|
} |
|
|
|
.referencesnb { |
|
|
|
.referencesnb { |
|
|
|
float : right; |
|
|
|
float : right; |
|
|
|
|
|
|
|
margin-left : 15px; |
|
|
|
} |
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
@ -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 { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_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,19 +108,41 @@ 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)` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 () { |
|
|
|
function jumpTo () { |
|
|
|
if (node && node.src) { |
|
|
|
if (node && node.src) { |
|
|
|
var position = self.sourceMappingDecoder.decode(node.src) |
|
|
|
var position = self.sourceMappingDecoder.decode(node.src) |
|
|
@ -132,8 +155,10 @@ class ContextView { |
|
|
|
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> |
|
|
|
<i title='Go to Definition' class="fa fa-share ${css.jumpto}" aria-hidden="true" onclick=${jumpTo}></i> |
|
|
|
<i class="fa fa-share ${css.jump}" aria-hidden="true" onclick=${jumpTo}></i> |
|
|
|
<span class=${css.referencesnb}>${references}</span> |
|
|
|
<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>` |
|
|
|
</div>` |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|