diff options
author | 2021-10-31 01:53:11 +0200 | |
---|---|---|
committer | 2021-10-31 19:26:15 +0100 | |
commit | a7ba55f2b781544cd74927137025f2c00a398f69 (patch) | |
tree | 3fdb3a0bea8f2b53e238180b33388004368f6bd6 /language-web/src/main/js/xtext/ContentAssistService.ts | |
parent | feat(web): find occurrences when idle (diff) | |
download | refinery-a7ba55f2b781544cd74927137025f2c00a398f69.tar.gz refinery-a7ba55f2b781544cd74927137025f2c00a398f69.tar.zst refinery-a7ba55f2b781544cd74927137025f2c00a398f69.zip |
fix(web): fix server-side content assist filtering
Diffstat (limited to 'language-web/src/main/js/xtext/ContentAssistService.ts')
-rw-r--r-- | language-web/src/main/js/xtext/ContentAssistService.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/language-web/src/main/js/xtext/ContentAssistService.ts b/language-web/src/main/js/xtext/ContentAssistService.ts index ec6b80d2..8461ec7f 100644 --- a/language-web/src/main/js/xtext/ContentAssistService.ts +++ b/language-web/src/main/js/xtext/ContentAssistService.ts | |||
@@ -14,20 +14,28 @@ const PROPOSALS_LIMIT = 1000; | |||
14 | 14 | ||
15 | const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; | 15 | const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; |
16 | 16 | ||
17 | const HIGH_PRIORITY_KEYWORDS = ['<->']; | ||
18 | |||
19 | const QUALIFIED_NAME_SEPARATOR_REGEXP = /::/g; | ||
20 | |||
17 | const log = getLogger('xtext.ContentAssistService'); | 21 | const log = getLogger('xtext.ContentAssistService'); |
18 | 22 | ||
19 | function createCompletion(entry: IContentAssistEntry): Completion { | 23 | function createCompletion(entry: IContentAssistEntry): Completion { |
20 | let boost; | 24 | let boost; |
21 | switch (entry.kind) { | 25 | switch (entry.kind) { |
22 | case 'KEYWORD': | 26 | case 'KEYWORD': |
23 | boost = -99; | 27 | // Some hard-to-type operators should be on top. |
28 | boost = HIGH_PRIORITY_KEYWORDS.includes(entry.proposal) ? 10 : -99; | ||
24 | break; | 29 | break; |
25 | case 'TEXT': | 30 | case 'TEXT': |
26 | case 'SNIPPET': | 31 | case 'SNIPPET': |
27 | boost = -90; | 32 | boost = -90; |
28 | break; | 33 | break; |
29 | default: | 34 | default: { |
30 | boost = 0; | 35 | // Penalize qualified names (vs available unqualified names). |
36 | const extraSegments = entry.proposal.match(QUALIFIED_NAME_SEPARATOR_REGEXP)?.length || 0; | ||
37 | boost = Math.max(-5 * extraSegments, -50); | ||
38 | } | ||
31 | break; | 39 | break; |
32 | } | 40 | } |
33 | return { | 41 | return { |