update pragma to support selected compiler version

pull/4052/head
aniket-engg 1 year ago committed by Aniket
parent cfedb800ab
commit c63a00ef7c
  1. 11
      libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts
  2. 6
      libs/remix-ui/editor/src/lib/providers/quickfixes.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,

@ -113,5 +113,11 @@ export default {
message: 'abstract ',
nodeType: 'ContractDefinition'
}
],
'ParserError: Source file requires different compiler version (current compiler' : [
{
id: 7,
nodeType: 'PragmaDirective'
}
]
}

Loading…
Cancel
Save