diff --git a/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts b/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts index ce4549a748..e9cd42d8b4 100644 --- a/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts @@ -29,6 +29,7 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi lineNumber: error.startLineNumber, column: error.startColumn }) + console.log('cursorPosition------>', cursorPosition) const nodeAtPosition = await this.props.plugin.call('codeParser', 'definitionAtPosition', cursorPosition) console.log('nodeAtPosition------>', nodeAtPosition) console.log('error------>', error) @@ -70,6 +71,16 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi range: fix.range, text: msg }) + } else if (fix.id === 7) { + // To update pragma same as selected compiler version + const startIndex = error.message.indexOf('is') + const endIndex = error.message.indexOf('+') + const msg = error.message.substring(startIndex + 2, endIndex) + this.addQuickFix(actions, error, model.uri, { + title: `update pragma to ${msg}`, + range: error, + text: 'pragma solidity' + msg + ';' + }) } else this.addQuickFix(actions, error, model.uri, { title: fix.title, diff --git a/libs/remix-ui/editor/src/lib/providers/quickfixes.ts b/libs/remix-ui/editor/src/lib/providers/quickfixes.ts index 2edb137fd6..898b012ec8 100644 --- a/libs/remix-ui/editor/src/lib/providers/quickfixes.ts +++ b/libs/remix-ui/editor/src/lib/providers/quickfixes.ts @@ -113,5 +113,11 @@ export default { message: 'abstract ', nodeType: 'ContractDefinition' } + ], + 'ParserError: Source file requires different compiler version (current compiler' : [ + { + id: 7, + nodeType: 'PragmaDirective' + } ] }