From f54380ff2a91f28a945e0ca0b0b091a092dfe399 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Fri, 19 Aug 2022 11:48:54 +0200 Subject: [PATCH] marker severity --- .../parser/services/code-parser-compiler.ts | 14 +++++++------- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 8 ++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts index b91d617f10..4a31356052 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts @@ -2,7 +2,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity' import { Compiler } from '@remix-project/remix-solidity' -import { CompilationError, CompilationResult, CompilationSource } from '@remix-project/remix-solidity' +import { CompilationResult, CompilationSource } from '@remix-project/remix-solidity' import { CodeParser } from "../code-parser"; import { fileDecoration, fileDecorationType } from '@remix-ui/file-decorators' import { sourceMappingDecoder } from '@remix-project/remix-debug' @@ -57,7 +57,7 @@ export default class CodeParserCompiler { allErrors = [...allErrors, { message: error.formattedMessage, - severity: error.severity, + severity: error.severity === 'error' ? MarkerSeverity.Error : MarkerSeverity.Warning, position: { start: { line: ((lineColumn.start && lineColumn.start.line) || 0) + 1, @@ -150,7 +150,7 @@ export default class CodeParserCompiler { async addDecorators(allErrors: errorMarker[], sources: any) { const displayErrors = await this.plugin.call('config', 'getAppParameter', 'display-errors') if(!displayErrors) return - const errorsPerFiles = {} + const errorsPerFiles: {[fileName: string]: errorMarker[]} = {} for (const error of allErrors) { if (!errorsPerFiles[error.file]) { errorsPerFiles[error.file] = [] @@ -164,7 +164,7 @@ export default class CodeParserCompiler { } // sort errorPerFiles by error priority - const sortedErrorsPerFiles = {} + const sortedErrorsPerFiles: {[fileName: string]: errorMarker[]} = {} for (const fileName in errorsPerFiles) { const errors = errorsPerFiles[fileName] errors.sort((a, b) => { @@ -181,11 +181,11 @@ export default class CodeParserCompiler { const decorator: fileDecoration = { path: fileName, isDirectory: false, - fileStateType: errors[0].severity === 'error' ? fileDecorationType.Error : fileDecorationType.Warning, - fileStateLabelClass: errors[0].severity === 'error' ? 'text-danger' : 'text-warning', + fileStateType: errors[0].severity == MarkerSeverity.Error? fileDecorationType.Error : fileDecorationType.Warning, + fileStateLabelClass: errors[0].severity == MarkerSeverity.Error ? 'text-danger' : 'text-warning', fileStateIconClass: '', fileStateIcon: '', - text: errors.length, + text: errors.length.toString(), owner: 'code-parser', bubble: true, comment: errors.map((error) => error.message), diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 2429c218cf..d2a287b803 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -421,14 +421,10 @@ export const EditorUI = (props: EditorUIProps) => { const fileFromUrl = await props.plugin.call('fileManager', 'getPathFromUrl', filePath) filePath = fileFromUrl.file const model = editorModelsState[filePath]?.model - const errorServerityMap = { - 'error': MarkerSeverity.Error, - 'warning': MarkerSeverity.Warning, - 'info': MarkerSeverity.Info - } + if (model) { const markerData: monaco.editor.IMarkerData = { - severity: errorServerityMap[error.severity], + severity: error.severity, startLineNumber: ((error.position.start && error.position.start.line) || 0), startColumn: ((error.position.start && error.position.start.column) || 0), endLineNumber: ((error.position.end && error.position.end.line) || 0),