Commit 8be16b1f authored by yann300's avatar yann300

highlight entire line if contains children

parent 6e83b2a4
...@@ -297,20 +297,6 @@ input[type="file"] { ...@@ -297,20 +297,6 @@ input[type="file"] {
opacity: 0.7 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 {
position:absolute; position:absolute;
z-index:20; z-index:20;
......
...@@ -394,10 +394,22 @@ function run () { ...@@ -394,10 +394,22 @@ function run () {
getCompilationResult: () => { getCompilationResult: () => {
return compiler.lastCompilationResult return compiler.lastCompilationResult
}, },
highlight: (position, node, type) => { highlight: (position, node) => {
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' + type) if (node.children && node.children.length) {
position = {
start: {
line: position.start.line,
column: 0
},
end: {
line: position.start.line + 1,
column: 0
}
}
}
return editor.addMarker(position, config.get('currentFile'), 'highlightreference')
} }
return null return null
}, },
......
...@@ -62,9 +62,10 @@ class ContextualListener { ...@@ -62,9 +62,10 @@ class ContextualListener {
} }
} }
_highlight (node, compilationResult, type) { _highlight (node, compilationResult) {
var position = this.sourceMappingDecoder.decode(node.src) var src = node.src
var eventId = this._api.highlight(position, node, type) var position = this.sourceMappingDecoder.decode(src)
var eventId = this._api.highlight(position, node)
if (eventId) { if (eventId) {
this._events.push({ eventId, position, fileTarget: compilationResult.source.target }) this._events.push({ eventId, position, fileTarget: compilationResult.source.target })
} }
...@@ -77,16 +78,16 @@ class ContextualListener { ...@@ -77,16 +78,16 @@ class ContextualListener {
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]
self._highlight(node, compilationResult, 'reference') self._highlight(node, compilationResult)
} }
} }
} }
if (node.attributes && node.attributes.referencedDeclaration) { if (node.attributes && node.attributes.referencedDeclaration) {
highlights(node.attributes.referencedDeclaration) highlights(node.attributes.referencedDeclaration)
var current = this._index['FlatReferences'][node.attributes.referencedDeclaration] var current = this._index['FlatReferences'][node.attributes.referencedDeclaration]
this._highlight(current, compilationResult, 'declaration') this._highlight(current, compilationResult)
} else { } else if (node && node.name && node.name !== 'FunctionDefinition' && node.name !== 'ContractDefinition' && node.name !== 'Block') {
highlights(node.id, 'current') highlights(node.id)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment