Skip to content

Commit

Permalink
Fix autocomplete for singleton references
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Oct 13, 2023
1 parent 113ad28 commit 834a48b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions server/src/functionalities/autocomplete/node-completion.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CompletionItem } from 'vscode-languageserver'
import { Assignment, Node, Body, Method, Singleton, Module, Environment, Package, Class, Mixin, Describe, Program, Test, Reference, New, Return } from 'wollok-ts'
import { Node, Body, Method, Singleton, Module, Environment, Package, Class, Mixin, Describe, Program, Test, Reference, New } from 'wollok-ts'
import { is, match, when } from 'wollok-ts/dist/extensions'
import { classCompletionItem, fieldCompletionItem, initializerCompletionItem, parameterCompletionItem, singletonCompletionItem } from './autocomplete'
import { optionModules, optionImports, optionDescribes, optionTests, optionReferences, optionMethods, optionPrograms, optionAsserts, optionConstReferences, optionInitialize, optionPropertiesAndReferences } from './options-autocomplete'

export const completionsForNode = (node: Node): CompletionItem[] => {
try{
try {
return match(node)(
when(Environment)(_ => []),
when(Package)(completePackage),
Expand Down
10 changes: 5 additions & 5 deletions server/src/functionalities/autocomplete/send-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ function methodPool(environment: Environment, node: Node): List<Method> {
if (node.is(Literal)) {
return literalMethods(environment, node)
}
if (node.is(New)) {
return allMethods(environment, node.instantiated)
}
if (node.is(Body) && node.hasProblems) {
const childAutocomplete = firstNodeWithProblems(node)
if (childAutocomplete?.is(Literal)) {
return literalMethods(environment, childAutocomplete)
}
if (childAutocomplete?.is(New)) {
return allMethods(environment, childAutocomplete.instantiated)
if (childAutocomplete) {
return methodPool(environment, childAutocomplete)
}
}
return allPossibleMethods(environment, node)
Expand Down

0 comments on commit 834a48b

Please sign in to comment.