import * as path from "path"; import * as fs from "fs"; import Completer from "../../interfaces/Completer"; import { CompletionItemKind, CompletionItem } from "vscode-languageserver/lib/main"; export default class NodeCompleter implements Completer { public projectPath: string; setPath(projectPath: string) { this.projectPath = projectPath; } getItems(): CompletionItem[] { const idsPath = "_eko_/js/auto_generated/nodes"; let completionsPath = path.join(this.projectPath, idsPath); let result: CompletionItem[] = []; fs.accessSync( completionsPath, fs.constants.F_OK | fs.constants.W_OK ); result = fs.readdirSync(completionsPath).map( (filename: string): CompletionItem => { return { label: filename.replace(path.extname(filename), ""), kind: CompletionItemKind.Constant, detail: "Node" }; } ); return result; } }