diff options
Diffstat (limited to 'language-web/src/main/js/xtext')
-rw-r--r-- | language-web/src/main/js/xtext/ContentAssistService.ts | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/language-web/src/main/js/xtext/ContentAssistService.ts b/language-web/src/main/js/xtext/ContentAssistService.ts index 65381b21..aa9a80b0 100644 --- a/language-web/src/main/js/xtext/ContentAssistService.ts +++ b/language-web/src/main/js/xtext/ContentAssistService.ts | |||
@@ -7,18 +7,11 @@ import { syntaxTree } from '@codemirror/language'; | |||
7 | import type { Transaction } from '@codemirror/state'; | 7 | import type { Transaction } from '@codemirror/state'; |
8 | import escapeStringRegexp from 'escape-string-regexp'; | 8 | import escapeStringRegexp from 'escape-string-regexp'; |
9 | 9 | ||
10 | import { implicitCompletion } from '../language/props'; | ||
10 | import type { UpdateService } from './UpdateService'; | 11 | import type { UpdateService } from './UpdateService'; |
11 | import { getLogger } from '../utils/logger'; | 12 | import { getLogger } from '../utils/logger'; |
12 | import type { IContentAssistEntry } from './xtextServiceResults'; | 13 | import type { IContentAssistEntry } from './xtextServiceResults'; |
13 | 14 | ||
14 | const IMPLICIT_COMPLETION_TOKENS = [ | ||
15 | 'QualifiedName', | ||
16 | 'true', | ||
17 | 'false', | ||
18 | 'unknown', | ||
19 | 'error', | ||
20 | ]; | ||
21 | |||
22 | const PROPOSALS_LIMIT = 1000; | 15 | const PROPOSALS_LIMIT = 1000; |
23 | 16 | ||
24 | const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; | 17 | const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; |
@@ -32,7 +25,7 @@ interface IFoundToken { | |||
32 | 25 | ||
33 | to: number; | 26 | to: number; |
34 | 27 | ||
35 | name: string; | 28 | implicitCompletion: boolean; |
36 | 29 | ||
37 | text: string; | 30 | text: string; |
38 | } | 31 | } |
@@ -50,14 +43,14 @@ function findToken({ pos, state }: CompletionContext): IFoundToken | null { | |||
50 | return { | 43 | return { |
51 | from: token.from, | 44 | from: token.from, |
52 | to: token.to, | 45 | to: token.to, |
53 | name: token.name, | 46 | implicitCompletion: token.type.prop(implicitCompletion) || false, |
54 | text: state.sliceDoc(token.from, token.to), | 47 | text: state.sliceDoc(token.from, token.to), |
55 | }; | 48 | }; |
56 | } | 49 | } |
57 | 50 | ||
58 | function shouldCompleteImplicitly(token: IFoundToken | null, context: CompletionContext): boolean { | 51 | function shouldCompleteImplicitly(token: IFoundToken | null, context: CompletionContext): boolean { |
59 | return token !== null | 52 | return token !== null |
60 | && IMPLICIT_COMPLETION_TOKENS.includes(token.name) | 53 | && token.implicitCompletion |
61 | && context.pos - token.from >= 2; | 54 | && context.pos - token.from >= 2; |
62 | } | 55 | } |
63 | 56 | ||