From 3b9fc301c3dcb0aa34ea8153260544a4eed353f6 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 6 Sep 2023 18:29:19 +0530 Subject: [PATCH] data location for constructor param --- .../editor/src/lib/providers/codeActionProvider.ts | 13 +++++++++++++ .../editor/src/lib/providers/quickfixes.ts | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts b/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts index 7064f23a4a..12a073124f 100644 --- a/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts @@ -24,12 +24,14 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi const errStrings: string[] = Object.keys(fixesList) const errStr: string = errStrings.find((es) => error.message.includes(es)) if (errStr) { + console.log('error=========>', error) fixes = fixesList[errStr] const cursorPosition: number = this.props.editorAPI.getHoverPosition({ lineNumber: error.startLineNumber, column: error.startColumn }) const nodeAtPosition = await this.props.plugin.call('codeParser', 'definitionAtPosition', cursorPosition) + console.log('nodeAtPosition=========>', nodeAtPosition) // Check if a function is hovered if (nodeAtPosition && nodeAtPosition.nodeType === 'FunctionDefinition') { // Identify type of AST node @@ -72,6 +74,17 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi }) 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: 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 683671f3f4..e0a947a5b4 100644 --- a/libs/remix-ui/editor/src/lib/providers/quickfixes.ts +++ b/libs/remix-ui/editor/src/lib/providers/quickfixes.ts @@ -129,5 +129,19 @@ export default { message: 'abstract ', 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' + } ] }