"use strict" ; import * as vscode from "vscode" ; import { TextDocumentContentProvider , Uri } from "vscode" ; import snippet from "./snippet" ; export default class SnippetProvider implements TextDocumentContentProvider { param { vscode . Uri } uri returns { string } public async provideTextDocumentContent ( uri ? ) { let request = decodeRequest ( uri ) ; let response = await snippet . load ( request . language , request . query , request . answerNumber ) ; return response . data ; } } export function encodeRequest ( query , language , verbose , answerNumber ) { const data = JSON . stringify ( { query : query , language : language , answerNumber , verbose } ) ; return vscode . Uri . parse ( `snippet:[${ language }] ${ query } (${ answerNumber })?${ data }` ) ; } export function decodeRequest ( uri ) { let obj = JSON . parse ( uri . query ) ; return obj ; }