pull/3939/head
bunsenstraat 2 years ago
parent b35d97d72d
commit 866cc44d61
  1. 74
      libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts
  2. 26
      libs/remix-ui/editor/src/lib/providers/quickfixes.ts

@ -4,45 +4,45 @@ import { EditorUIProps } from "../remix-ui-editor"
import { default as fixes } from "./quickfixes" import { default as fixes } from "./quickfixes"
export class RemixCodeActionProvider implements monaco.languages.CodeActionProvider { export class RemixCodeActionProvider implements monaco.languages.CodeActionProvider {
props: EditorUIProps props: EditorUIProps
monaco: Monaco monaco: Monaco
constructor(props: any, monaco: any) { constructor(props: any, monaco: any) {
this.props = props this.props = props
this.monaco = monaco this.monaco = monaco
} }
async provideCodeActions ( async provideCodeActions (
model /**ITextModel*/, model /**ITextModel*/,
range /**Range*/, range /**Range*/,
context /**CodeActionContext*/, context /**CodeActionContext*/,
token /**CancellationToken*/ token /**CancellationToken*/
) { ) {
const actions = context.markers.map(error => { const actions = context.markers.map(error => {
const errStrings = Object.keys(fixes) const errStrings = Object.keys(fixes)
const errStr = errStrings.find(es => error.message.includes(es)) const errStr = errStrings.find(es => error.message.includes(es))
const fix = fixes[errStr] const fix = fixes[errStr]
return { return {
title: fix.title, title: fix.title,
diagnostics: [error], diagnostics: [error],
kind: "quickfix", kind: "quickfix",
edit: { edit: {
edits: [ edits: [
{ {
resource: model.uri, resource: model.uri,
edit: { edit: {
range: fix.range || error, range: fix.range || error,
text: fix.message text: fix.message
} }
}
]
},
isPreferred: true
} }
}) ]
return { },
actions: actions, isPreferred: true
dispose: () => {} }
} })
return {
actions: actions,
dispose: () => {}
} }
}
} }

@ -1,16 +1,16 @@
export default { export default {
"Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.": { "Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.": {
"title": "Add open-source license", "title": "Add open-source license",
"message": "// SPDX-License-Identifier: GPL-3.0" "message": "// SPDX-License-Identifier: GPL-3.0"
}, },
"Warning: Source file does not specify required compiler version! Consider adding" : { "Warning: Source file does not specify required compiler version! Consider adding" : {
"title": "Add pragma line", "title": "Add pragma line",
"message": "pragma solidity ^0.*.*;", "message": "pragma solidity ^0.*.*;",
"range": { "range": {
startLineNumber: 2, startLineNumber: 2,
endLineNumber: 2, endLineNumber: 2,
startColumn: 1, startColumn: 1,
endColumn: 1 endColumn: 1
}
} }
}
} }
Loading…
Cancel
Save