Skip to content

Commit 0994a3c

Browse files
committed
cleanup comments and import
1 parent 168efff commit 0994a3c

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

src/documentParser.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class DocumentParser {
1818

1919
for (var i = 0, length = functions.length; i < length; ++i) {
2020
const func = functions[i];
21-
// only return functions with stopped location in range
21+
// Only return functions with stopped location inside range
2222
if (func.range.start.line <= stoppedStart && func.range.end.line >= stoppedEnd && func.range.contains(stoppedLocation)) {
2323
res.push(func);
2424
}
@@ -37,7 +37,7 @@ export class DocumentParser {
3737
let functions: vscode.DocumentSymbol[] = [];
3838

3939
if (documentSymbols) {
40-
// flatten symbols and keep only functions
40+
// Get all functions in a flat array from the symbol-tree
4141
functions = utils.flattenSymbols(documentSymbols).filter(s => s.kind === vscode.SymbolKind.Function);
4242
}
4343

@@ -50,7 +50,7 @@ export class DocumentParser {
5050
return 0;
5151
}
5252

53-
// Lookup closest matching function start or default to document start (0)
53+
// Lookup closest matching function start line or default to document start (0)
5454
const functions = await this.getFunctionsInScope(document, stoppedLocation);
5555
return Math.max(0, ...functions.map(fn => fn.range.start.line));
5656
}
@@ -62,14 +62,16 @@ export class DocumentParser {
6262

6363
for (var i = 0, length = functions.length; i < length; ++i) {
6464
const func = functions[i];
65-
// startLine (either document start or closest function start) are provided, so functions necessary to exclude
65+
// tartLine (either document start or closest function start) are provided, so functions necessary to exclude
6666
// will always start >= documentStart or same as currentFunction start if nested function.
6767
// Don't bother checking functions before startLine or after stoppedLocation
6868
if (func.range.start.line >= startLine && func.range.start.line <= stoppedEnd && !func.range.contains(stoppedLocation)) {
6969
const functionRange = utils.range(func.range.start.line, func.range.end.line);
7070
excludedLines.push(...functionRange);
7171
}
7272
}
73+
74+
// Ensure we don't exclude our stopped location and make lookup blazing fast
7375
return new Set(excludedLines.filter(line => line < stoppedLocation.start.line || line > stoppedEnd));
7476
}
7577
}

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function activate(context: vscode.ExtensionContext) {
77

88
context.subscriptions.push(vscode.languages.registerInlineValuesProvider('powershell', new PowerShellVariableInlineValuesProvider(parser)));
99

10-
// Clear function cache to get updated files in next debug session
10+
// Clear function symbol cache to ensure we get symbols from any updated files
1111
context.subscriptions.push(
1212
vscode.debug.onDidTerminateDebugSession((e) => {
1313
if (e.type.toLowerCase() === 'powershell') {

src/test/suite/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
22
import * as Mocha from 'mocha';
33
import * as glob from 'glob';
4-
import * as testUtils from '../testUtils';
4+
import { ensureEditorServicesIsConnected } from '../testUtils';
55

66
export async function run(): Promise<void> {
77
// Create the mocha test
@@ -13,7 +13,7 @@ export async function run(): Promise<void> {
1313
const testsRoot = path.resolve(__dirname, '..');
1414

1515
// Ensure PowerShell extension is finished starting because we need it's symbol provider
16-
await testUtils.ensureEditorServicesIsConnected();
16+
await ensureEditorServicesIsConnected();
1717

1818
return new Promise((c, e) => {
1919
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {

src/test/testUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface IPowerShellExtensionClient {
2121
}
2222

2323
/**
24-
* ensureEditorServicesIsConnected
24+
* Modified version of ensureEditorServicesIsConnected()
2525
* https://github.com/PowerShell/vscode-powershell/blob/c323846803f0d43f75562a7fd1e8c225099cc528/test/utils.ts#L17-L21
2626
*/
2727
export async function ensureExtensionIsActivated(): Promise<vscode.Extension<any>> {
@@ -31,7 +31,7 @@ export async function ensureExtensionIsActivated(): Promise<vscode.Extension<any
3131
}
3232

3333
/**
34-
* ensureEditorServicesIsConnected
34+
* ensureEditorServicesIsConnected()
3535
* https://github.com/PowerShell/vscode-powershell/blob/c323846803f0d43f75562a7fd1e8c225099cc528/test/utils.ts#L23-L29
3636
*/
3737
export async function ensureEditorServicesIsConnected(): Promise<void> {

src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { DocumentSymbol } from 'vscode';
22

3+
// Because 1..10 isn't supported here...
34
export function range(start: number, end: number) {
45
return Array(end - start + 1).fill(undefined).map((_, i) => start + i);
56
}
67

8+
// Convert the symbol-tree to a flat array
79
export function flattenSymbols(symbols: DocumentSymbol[]): DocumentSymbol[] {
810
let result: DocumentSymbol[] = [];
911
symbols.map(symbol => {

0 commit comments

Comments
 (0)