aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/js/xtext/ContentAssistService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'language-web/src/main/js/xtext/ContentAssistService.ts')
-rw-r--r--language-web/src/main/js/xtext/ContentAssistService.ts14
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
15const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; 15const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*';
16 16
17const HIGH_PRIORITY_KEYWORDS = ['<->'];
18
19const QUALIFIED_NAME_SEPARATOR_REGEXP = /::/g;
20
17const log = getLogger('xtext.ContentAssistService'); 21const log = getLogger('xtext.ContentAssistService');
18 22
19function createCompletion(entry: IContentAssistEntry): Completion { 23function 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 {