VeniaminR
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору On server side: ``` export function GetFileRequest(nameInter:string) { connection.sendRequest("getFile", nameInter).then( (body : string) => { if (body != undefined && body.length) pushImports(body); }); } ``` on client side: in *function activate(context: ExtensionContext)* after client.start(); ``` client.onReady().then(() => { client.onRequest("getFile", (nameInter : string) : Promise<string> => { return getFile(nameInter); } ); }); ``` and async function on client side: ``` async function getFile(name):Promise<string>{ let uri:Uri = undefined; let text:string = undefined; await workspace.findFiles(name, null, 1).then((value)=> { if (value.length) { uri=value[0]; } }); if (uri!=undefined) { let textDocument; await workspace.openTextDocument(uri).then((value)=>textDocument = value); text = textDocument.getText(); } return text; } ``` This code will return a text from file to server side. |