|
1 | 1 | import { setInterval, clearInterval } from 'timers'; |
2 | 2 | import * as vscode from 'vscode'; |
3 | | -import { AnalyticsProvider, CodeObjectSummary, MethodCodeObjectSummary } from './analyticsProvider'; |
| 3 | +import { AnalyticsProvider, CodeObjectSummary, EndpointCodeObjectSummary, EndpointSchema, MethodCodeObjectSummary } from './analyticsProvider'; |
4 | 4 | import { Logger } from "./logger"; |
5 | 5 | import { SymbolProvider } from './languages/symbolProvider'; |
6 | 6 | import { Token, TokenType } from './languages/tokens'; |
@@ -169,14 +169,39 @@ export class DocumentInfoProvider implements vscode.Disposable |
169 | 169 | const tokens = await this.symbolProvider.getTokens(doc); |
170 | 170 | const endpoints = await this.symbolProvider.getEndpoints(doc, symbolInfos, tokens, symbolTrees, this); |
171 | 171 | 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)) |
179 | 177 | ); |
| 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 | + |
180 | 205 | const lines = this.createLineInfos(doc, summaries, methodInfos); |
181 | 206 | latestVersionInfo.value = { |
182 | 207 | summaries, |
|
0 commit comments