MCPcopy Create free account
hub / github.com/angular/angular / run

Function run

ngp-vscode-ng-language-service/e2e/src/hover.ts:14–360  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12import {waitFor} from './utils';
13
14export async function run() {
15 const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
16 if (!workspaceRoot) {
17 throw new Error('No workspace root found');
18 }
19
20 const testFilePath = path.join(workspaceRoot, 'app.ts');
21 const uri = vscode.Uri.file(testFilePath);
22
23 console.log(`Open file: ${testFilePath}`);
24 const document = await vscode.workspace.openTextDocument(uri);
25 await vscode.window.showTextDocument(document);
26
27 // Position of 'route' declaration (line 35, character 12) -> 0-indexed line 34
28 const routeParamPosition = new vscode.Position(34, 12);
29 console.log(`Querying hover for route param at Position(34, 12)...`);
30 // Check if Angular LS is ready
31 // Poll for hover results to wait for server to start
32 const routeParamHovers = await waitFor(
33 () =>
34 vscode.commands.executeCommand<vscode.Hover[]>(
35 'vscode.executeHoverProvider',
36 uri,
37 routeParamPosition,
38 ),
39 (hovers) => !!hovers && hovers.length > 0,
40 );
41
42 assert.ok(
43 routeParamHovers && routeParamHovers.length > 0,
44 'Should return at least one hover for route param',
45 );
46 const routeParamHover = routeParamHovers[0];
47 const routeParamValue = (routeParamHover.contents[0] as vscode.MarkdownString).value;
48 console.log(`Hover value for route param: ${routeParamValue}`);
49 assert.ok(routeParamValue.includes('title'), 'Hover should include type info for route param');
50
51 // Position of '$index' (line 35, character 33) -> 0-indexed line 34
52 const indexPosition = new vscode.Position(34, 33);
53 console.log(`Querying hover for $index at Position(34, 33)...`);
54 const indexHovers = await vscode.commands.executeCommand<vscode.Hover[]>(
55 'vscode.executeHoverProvider',
56 uri,
57 indexPosition,
58 );
59
60 assert.ok(indexHovers && indexHovers.length > 0, 'Should return at least one hover for $index');
61 const indexHover = indexHovers[0];
62 const indexValue = (indexHover.contents[0] as vscode.MarkdownString).value;
63 console.log(`Hover value for $index: ${indexValue}`);
64 assert.ok(
65 indexValue.includes('number') || indexValue.includes('unknown'),
66 'Hover should include type info for $index',
67 );
68
69 const titlePosition = new vscode.Position(43, 60);
70 console.log(`Querying hover for route.title at Position(43, 60)...`);
71 const titleHovers = await vscode.commands.executeCommand<vscode.Hover[]>(

Callers

nothing calls this directly

Calls 9

waitForFunction · 0.90
setTimeoutFunction · 0.85
okMethod · 0.80
getTextMethod · 0.80
joinMethod · 0.65
logMethod · 0.65
fileMethod · 0.45
findMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected