'use strict' ; import * as vscode from 'vscode' ; import * as uiflow from 'uiflow' ; import { selector } from './mode' ; export function activate ( context ) { const provider = new UiflowCompletionItemProvider ( ) ; const registration = vscode . languages . registerCompletionItemProvider ( selector , provider , ... UiflowCompletionItemProvider . triggerCharacters ) ; context . subscriptions . push ( registration ) ; } export class UiflowCompletionItemProvider implements vscode . CompletionItemProvider { public static readonly triggerCharacters = [ '>' , ' ' ] ; public provideCompletionItems ( document , position , token ) { const lineText = document . lineAt ( position . line ) ; if ( ! lineText . text . substring ( 0 , position . character ) . match ( /=.*=>/ ) ) { return [ ] ; } const json = uiflow . parser . parse ( document . getText ( ) , '' ) ; const list = [ ] ; Object . keys ( json ) . forEach ( key => { const section = json [ key ] ; const item = new vscode . CompletionItem ( section . name ) ; item . kind = vscode . CompletionItemKind . Class ; list . push ( item ) ; } ) ; return list ; } }