pull/5370/head
bunsenstraat 1 year ago
commit f214d91dc9
  1. 48
      libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts
  2. 16
      libs/remix-ui/editor/src/lib/providers/quickfixes.ts
  3. 2
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  4. 6
      yarn.lock

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

@ -0,0 +1,16 @@
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.": {
"title": "Add open-source license",
"message": "// SPDX-License-Identifier: GPL-3.0"
},
"Warning: Source file does not specify required compiler version! Consider adding" : {
"title": "Add pragma line",
"message": "pragma solidity ^0.*.*;",
"range": {
startLineNumber: 2,
endLineNumber: 2,
startColumn: 1,
endColumn: 1
}
}
}

@ -15,6 +15,7 @@ import { RemixReferenceProvider } from './providers/referenceProvider'
import { RemixCompletionProvider } from './providers/completionProvider'
import { RemixHighLightProvider } from './providers/highlightProvider'
import { RemixDefinitionProvider } from './providers/definitionProvider'
import { RemixCodeActionProvider } from './providers/codeActionProvider'
import './remix-ui-editor.css'
@ -749,6 +750,7 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.languages.registerReferenceProvider('remix-solidity', new RemixReferenceProvider(props, monaco))
monacoRef.current.languages.registerHoverProvider('remix-solidity', new RemixHoverProvider(props, monaco))
monacoRef.current.languages.registerCompletionItemProvider('remix-solidity', new RemixCompletionProvider(props, monaco))
monaco.languages.registerCodeActionProvider("remix-solidity", new RemixCodeActionProvider(props, monaco))
loadTypes(monacoRef.current)
}

@ -27631,9 +27631,9 @@ winston@^3.3.3:
winston-transport "^4.4.0"
word-wrap@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
version "1.2.4"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f"
integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==
wordwrap@0.0.2:
version "0.0.2"

Loading…
Cancel
Save