add abstract quickfix

pull/4047/head
aniket-engg 1 year ago committed by Aniket
parent d0b0263bc0
commit 9bd904eae0
  1. 11
      libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts
  2. 8
      libs/remix-ui/editor/src/lib/providers/quickfixes.ts

@ -30,6 +30,8 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi
column: error.startColumn column: error.startColumn
}) })
const nodeAtPosition = await this.props.plugin.call('codeParser', 'definitionAtPosition', cursorPosition) const nodeAtPosition = await this.props.plugin.call('codeParser', 'definitionAtPosition', cursorPosition)
console.log('nodeAtPosition------>', nodeAtPosition)
console.log('error------>', error)
// Check if a function is hovered // Check if a function is hovered
if (nodeAtPosition && nodeAtPosition.nodeType === 'FunctionDefinition') { if (nodeAtPosition && nodeAtPosition.nodeType === 'FunctionDefinition') {
// Identify type of AST node // Identify type of AST node
@ -46,6 +48,15 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi
text: msg text: msg
}) })
} }
} else if (nodeAtPosition && nodeAtPosition.nodeType === 'ContractDefinition') {
for (const fix of fixes) {
const lineContent: string = model.getValueInRange(error)
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: error,
text: fix.message + lineContent
})
}
} else { } else {
for (const fix of fixes) { for (const fix of fixes) {
if (fix && nodeAtPosition && fix.nodeType !== nodeAtPosition.nodeType) continue if (fix && nodeAtPosition && fix.nodeType !== nodeAtPosition.nodeType) continue

@ -106,5 +106,13 @@ export default {
message: 'pure ', message: 'pure ',
nodeType: 'FunctionDefinition' nodeType: 'FunctionDefinition'
} }
],
'should be marked as abstract': [
{
id: 6,
title: "Add 'abstract' to contract",
message: 'abstract ',
nodeType: 'ContractDefinition'
}
] ]
} }

Loading…
Cancel
Save