-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Labels
completionCompletion related issueCompletion related issue
Description
Langium version: 4.0.0
Package name: langium
Original discussion: #2015
Steps To Reproduce
- Create a grammar with a single-line comment as a hidden terminal
- Create a completion provider
- Start typing after a single-line comment has started
Link to code example: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/src/langium/statemachine/ls/statemachine.langium
Link to example: https://langium.org/showcase/statemachine/
The current behavior
Completions are currently possible within single-line comments.
The expected behavior
Completions should be able to be disabled within single-line comments.
There are currently tests for multi-line comments, but not for single-line comments:
langium/packages/langium/test/lsp/completion-provider.test.ts
Lines 339 to 424 in 910e8a0
| test('Can perform completion for fully qualified names', async () => { | |
| const grammar = ` | |
| grammar FQNCompletionTest | |
| entry Model: | |
| (persons+=Person | greetings+=Greeting)*; | |
| Person: | |
| 'person' name=FQN; | |
| Greeting: | |
| 'Hello' person=[Person:FQN] '!'; | |
| FQN returns string: ID ('.' ID)*; | |
| hidden terminal WS: /\\s+/; | |
| terminal ID: /[_a-zA-Z][\\w_]*/; | |
| hidden terminal ML_COMMENT: /\\/\\*[\\s\\S]*?\\*\\//; | |
| `; | |
| const services = await createServicesForGrammar({ grammar }); | |
| const completion = expectCompletion(services); | |
| const text = ` | |
| person John.Miller | |
| person John.Smith.Junior | |
| person John.Smith.Senior | |
| Hello <|>John<|>.Smi<|>th.Jun<|>ior | |
| Hello <|>John./* Hello */ <|>Miller | |
| `; | |
| await completion({ | |
| text: text, | |
| index: 0, | |
| expectedItems: [ | |
| 'John.Miller', | |
| 'John.Smith.Junior', | |
| 'John.Smith.Senior' | |
| ] | |
| }); | |
| await completion({ | |
| text: text, | |
| index: 1, | |
| expectedItems: [ | |
| 'John.Miller', | |
| 'John.Smith.Junior', | |
| 'John.Smith.Senior' | |
| ] | |
| }); | |
| await completion({ | |
| text: text, | |
| index: 2, | |
| expectedItems: [ | |
| 'John.Smith.Junior', | |
| 'John.Smith.Senior' | |
| ] | |
| }); | |
| await completion({ | |
| text: text, | |
| index: 3, | |
| expectedItems: [ | |
| 'John.Smith.Junior' | |
| ] | |
| }); | |
| await completion({ | |
| text: text, | |
| index: 4, | |
| expectedItems: [ | |
| 'John.Miller', | |
| 'John.Smith.Junior', | |
| 'John.Smith.Senior' | |
| ] | |
| }); | |
| // A comment within the FQN should prevent any completion from appearing | |
| await completion({ | |
| text: text, | |
| index: 5, | |
| expectedItems: [] | |
| }); | |
| }); |
Metadata
Metadata
Assignees
Labels
completionCompletion related issueCompletion related issue