From a0371f21d91dbac7dad903c4e707ee8546d05853 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 27 May 2020 19:57:45 +0200 Subject: [PATCH] use SourceHighlighters plugin in StaticAnalisys and remove multiple highligh for same position --- src/app/editor/SourceHighlighters.js | 11 +++++++++-- src/app/tabs/staticanalysis/staticAnalysisView.js | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/editor/SourceHighlighters.js b/src/app/editor/SourceHighlighters.js index 7560d2832b..7bd678148c 100644 --- a/src/app/editor/SourceHighlighters.js +++ b/src/app/editor/SourceHighlighters.js @@ -14,8 +14,15 @@ class SourceHighlighters { try { if (!this.highlighters[from]) this.highlighters[from] = [] const sourceHighlight = new SourceHighlighter() - sourceHighlight.currentSourceLocationFromfileName(position, filePath, hexColor) - this.highlighters[from].push(sourceHighlight) + if ( + !this.highlighters[from].length || + (this.highlighters[from].length && !this.highlighters[from].find((el) => { + return el.source === filePath && el.position === position + })) + ) { + sourceHighlight.currentSourceLocationFromfileName(position, filePath, hexColor) + this.highlighters[from].push(sourceHighlight) + } } catch (e) { throw e } diff --git a/src/app/tabs/staticanalysis/staticAnalysisView.js b/src/app/tabs/staticanalysis/staticAnalysisView.js index f861b93710..2723c73754 100644 --- a/src/app/tabs/staticanalysis/staticAnalysisView.js +++ b/src/app/tabs/staticanalysis/staticAnalysisView.js @@ -108,9 +108,9 @@ staticAnalysisView.prototype.run = function () { if (!this.view) { return } - const highlightLocation = (location, fileName) => { - // await this.analysisModule.call('editor', 'highlight', location, fileName) @todo(#2834) use this after fixing the issue - this.sourceHighlighter.currentSourceLocationFromfileName(location, fileName) + const highlightLocation = async (location, fileName) => { + await this.analysisModule.call('editor', 'discardHighlight') + await this.analysisModule.call('editor', 'highlight', location, fileName) } const selected = this.selectedModules() const warningContainer = $('#staticanalysisresult')