File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ export default class lspClient {
9191 * Add an editor to the language provider
9292 * @param {Object } editor - Ace editor instance
9393 * @returns {boolean } - Success status
94+ *
95+ * Note: this is not limited to a single editor tab
9496 */
9597 addEditor ( editor ) {
9698 if ( ! editor ) {
@@ -295,6 +297,36 @@ export default class lspClient {
295297 return new Set ( this . registeredEditors ) ;
296298 }
297299
300+ async sendRequest ( method , params ) {
301+ return new Promise ( ( resolve , reject ) => {
302+ try {
303+ this . languageProvider . sendRequest (
304+ "lspClient" ,
305+ method ,
306+ params ,
307+ ( result ) => {
308+ resolve ( result ) ;
309+ }
310+ ) ;
311+ } catch ( err ) {
312+ reject ( err ) ;
313+ }
314+ } ) ;
315+ }
316+
317+ async getDefination ( editor , uri ) {
318+ const result = await this . sendRequest ( "textDocument/definition" , {
319+ textDocument : { uri } ,
320+ position : {
321+ line : editor . getCursorPosition ( ) . row ,
322+ character : editor . getCursorPosition ( ) . column ,
323+ } ,
324+ } ) ;
325+
326+ return result ;
327+ }
328+
329+
298330 // Private helper methods
299331
300332 /**
@@ -307,6 +339,7 @@ export default class lspClient {
307339 modes : this . modes ,
308340 type : "socket" ,
309341 socket : this . socket ,
342+ serviceName : "lspClient" ,
310343 initializationOptions : this . initializationOptions ,
311344 } ;
312345
You can’t perform that action at this time.
0 commit comments