import { scopedLogger } from "@hpcc-js/util" ; import * as vscode from "vscode" ; import { Diagnostic } from "./diagnostic" ; import { Meta } from "./meta" ; const logger = scopedLogger ( "documentSymbolProvider.ts" ) ; export let documentSymbolProvider ; export class DocumentSymbolProvider implements vscode . DocumentSymbolProvider { protected _ctx : vscode . ExtensionContext ; private _diagnostic : Diagnostic ; private constructor ( ctx ) { this . _ctx = ctx ; ctx . subscriptions . push ( vscode . languages . registerDocumentSymbolProvider ( "ojs" , this ) ) ; ctx . subscriptions . push ( vscode . languages . registerDocumentSymbolProvider ( "omd" , this ) ) ; this . _diagnostic = Diagnostic . attach ( ctx ) ; } static attach ( ctx ) { if ( ! documentSymbolProvider ) { documentSymbolProvider = new DocumentSymbolProvider ( ctx ) ; } return documentSymbolProvider ; } provideDocumentSymbols ( document , token ) { const retVal = [ ] ; const meta = Meta . attach ( document ) ; const cells = meta . parse ( ) ; cells . forEach ( cell => { retVal . push ( cell . documentSymbol ( ) ) ; } ) ; return retVal ; } }