switch statement

pull/4052/head
aniket-engg 1 year ago committed by Aniket
parent 0aa6b1fc44
commit 87bb358960
  1. 75
      libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts

@ -49,39 +49,48 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi
} else {
for (const fix of fixes) {
if (fix && nodeAtPosition && fix.nodeType && fix.nodeType !== nodeAtPosition.nodeType) continue
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 if (fix.id === 6) {
const lineContent: string = model.getValueInRange(error)
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: error,
text: fix.message + lineContent
})
} 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,
range: fix.range || error,
text: fix.message
})
switch (fix.id) {
case 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
})
break
}
case 6: {
// To add `abstract` in the contract
const lineContent: string = model.getValueInRange(error)
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: error,
text: fix.message + lineContent
})
break
}
case 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 + ';'
})
break
}
default:
this.addQuickFix(actions, error, model.uri, {
title: fix.title,
range: fix.range || error,
text: fix.message
})
}
}
}
}

Loading…
Cancel
Save