Merge branch 'master' into fix_listen_on_framework

pull/2956/head
bunsenstraat 2 years ago committed by GitHub
commit 6c7ded15c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      libs/remix-ui/editor/src/lib/providers/completionProvider.ts

@ -258,6 +258,7 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider
// if no nodes exits at position, try to get the block of which the position is in
const block = await this.props.plugin.call('codeParser', 'getANTLRBlockAtPosition', cursorPosition, null)
const fileNodes = await this.props.plugin.call('codeParser', 'getCurrentFileNodes')
if (!nodesAtPosition.length) {
if (block) {
nodesAtPosition = await this.props.plugin.call('codeParser', 'nodesAtPosition', block.start)
@ -274,7 +275,7 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider
nodes = [...Object.values(contractNodes.baseNodesWithBaseContractScope), ...nodes]
nodes = [...Object.values(fileNodes.imports), ...nodes]
// add the nodes at the block itself
if (node.nodeType === 'ContractDefinition' && block && block.name) {
if (block && block.name) {
const contractNodes = fileNodes.contracts[node.name].contractNodes
for (const contractNode of Object.values(contractNodes)) {
if (contractNode['name'] === block.name
@ -288,6 +289,14 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider
}
}
}
} else { // we use the block info from the nodesAtPosition
const contractNodes = fileNodes.contracts[node.name].contractNodes
for (const contractNode of Object.values(contractNodes)) {
if((contractNode as any).nodeType === 'Block'){
const nodeOfScope = await this.props.plugin.call('codeParser', 'getNodesWithScope', (contractNode as any).id)
nodes = [...nodes, ...nodeOfScope]
}
}
}
// filter private nodes, only allow them when contract ID is the same as the current contract
nodes = nodes.filter(node => {

Loading…
Cancel
Save