pull/5370/head
filip mertens 3 years ago
parent 10889e5684
commit 0a2935e862
  1. 1
      apps/remix-ide/src/app/editor/editor.js
  2. 2
      libs/remix-solidity/src/compiler/types.ts
  3. 24
      libs/remix-ui/editor/src/lib/providers/completionProvider.ts
  4. 45
      libs/remix-ui/editor/src/lib/providers/signatureProvider.ts
  5. 7
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -163,7 +163,6 @@ class Editor extends Plugin {
} }
async _onChange (file) { async _onChange (file) {
console.log(file)
const currentFile = await this.call('fileManager', 'file') const currentFile = await this.call('fileManager', 'file')
if (!currentFile) { if (!currentFile) {
return return

@ -123,7 +123,7 @@ export interface CompilerInput {
outputSelection?: { outputSelection?: {
'*': { '*': {
'': [ 'ast' ], '': [ 'ast' ],
'*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'storageLayout', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates', 'evm.assembly' ] //'*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'storageLayout', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates', 'evm.assembly' ]
} }
} }
} }

@ -0,0 +1,24 @@
export class RemixCompletionProvider {
props: any
monaco: any
constructor(props: any, monaco: any) {
this.props = props
this.monaco = monaco
}
triggerCharacters = ['.', ' ']
async provideCompletionItems(model: any, position: any) {
const textUntilPosition = model.getValueInRange({
startLineNumber: 1,
startColumn: 1,
endLineNumber: position.lineNumber,
endColumn: position.column
});
console.log(textUntilPosition)
return {
suggestions: []
}
}
}

@ -0,0 +1,45 @@
// https://github.com/maziac/binary-file-viewer/blob/c71ab6043867717327ef546f1646938fd4733548/src/signatureprovider.ts
export class RemixSignatureProvider {
props: any
monaco: any
constructor(props: any, monaco: any) {
this.props = props
this.monaco = monaco
}
public signatureHelpTriggerCharacters = ['(', ','];
async provideSignatureHelp(model: any, position: any, token: any, context: any) {
console.log(`providing signature help`, context);
console.log(position)
const line = model.getLineContent(position.lineNumber);
// find position of the opening parenthesis before the cursor
const openParenIndex = line.lastIndexOf('(', position.column - 1);
console.log(openParenIndex)
const newPosition = new this.monaco.Position(position.lineNumber - 1, openParenIndex -1);
const cursorPosition = this.props.editorAPI.getHoverPosition(newPosition)
const nodeDefinition = await this.props.plugin.call('contextualListener', 'definitionAtPosition', cursorPosition)
console.log(nodeDefinition)
return {
value: {
signatures: [{
label: "test(var1, var2)",
parameters: [{
label: "var1",
documentation: "param 1"
},
{
label: "var2",
documentation: "param 2"
}]
}],
activeSignature: 0,
activeParameter: 0
},
dispose: () => { }
};
}
}

@ -12,6 +12,8 @@ import { IPosition, languages } from 'monaco-editor'
import { sourceMappingDecoder } from '@remix-project/remix-debug' import { sourceMappingDecoder } from '@remix-project/remix-debug'
import { RemixHoverProvider } from './providers/hoverProvider' import { RemixHoverProvider } from './providers/hoverProvider'
import { RemixReferenceProvider } from './providers/referenceProvider' import { RemixReferenceProvider } from './providers/referenceProvider'
import { RemixCompletionProvider } from './providers/completionProvider'
import { RemixSignatureProvider } from './providers/signatureProvider'
type cursorPosition = { type cursorPosition = {
startLineNumber: number, startLineNumber: number,
@ -437,8 +439,11 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.languages.registerReferenceProvider('remix-solidity', new RemixReferenceProvider(props, monaco)) monacoRef.current.languages.registerReferenceProvider('remix-solidity', new RemixReferenceProvider(props, monaco))
monacoRef.current.languages.registerHoverProvider('remix-solidity', new RemixHoverProvider(props, monaco)) monacoRef.current.languages.registerHoverProvider('remix-solidity', new RemixHoverProvider(props, monaco))
monacoRef.current.languages.registerCompletionItemProvider('remix-solidity', new RemixCompletionProvider(props, monaco))
monacoRef.current.languages.registerSignatureHelpProvider('remix-solidity', new RemixSignatureProvider(props, monaco))
loadTypes(monacoRef.current) loadTypes(monacoRef.current)
props.plugin.call()
} }
return ( return (

Loading…
Cancel
Save