data location for constructor param

pull/5370/head
aniket-engg 1 year ago committed by Aniket
parent 2f934d6cd2
commit 3b9fc301c3
  1. 13
      libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts
  2. 14
      libs/remix-ui/editor/src/lib/providers/quickfixes.ts

@ -24,12 +24,14 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi
const errStrings: string[] = Object.keys(fixesList) const errStrings: string[] = Object.keys(fixesList)
const errStr: string = errStrings.find((es) => error.message.includes(es)) const errStr: string = errStrings.find((es) => error.message.includes(es))
if (errStr) { if (errStr) {
console.log('error=========>', error)
fixes = fixesList[errStr] fixes = fixesList[errStr]
const cursorPosition: number = this.props.editorAPI.getHoverPosition({ const cursorPosition: number = this.props.editorAPI.getHoverPosition({
lineNumber: error.startLineNumber, lineNumber: error.startLineNumber,
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)
// 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
@ -72,6 +74,17 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi
}) })
break break
} }
case 9.1:
case 9.2: {
const lineContent: string = model.getValueInRange(error)
const words = lineContent.split(' ')
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: error,
text: words[0] + fix.message + words[1]
})
break
}
default: default:
this.addQuickFix(actions, error, model.uri, { this.addQuickFix(actions, error, model.uri, {
title: fix.title, title: fix.title,

@ -129,5 +129,19 @@ export default {
message: 'abstract ', message: 'abstract ',
nodeType: 'ContractDefinition' nodeType: 'ContractDefinition'
} }
],
'TypeError: Data location must be "storage" or "memory" for constructor parameter, but none was given.': [
{
id: 9.1,
title: "Add 'storage' to param",
message: ' storage ',
nodeType: 'ElementaryTypeName'
},
{
id: 9.2,
title: "Add 'memory' to param",
message: ' memory ',
nodeType: 'ElementaryTypeName'
}
] ]
} }

Loading…
Cancel
Save