marker severity

pull/5370/head
bunsenstraat 2 years ago
parent 561be4c106
commit f54380ff2a
  1. 14
      apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts
  2. 8
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -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),

@ -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),

Loading…
Cancel
Save