highlight the scope

pull/3/head
LianaHus 5 years ago committed by Liana Husikyan
parent 6a9632e840
commit 1f6267d900
  1. 1
      src/app/editor/sourceHighlighter.js
  2. 6
      src/app/tabs/staticanalysis/staticAnalysisView.js
  3. 19
      src/app/ui/renderer.js

@ -47,6 +47,7 @@ class SourceHighlighter {
.highlightcode {
position:absolute;
z-index:20;
opacity: 0.2;
background-color: ${style || 'var(--info)'};
}
.highlightcode_fullLine {

@ -6,6 +6,7 @@ var remixLib = require('remix-lib')
var utils = remixLib.util
var css = require('./styles/staticAnalysisView-styles')
var Renderer = require('../../ui/renderer')
const SourceHighlighter = require('../../editor/sourceHighlighter')
var EventManager = require('../../../lib/events')
@ -18,6 +19,7 @@ function staticAnalysisView (localRegistry, analysisModule) {
this.lastCompilationResult = null
this.lastCompilationSource = null
this.currentFile = 'No file compiled'
this.sourceHighlighter = new SourceHighlighter()
self._components = {
renderer: new Renderer()
}
@ -105,6 +107,9 @@ staticAnalysisView.prototype.run = function () {
if (!this.view) {
return
}
const highlightLocation = (location, fileName) => {
this.sourceHighlighter.currentSourceLocationFromfileName(location, fileName)
}
const selected = this.selectedModules()
const warningContainer = $('#staticanalysisresult')
warningContainer.empty()
@ -169,6 +174,7 @@ staticAnalysisView.prototype.run = function () {
msg,
this.view.querySelector(`[id="staticAnalysisModule${moduleName}"]`),
{
click: () => highlightLocation(location, fileName),
type: 'warning',
useSpan: true,
errFile: fileName,

@ -55,7 +55,18 @@ Renderer.prototype._errorClick = function (errFile, errLine, errCol) {
*
* @param {String or DOMElement} message
* @param {DOMElement} container
* @param {Object} options {useSpan, noAnnotations, click:(Function), type:(warning, error, staticAnalysisWarning), errFile, errLine, errCol}
* @param {Object} options {
* useSpan,
* noAnnotations,
* click:(Function),
* type:(
* warning,
* error
* ),
* errFile,
* errLine,
* errCol
* }
*/
Renderer.prototype.error = function (message, container, opt) {
if (!message) return
@ -94,10 +105,10 @@ Renderer.prototype.error = function (message, container, opt) {
$(container).append($error)
$error.click((ev) => {
if (opt.errFile && opt.errLine && opt.errCol) {
this._errorClick(opt.errFile, opt.errLine, opt.errCol)
} else if (opt.click) {
if (opt.click) {
opt.click(message)
} else if (opt.errFile && opt.errLine && opt.errCol) {
this._errorClick(opt.errFile, opt.errLine, opt.errCol)
}
})

Loading…
Cancel
Save