@@ -17,7 +17,12 @@ export class ObjectScriptCompletionItemProvider implements vscode.CompletionItem
17
17
) : vscode . ProviderResult < vscode . CompletionItem [ ] | vscode . CompletionList > {
18
18
if ( context . triggerKind === vscode . CompletionTriggerKind . TriggerCharacter ) {
19
19
if ( context . triggerCharacter === '#' )
20
- return this . macro ( document , position , token , context ) || this . entities ( document , position , token , context ) ;
20
+ return (
21
+ this . macro ( document , position , token , context ) ||
22
+ this . entities ( document , position , token , context ) ||
23
+ null ) ;
24
+ if ( context . triggerCharacter === '$' )
25
+ return this . macrolist ( document , position , token , context ) ;
21
26
if ( context . triggerCharacter === '.' ) {
22
27
if ( document . getWordRangeAtPosition ( position , / \$ s y s t e m ( \. \b \w + \b ) ? \. / i) ) {
23
28
return this . system ( document , position , token , context ) ;
@@ -31,6 +36,7 @@ export class ObjectScriptCompletionItemProvider implements vscode.CompletionItem
31
36
}
32
37
let completions = (
33
38
this . classes ( document , position , token , context ) ||
39
+ this . macrolist ( document , position , token , context ) ||
34
40
this . dollarsComplete ( document , position ) ||
35
41
this . commands ( document , position ) ||
36
42
this . entities ( document , position , token , context ) ||
@@ -65,12 +71,44 @@ export class ObjectScriptCompletionItemProvider implements vscode.CompletionItem
65
71
label : '##super()' ,
66
72
insertText : new vscode . SnippetString ( '##super($0)' ) ,
67
73
range
74
+ } ,
75
+ {
76
+ label : '#dim' ,
77
+ insertText : new vscode . SnippetString ( '#dim $1 As $2' ) ,
78
+ range
68
79
}
69
80
] ;
70
81
}
71
82
return null ;
72
83
}
73
84
85
+ macrolist (
86
+ document : vscode . TextDocument ,
87
+ position : vscode . Position ,
88
+ token : vscode . CancellationToken ,
89
+ context : vscode . CompletionContext
90
+ ) : vscode . ProviderResult < vscode . CompletionItem [ ] | vscode . CompletionList > {
91
+ let range = document . getWordRangeAtPosition ( position , / \$ { 3 } ( \b \w [ \w \d ] * \b ) ? / ) ;
92
+ let text = range ? document . getText ( range ) : '' ;
93
+ if ( range ) {
94
+ let macro = text . toLowerCase ( ) . slice ( 3 ) ;
95
+ let file = currentFile ( ) ;
96
+ let api = new AtelierAPI ( )
97
+ return api . getmacrollist ( file . name , [ ] )
98
+ . then ( data => data . result . content . macros )
99
+ . then ( list => list . filter ( el => el . toLowerCase ( ) . startsWith ( macro ) ) )
100
+ . then ( list => list . map ( el => '$$$' + el ) )
101
+ . then ( list => list . map ( el => ( {
102
+ label : el ,
103
+ // kind: vscode.CompletionItemKind.Constant,
104
+ // insertText: el,
105
+ range
106
+ } ) ) )
107
+ . then ( data => { console . log ( data ) ; return data ; } )
108
+ }
109
+ return null
110
+ }
111
+
74
112
commands (
75
113
document : vscode . TextDocument ,
76
114
position : vscode . Position
0 commit comments