3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
import * as http from 'http' ;
6
- import { SidecarApplyEditsRequest , SidecarDiagnosticsRequest , SidecarGoToDefinitionRequest , SidecarGoToImplementationRequest , SidecarOpenFileToolRequest , SidecarQuickFixInvocationRequest , SidecarQuickFixRequest } from './types' ;
6
+ import { SidecarApplyEditsRequest , SidecarDiagnosticsRequest , SidecarGoToDefinitionRequest , SidecarGoToImplementationRequest , SidecarGoToReferencesRequest , SidecarOpenFileToolRequest , SidecarQuickFixInvocationRequest , SidecarQuickFixRequest } from './types' ;
7
7
import { Position , Range } from 'vscode' ;
8
8
import { getDiagnosticsFromEditor } from './diagnostics' ;
9
9
import { openFileEditor } from './openFile' ;
@@ -12,6 +12,7 @@ import { SIDECAR_CLIENT } from '../extension';
12
12
import { goToImplementation } from './goToImplementation' ;
13
13
import { quickFixInvocation , quickFixList } from './quickFix' ;
14
14
import { applyEdits } from './applyEdits' ;
15
+ import { goToReferences } from './goToReferences' ;
15
16
16
17
// Helper function to read the request body
17
18
function readRequestBody ( req : http . IncomingMessage ) : Promise < string > {
@@ -95,6 +96,13 @@ export async function handleRequest(req: http.IncomingMessage, res: http.ServerR
95
96
const response = await applyEdits ( request ) ;
96
97
res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
97
98
res . end ( JSON . stringify ( response ) ) ;
99
+ } else if ( req . method === 'POST' && req . url === '/go_to_references' ) {
100
+ console . log ( 'go-to-references' ) ;
101
+ const body = await readRequestBody ( req ) ;
102
+ const request : SidecarGoToReferencesRequest = JSON . parse ( body ) ;
103
+ const response = await goToReferences ( request ) ;
104
+ res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
105
+ res . end ( JSON . stringify ( response ) ) ;
98
106
} else {
99
107
console . log ( 'HC request' ) ;
100
108
res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
0 commit comments