@@ -7,6 +7,7 @@ import { Token, TokenType } from './languages/tokens';
77import { Dictionary , Future } from './utils' ;
88import { EndpointInfo , SpanInfo , SymbolInfo , CodeObjectInfo } from './languages/extractors' ;
99import { InstrumentationInfo } from './EditorHelper' ;
10+ import { SymbolInformation } from 'vscode' ;
1011
1112export class DocumentInfoProvider implements vscode . Disposable
1213{
@@ -47,11 +48,31 @@ export class DocumentInfoProvider implements vscode.Disposable
4748
4849 public async searchForSpan ( instrumentationInfo : InstrumentationInfo ) : Promise < SpanInfo | undefined > {
4950 const codeFileHint = instrumentationInfo . instrumentationName ;
50- if ( codeFileHint ) {
51+
52+ if ( codeFileHint ) {
53+
54+ if ( vscode . window . activeTextEditor ?. document . fileName . toLocaleLowerCase ( ) . endsWith ( ".go" ) ) {
55+
56+ //TODO: change to use document info we alrady scanned
57+ let regex = / ( \( \* ? .* \) .* ) / ;
58+ //workaround for GO
59+ let match = instrumentationInfo . fullName ?. match ( regex ) ?. firstOrDefault ( ) ;
60+ if ( match ) {
61+ match = match ?. replace ( "(*" , "" ) . replace ( ")" , "" ) ;
62+ let codeLocations :SymbolInformation [ ] = await vscode . commands . executeCommand ( "vscode.executeWorkspaceSymbolProvider" , match ) ;
63+ if ( codeLocations ) {
64+ codeLocations = codeLocations . filter ( x => x . kind === vscode . SymbolKind . Method && x . name === match ) ;
65+ if ( codeLocations . length === 1 ) {
66+ return new SpanInfo ( instrumentationInfo . fullName ! , instrumentationInfo . spanName ! , codeLocations [ 0 ] . location . range , codeLocations [ 0 ] . location . uri ) ;
67+ }
68+ }
69+ }
70+ }
71+
5172
5273 if ( codeFileHint === '__main__' ) {
5374
54- let doc = vscode . window . activeTextEditor ?. document
75+ let doc = vscode . window . activeTextEditor ?. document ;
5576 if ( doc ) {
5677 const docInfo = await this . getDocumentInfo ( doc ) ;
5778 if ( docInfo ) {
0 commit comments