@@ -17,7 +17,12 @@ export class ObjectScriptCompletionItemProvider implements vscode.CompletionItem
1717 ) : vscode . ProviderResult < vscode . CompletionItem [ ] | vscode . CompletionList > {
1818 if ( context . triggerKind === vscode . CompletionTriggerKind . TriggerCharacter ) {
1919 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 ) ;
2126 if ( context . triggerCharacter === '.' ) {
2227 if ( document . getWordRangeAtPosition ( position , / \$ s y s t e m ( \. \b \w + \b ) ? \. / i) ) {
2328 return this . system ( document , position , token , context ) ;
@@ -31,6 +36,7 @@ export class ObjectScriptCompletionItemProvider implements vscode.CompletionItem
3136 }
3237 let completions = (
3338 this . classes ( document , position , token , context ) ||
39+ this . macrolist ( document , position , token , context ) ||
3440 this . dollarsComplete ( document , position ) ||
3541 this . commands ( document , position ) ||
3642 this . entities ( document , position , token , context ) ||
@@ -65,12 +71,44 @@ export class ObjectScriptCompletionItemProvider implements vscode.CompletionItem
6571 label : '##super()' ,
6672 insertText : new vscode . SnippetString ( '##super($0)' ) ,
6773 range
74+ } ,
75+ {
76+ label : '#dim' ,
77+ insertText : new vscode . SnippetString ( '#dim $1 As $2' ) ,
78+ range
6879 }
6980 ] ;
7081 }
7182 return null ;
7283 }
7384
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+
74112 commands (
75113 document : vscode . TextDocument ,
76114 position : vscode . Position
0 commit comments