Skip to content

Commit f3c6c10

Browse files
committed
fixing high usage docorator
1 parent d9f22fe commit f3c6c10

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

src/services/analyticsProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export class EndpointCodeObjectSummary implements CodeObjectSummary
166166
highUsage: boolean = false;
167167
lowUsage: boolean = false;
168168
maxCallsIn1Min: integer = 0;
169+
route: string='';
169170
}
170171
export class SpanCodeObjectSummary implements CodeObjectSummary
171172
{

src/services/documentInfoProvider.ts

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { setInterval, clearInterval } from 'timers';
22
import * as vscode from 'vscode';
3-
import { AnalyticsProvider, CodeObjectSummary, MethodCodeObjectSummary } from './analyticsProvider';
3+
import { AnalyticsProvider, CodeObjectSummary, EndpointCodeObjectSummary, EndpointSchema, MethodCodeObjectSummary } from './analyticsProvider';
44
import { Logger } from "./logger";
55
import { SymbolProvider } from './languages/symbolProvider';
66
import { Token, TokenType } from './languages/tokens';
@@ -169,14 +169,39 @@ export class DocumentInfoProvider implements vscode.Disposable
169169
const tokens = await this.symbolProvider.getTokens(doc);
170170
const endpoints = await this.symbolProvider.getEndpoints(doc, symbolInfos, tokens, symbolTrees, this);
171171
const spans = await this.symbolProvider.getSpans(doc, symbolInfos, tokens);
172-
const methodInfos = this.createMethodInfos(doc, symbolInfos, tokens, spans, endpoints);
173-
const summaries = new CodeObjectSummaryAccessor(
174-
await this.analyticsProvider.getSummaries(
175-
methodInfos.map(s => s.idWithType)
176-
.concat(endpoints.map(e => e.idWithType))
177-
.concat(spans.map(s => s.idWithType))
178-
)
172+
let methodInfos = this.createMethodInfos(doc, symbolInfos, tokens, spans, endpoints);
173+
const summariesResult = await this.analyticsProvider.getSummaries(
174+
methodInfos.map(s => s.idWithType)
175+
.concat(endpoints.map(e => e.idWithType))
176+
.concat(spans.map(s => s.idWithType))
179177
);
178+
179+
//Get endpoints discovered via server that don't exist in document info
180+
const endPointsDiscoveredViaServer = summariesResult.filter(x=>x.type==='EndpointSummary')
181+
.filter(x=>!endpoints.any(e=>e.id===x.codeObjectId));
182+
183+
for ( const endpoint of endPointsDiscoveredViaServer){
184+
const endPointSummary = endpoint as EndpointCodeObjectSummary;
185+
const shortRouteName = EndpointSchema.getShortRouteName(endPointSummary.route);
186+
const parts = shortRouteName.split(' ');
187+
if (endPointSummary){
188+
const relatedMethod = symbolInfos.filter(x=>x.id===endpoint.codeObjectId).firstOrDefault();
189+
if (relatedMethod){
190+
endpoints.push(new EndpointInfo(
191+
endpoint.codeObjectId,
192+
parts[0],
193+
endPointSummary.route,
194+
relatedMethod.range
195+
,relatedMethod.documentUri));
196+
197+
}
198+
}
199+
}
200+
201+
const newMethodInfos = this.createMethodInfos(doc, symbolInfos, tokens, spans, endpoints);
202+
methodInfos=newMethodInfos;
203+
const summaries = new CodeObjectSummaryAccessor(summariesResult);
204+
180205
const lines = this.createLineInfos(doc, summaries, methodInfos);
181206
latestVersionInfo.value = {
182207
summaries,

0 commit comments

Comments
 (0)