Skip to content

Commit ee3f08e

Browse files
committed
adding logs for error lookups and fixing issue with runtime data not appearing
1 parent 98f341c commit ee3f08e

File tree

2 files changed

+62
-26
lines changed

2 files changed

+62
-26
lines changed

src/analyticsCodeLens.ts

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
7676

7777
}
7878

79+
private async getRuntimeDataExistsLens(methodInfo: MethodInfo) :Promise<vscode.CodeLens>{
80+
return new vscode.CodeLens(methodInfo.range, {
81+
title: "Runtime data",
82+
tooltip: "Click to see this function's runtime data",
83+
command: CodelensProvider.clickCommand,
84+
arguments: [methodInfo, this._state.environment]
85+
86+
87+
});
88+
}
89+
7990

8091
private async getCodeLens(methodInfo: MethodInfo,
8192
codeObjectInfo:CodeObjectLocationInfo,
@@ -177,48 +188,50 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
177188
public async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.CodeLens[]>
178189
{
179190
if (!Settings.enableCodeLens.value)
180-
return [];
191+
{return [];}
181192

182193
const documentInfo = await this._documentInfoProvider.getDocumentInfo(document);
183194
if(!documentInfo)
184-
return [];
195+
{return [];}
185196

186197
const codelens: vscode.CodeLens[] = [];
187198
for(let methodInfo of documentInfo.methods)
188199
{
200+
const methodCodeLens: vscode.CodeLens[] = [];
201+
189202
for (let alias of methodInfo.ids){
190-
const insights = documentInfo.insights.all.filter(x=>x.codeObjectId== alias)
191-
.filter(x=>x.scope=="Function");
203+
const insights = documentInfo.insights.all
204+
.filter(x=>x.codeObjectId == alias);
192205

193-
const thisEnvInsights = insights.filter(x=>x.environment==this._state.environment);
206+
const thisEnvInsights = insights
207+
.filter(x=>x.environment == this._state.environment);
194208

195-
const lenses = await this.getCodeLens(methodInfo,methodInfo,thisEnvInsights, documentInfo.usageData.getAll(),false);
209+
const lenses = await this.getCodeLens(methodInfo,methodInfo,
210+
thisEnvInsights.filter(x=>x.scope=="Function"),
211+
documentInfo.usageData.getAll(),false);
212+
196213
for (const lens of lenses){
197-
codelens.push(lens);
214+
methodCodeLens.push(lens);
198215
}
199216

200-
if (lenses.length===0 && thisEnvInsights.length>0){
201-
codelens.push(new vscode.CodeLens(methodInfo.range, {
202-
title: "Runtime data",
203-
tooltip: "Click to see this function's runtime data",
204-
command: CodelensProvider.clickCommand,
205-
arguments: [methodInfo, this._state.environment]
206-
}));
207-
208-
217+
if (methodCodeLens.length===0 && thisEnvInsights.length>0){
218+
methodCodeLens.push(await this.getRuntimeDataExistsLens(methodInfo));
209219
}
210220

211221
}
212222

213223
let spans = documentInfo.spans.filter(e => e.range.intersection(methodInfo.range) != undefined);
214-
let duplicates = spans.filter(x=>documentInfo.spans.any(span=>span!=x && span.name==x.name && span.range!=x.range));
224+
let duplicates = spans
225+
.filter(x=>documentInfo.spans
226+
.any(span=>span!=x && span.name==x.name && span.range!=x.range));
227+
215228
spans=spans.filter(span=>!duplicates.includes(span));
216229

217230
if(duplicates.length>0){
218231
const lenses = await this.getDuplicateSpanLens(methodInfo, duplicates);
219232

220233
for (const lens of lenses){
221-
codelens.push(lens);
234+
methodCodeLens.push(lens);
222235
}
223236

224237
}
@@ -227,8 +240,8 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
227240
spans,documentInfo.usageData.getAll(),documentInfo.insights.all.filter(x=>x.scope=="Span"));
228241

229242
for (const lens of lenses){
230-
codelens.push(lens);
231-
}
243+
methodCodeLens.push(lens);
244+
}
232245

233246
}
234247

@@ -240,11 +253,8 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
240253
uniqueEndpoints,documentInfo.usageData.getAll(),documentInfo.insights.all.filter(x=>x.scope=="EntrySpan"|| x.scope=="Span"),
241254
);
242255

243-
const uniqueLenses =[...new Map(lenses.map(item =>
244-
[item.command!.title, item])).values()];
245-
246-
for (const lens of uniqueLenses){
247-
codelens.push(lens);
256+
for (const lens of lenses){
257+
methodCodeLens.push(lens);
248258
}
249259

250260

@@ -263,10 +273,16 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
263273
const otherEnvLenses = await this.getCodeLens(methodInfo,methodInfo,otherEnvsInsights,
264274
documentInfo.usageData.getAll(),true);
265275
for (const lens of otherEnvLenses){
266-
codelens.push(lens);
276+
methodCodeLens.push(lens);
267277
}
268278

269279
}
280+
281+
const uniqueLenses =[...new Map(methodCodeLens.map(item =>
282+
[item.command!.title, item])).values()];
283+
284+
285+
codelens.push(...uniqueLenses);
270286

271287
}
272288

src/services/languages/modulePathToUriConverters.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as vscode from 'vscode';
2+
import { Settings } from '../../settings';
3+
import { Logger } from '../logger';
24

35
export interface ModulePathInfo {
46
modulePhysicalPath?: string;
@@ -34,13 +36,31 @@ export class PhysicalModulePathToUriConverter implements IModulePathToUriConvert
3436
const moduleRootFolder = modulePhysicalPath.split('/').firstOrDefault();
3537
const moduleWorkspace = vscode.workspace.workspaceFolders?.find(w => w.name === moduleRootFolder);
3638
if (moduleWorkspace) {
39+
if (Settings.enableDebugOutput){
40+
Logger.info(`Looking in workspace folder ${moduleWorkspace}`);
41+
}
3742
const workspaceUri = moduleWorkspace
3843
? vscode.Uri.joinPath(moduleWorkspace.uri, '..', modulePhysicalPath)
3944
: undefined;
4045
return workspaceUri;
4146
}
4247
else {
48+
if (Settings.enableDebugOutput){
49+
Logger.info(`Trying to find file ${modulePhysicalPath}`);
50+
}
51+
if (modulePhysicalPath.indexOf("site-packages")>0){
52+
return undefined;
53+
}
4354
const file = await (await vscode.workspace.findFiles(modulePhysicalPath)).firstOrDefault();
55+
if (Settings.enableDebugOutput){
56+
if (file){
57+
Logger.info(`Found file ${file}`);
58+
}
59+
else {
60+
Logger.info(`File not found`);
61+
62+
}
63+
}
4464
return file;
4565
}
4666
}

0 commit comments

Comments
 (0)