@@ -6,10 +6,12 @@ import { SymbolProvider } from './languages/symbolProvider';
66import { Token , TokenType } from './languages/tokens' ;
77import { Dictionary , Future } from './utils' ;
88import { EndpointInfo , SpanLocationInfo as SpanLocationInfo , SymbolInfo , IParametersExtractor , CodeObjectLocationInfo , ISymbolAliasExtractor } from './languages/extractors' ;
9- import { InstrumentationInfo } from './EditorHelper' ;
9+ import { InstrumentationInfo , LocateEndpointInfo } from './EditorHelper' ;
1010import { SymbolInformation } from 'vscode' ;
1111import { WorkspaceState } from '../state' ;
1212import { CodeObjectInsight } from '../views/codeAnalytics/InsightListView/IInsightListViewItemsCreator' ;
13+ import { PathUtils } from './common/pathUtils' ;
14+ import { PossibleCodeObjectLocation } from './languages/modulePathToUriConverters' ;
1315
1416export class DocumentInfoProvider implements vscode . Disposable
1517{
@@ -67,86 +69,15 @@ export class DocumentInfoProvider implements vscode.Disposable
6769 }
6870 }
6971
72+ public async searchForEndpoint ( locationInfo : LocateEndpointInfo ) : Promise < SpanLocationInfo | undefined > {
7073
71- public async searchForSpan ( instrumentationInfo : InstrumentationInfo ) : Promise < SpanLocationInfo | undefined > {
72- const codeFileHint = instrumentationInfo . instrumentationName ;
73-
74- if ( codeFileHint ) {
75-
76- //try to find code object by span name
77- if ( vscode . window . activeTextEditor ?. document . fileName . toLocaleLowerCase ( ) . endsWith ( ".go" ) ) {
78-
79- //TODO: change to use document info we alrady scanned
80- let regex = / ( \( \* ? .* \) .* ) / ;
81- //workaround for GO
82- let match = instrumentationInfo . fullName ?. match ( regex ) ?. firstOrDefault ( ) ;
83- if ( match ) {
84- match = match ?. replace ( "(*" , "" ) . replace ( ")" , "" ) ;
85- let codeLocations :SymbolInformation [ ] = await vscode . commands . executeCommand ( "vscode.executeWorkspaceSymbolProvider" , match ) ;
86- if ( codeLocations ) {
87- codeLocations = codeLocations . filter ( x => x . kind === vscode . SymbolKind . Method && x . name === match ) ;
88- if ( codeLocations . length === 1 ) {
89- return new SpanLocationInfo ( instrumentationInfo . fullName ! , instrumentationInfo . spanName ! , [ instrumentationInfo . spanName ! ] , [ ] , codeLocations [ 0 ] . location . range , codeLocations [ 0 ] . location . uri ) ;
90- }
91- }
92- }
93- }
94-
95- //try to find code object by instrumentation name
96-
97-
98-
99- if ( codeFileHint === '__main__' ) {
100-
101- let doc = vscode . window . activeTextEditor ?. document ;
102- if ( doc ) {
103- const docInfo = await this . getDocumentInfo ( doc ) ;
104- if ( docInfo ) {
105- let spanInfos = docInfo . spans . filter ( span => span . aliases . any ( x => x === instrumentationInfo . spanName ) ) ;
106- return spanInfos . firstOrDefault ( x => x !== undefined ) ;
107-
108- }
109-
110- }
111-
112- }
113- else {
114-
115- let codeHintFiles = codeFileHint . split ( ' ' ) ;
116- let head = codeHintFiles [ 0 ] ;
117- let folder = await vscode . workspace . workspaceFolders ?. find ( w => w . name === head ) ;
118- let tail = codeHintFiles ;
119-
120- if ( folder ) {
121- tail = codeHintFiles . slice ( 1 ) ;
122- }
123-
124- if ( codeHintFiles . length >= 1 ) {
125- const files = await vscode . workspace . findFiles ( `**/${ tail . join ( '/' ) } .*` ) ;
126-
127- const spansPromises = files . map ( async file => {
128- try {
129- const doc = await vscode . workspace . openTextDocument ( file ) ;
130- const docInfo = await this . getDocumentInfo ( doc ) ;
131- if ( docInfo ) {
132- return docInfo . spans . filter ( span => span . name === instrumentationInfo . spanName ) ;
133- }
134- }
135- catch ( error ) {
136- Logger . warn ( `Searching for span "${ instrumentationInfo . spanName } " skipped ${ file . fsPath } ` , error ) ;
137- }
138- return [ ] ;
139- } ) ;
140-
141- const spnaInfos = ( await Promise . all ( spansPromises ) ) . flat ( ) . firstOrDefault ( x => x !== undefined ) ;
142- return spnaInfos ;
143- }
144- }
74+ if ( locationInfo . codeObjectId ) {
14575
146-
14776 }
148- }
14977
78+ return undefined ;
79+ }
80+
15081 public async refresh ( doc : vscode . TextDocument ) {
15182
15283 const docRelativePath = doc . uri . toModulePath ( ) ;
0 commit comments