Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * This file is released under the MIT license. * Copyright (c) 2018, 2022, Mike Lischke * * See LICENSE file for more info. */ /* eslint-disable max-classes-per-file */ import * as path from "path"; import { TreeItem, TreeItemCollapsibleState, Command, ProviderResult } from "vscode"; import { AntlrTreeDataProvider } from "./AntlrTreeDataProvider"; export class ParserSymbol extends TreeItem { public iconPath = { light: path.join(__dirname, "..", "..", "..", "misc", "rule-light.svg"), dark: path.join(__dirname, "..", "..", "..", "misc", "rule-dark.svg"), }; public contextValue = "parserSymbols"; public constructor( public readonly label: string, public readonly collapsibleState: TreeItemCollapsibleState, command?: Command, ) { super(label, collapsibleState); this.command = command; } } export class ParserSymbolsProvider extends AntlrTreeDataProvider<ParserSymbol> { public getChildren(element?: ParserSymbol): ProviderResult<ParserSymbol[]> { return new Promise((resolve) => { Iif (!element) { let rules: string[] | undefined; Iif (this.currentFile) { rules = this.backend.getRuleList(this.currentFile); } const list: ParserSymbol[] = []; Iif (rules) { rules.forEach((rule, index) => { const info = this.backend.infoForSymbol(this.currentFile!, rule); const parameters: Command = { title: "", command: "" }; const caption = `${index}: ${rules![index]}`; Iif (info && info.definition) { parameters.title = ""; parameters.command = "antlr.selectGrammarRange"; parameters.arguments = [info.definition.range]; } list.push(new ParserSymbol(caption, TreeItemCollapsibleState.None, parameters)); }); } resolve(list); } }); } } |