Skip to content

Commit

Permalink
add specific pragma in quickfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket-Engg committed Sep 1, 2023
1 parent 9bd904e commit cfedb80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi
} else {
for (const fix of fixes) {
if (fix && nodeAtPosition && fix.nodeType !== nodeAtPosition.nodeType) continue
else
if (fix.id === 2) {
// To add specific pragma based on error
const startIndex = error.message.indexOf('pragma')
const endIndex = error.message.indexOf(';')
const msg = error.message.substring(startIndex, endIndex + 1)
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: fix.range,
text: msg
})
} else
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: fix.range || error,
Expand Down
1 change: 0 additions & 1 deletion libs/remix-ui/editor/src/lib/providers/quickfixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default {
{
id: 2,
title: 'Add Solidity pragma',
message: 'pragma solidity ^0.*.*;',
nodeType: 'PragmaDirective',
range: {
startLineNumber: 2,
Expand Down

0 comments on commit cfedb80

Please sign in to comment.