import * as vscode from 'vscode' ; import { macrosOf } from './macros' ; import { Diagram } from '../diagram/diagram' ; export async function MacroCompletionItems ( target , position , token ) { if ( ! target ) return [ ] ; return new Promise < vscode . CompletionItem [ ] > ( ( resolve , reject ) => { const results = [ ] ; const macros = macrosOf ( target , position ) ; macros . forEach ( macro => { const item = new vscode . CompletionItem ( macro . name , vscode . CompletionItemKind . Method ) ; item . detail = macro . getDetailLabel ( ) ; item . insertText = new vscode . SnippetString ( macro . name ) ; results . push ( item ) ; } ) ; return resolve ( results ) ; } ) ; }