@@ -5,7 +5,7 @@ import { Logger } from "./logger";
55import { SymbolProvider } from './languages/symbolProvider' ;
66import { Token , TokenType } from './languages/tokens' ;
77import { Dictionary , Future } from './utils' ;
8- import { EndpointInfo , SpanLocationInfo as SpanLocationInfo , SymbolInfo , IParametersExtractor , CodeObjectLocationInfo } from './languages/extractors' ;
8+ import { EndpointInfo , SpanLocationInfo as SpanLocationInfo , SymbolInfo , IParametersExtractor , CodeObjectLocationInfo , ISymbolAliasExtractor } from './languages/extractors' ;
99import { InstrumentationInfo } from './EditorHelper' ;
1010import { SymbolInformation } from 'vscode' ;
1111import { WorkspaceState } from '../state' ;
@@ -186,7 +186,9 @@ export class DocumentInfoProvider implements vscode.Disposable
186186 const endpoints = await this . symbolProvider . getEndpoints ( doc , symbolInfos , tokens , symbolTrees , this ) ;
187187 const spans = await this . symbolProvider . getSpans ( doc , symbolInfos , tokens ) ;
188188 const paramsExtractor = await this . symbolProvider . getParametersExtractor ( doc ) ;
189- let methodInfos = await this . createMethodInfos ( doc , paramsExtractor , symbolInfos , tokens , spans , endpoints ) ;
189+ const symbolAliasExtractor = await this . symbolProvider . getSymbolAliasExtractor ( doc ) ;
190+
191+ let methodInfos = await this . createMethodInfos ( doc , paramsExtractor , symbolAliasExtractor , symbolInfos , tokens , spans , endpoints ) ;
190192
191193 let codeObjectIds = methodInfos . flatMap ( s => s . idsWithType )
192194 . concat ( endpoints . flatMap ( e => e . idsWithType ) )
@@ -230,7 +232,7 @@ export class DocumentInfoProvider implements vscode.Disposable
230232 // These are spans that the server is aware of but the client can't discover
231233 const spansDiscoveredViaServer = insightsResult
232234 . filter ( x => x . scope == "Span" )
233- . filter ( x => ! spans . any ( e => e . id === x . codeObjectId ) ) ;
235+ . filter ( x => ! spans . any ( e => e . id === x . codeObjectId ) ) ; //why we assume the the codeobjectid is span codeobject id, the output is that these span are spans discovered by server
234236
235237 const uniqueSpans = [ ...new Map ( spansDiscoveredViaServer . map ( item =>
236238 [ item . codeObjectId , item ] ) ) . values ( ) ] ;
@@ -253,7 +255,7 @@ export class DocumentInfoProvider implements vscode.Disposable
253255 }
254256 }
255257
256- const newMethodInfos = await this . createMethodInfos ( doc , paramsExtractor , symbolInfos , tokens , spans , endpoints ) ;
258+ const newMethodInfos = await this . createMethodInfos ( doc , paramsExtractor , symbolAliasExtractor , symbolInfos , tokens , spans , endpoints ) ;
257259 methodInfos = newMethodInfos ;
258260 const insights = new CodeObjectInsightsAccessor ( insightsResult ) ;
259261 //const lines:LineInfo[] = [];
@@ -306,20 +308,15 @@ export class DocumentInfoProvider implements vscode.Disposable
306308 private async createMethodInfos (
307309 document : vscode . TextDocument ,
308310 parametersExtractor : IParametersExtractor ,
311+ symbolAliasExtractor : ISymbolAliasExtractor ,
309312 symbols : SymbolInfo [ ] ,
310313 tokens : Token [ ] ,
311314 spans : SpanLocationInfo [ ] ,
312315 endpoints : EndpointInfo [ ] ,
313316 ) : Promise < MethodInfo [ ] > {
314- const codeObjectIdParser = await this . symbolProvider . getCodeObjectIdParser ( document ) ;
315- if ( ! codeObjectIdParser ) {
316- return [ ] ;
317- }
318-
319317 let methods : MethodInfo [ ] = [ ] ;
320-
321318 for ( let symbol of symbols ) {
322- const aliases = codeObjectIdParser . generateAliases ( symbol . id ) ;
319+ const aliases = symbolAliasExtractor . extractAliases ( symbol ) ;
323320 const method = new MethodInfo (
324321 symbol . id ,
325322 symbol . name ,
@@ -379,7 +376,7 @@ export class DocumentInfoProvider implements vscode.Disposable
379376 const lineInfosByEnv : ElementsByEnv < LineInfo > = new ElementsByEnv < LineInfo > ( state ) ;
380377 for ( let method of methods )
381378 {
382- const codeObjectSummary = methodSummaries . find ( x => method . aliases . any ( a => a == x . codeObjectId ) ) ;
379+ const codeObjectSummary = methodSummaries . find ( x => method . ids . any ( a => a == x . codeObjectId ) ) ;
383380 if ( ! codeObjectSummary )
384381 continue ;
385382
@@ -579,12 +576,10 @@ export class CodeObjectInsightsAccessor{
579576
580577
581578 public forMethod ( methodInfo : MethodInfo , environment : string | undefined ) {
582- const codeObjectsIds = methodInfo . aliases
583- . concat ( methodInfo . relatedCodeObjects . flatMap ( r => r . ids ) ) ;
584-
579+ const codeObjectsIds = methodInfo . getIds ( true , false ) ;
585580 let insights = this . _codeObjectInsights . filter ( x => codeObjectsIds . any ( o => o == x . codeObjectId ) ) ;
586581 if ( environment ) {
587- insights = insights . filter ( x => x . environment == environment ) ;
582+ insights = insights . filter ( x => x . environment === environment ) ;
588583 }
589584 return insights ;
590585
@@ -616,7 +611,7 @@ export class MethodInfo implements CodeObjectLocationInfo
616611 public range : vscode . Range ,
617612 public parameters : ParameterInfo [ ] ,
618613 public symbol : SymbolInfo ,
619- public aliases : string [ ] ,
614+ private aliases : string [ ] ,
620615 public relatedCodeObjects : CodeObjectLocationInfo [ ] ,
621616 public documentUri : vscode . Uri ) { }
622617
@@ -635,7 +630,18 @@ export class MethodInfo implements CodeObjectLocationInfo
635630 ] ;
636631 }
637632
638-
633+ public getIds ( includeRelated : boolean = false , withType : boolean = false ) : string [ ] {
634+ if ( includeRelated ) {
635+ if ( withType ) {
636+ return [ ...new Set ( this . idsWithType . concat ( this . relatedCodeObjects . flatMap ( r => r . idsWithType ) ) ) ] ;
637+ }
638+ return [ ...new Set ( this . ids . concat ( this . relatedCodeObjects . flatMap ( r => r . ids ) ) ) ] ;
639+ }
640+ if ( withType ) {
641+ return this . idsWithType ;
642+ }
643+ return this . ids ;
644+ }
639645}
640646
641647export interface ParameterInfo
0 commit comments