Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
award999 committed Jan 8, 2025
1 parent f793311 commit 00004d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ suite("Language Client Integration Suite @slow", function () {
},
});

setup(async () => {
await waitForIndex(workspaceContext.languageClientManager);
});

test("Expand Macro", async function () {
// Expand Macro support in Swift started from 6.1
if (workspaceContext.swiftVersion.isLessThan(new Version(6, 1, 0))) {
Expand All @@ -68,18 +72,13 @@ suite("Language Client Integration Suite @slow", function () {
await vscode.window.showTextDocument(uri);
await workspaceContext.focusFolder(macroFolderContext);

console.log("here 1");

// Beginning of macro, #
const position = new vscode.Position(5, 21);

// Create a range starting and ending at the specified position
const range = new vscode.Selection(position, position.with({ character: 22 }));

await waitForIndex(workspaceContext.languageClientManager);
console.log("here 2");
await waitForCodeActions(workspaceContext.languageClientManager, uri, range);
console.log("here 3");

// Execute the code action provider command
const codeActions = await vscode.commands.executeCommand<vscode.CodeAction[]>(
Expand All @@ -96,8 +95,6 @@ suite("Language Client Integration Suite @slow", function () {
// Assert that the expand macro command is available
expect(expandMacroAction).is.not.undefined;

console.log("here 4");

// Set up a promise that resolves when the expected document is opened
const expandedMacroUriPromise = new Promise<vscode.TextDocument>((resolve, reject) => {
const disposable = vscode.workspace.onDidOpenTextDocument(openedDocument => {
Expand All @@ -119,11 +116,9 @@ suite("Language Client Integration Suite @slow", function () {
expect(command.arguments).is.not.undefined;
const commandArgs = command.arguments!;
await vscode.commands.executeCommand(command.command, ...commandArgs);
console.log("here 5");

// Wait for the expanded macro document to be opened
const referenceDocument = await expandedMacroUriPromise;
console.log("here 6");

// Verify that the reference document was successfully opened
expect(referenceDocument).to.not.be.undefined;
Expand Down
31 changes: 0 additions & 31 deletions test/integration-tests/utilities/lsputilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,6 @@ export async function waitForClientState(
);
}

export async function waitForSymbols(
languageClientManager: LanguageClientManager,
uri: vscode.Uri
): Promise<langclient.DocumentSymbol[] | langclient.SymbolInformation[]> {
let symbols: langclient.DocumentSymbol[] | langclient.SymbolInformation[] = [];
while (symbols?.length === 0) {
symbols =
(await languageClientManager.useLanguageClient(async (client, token) =>
client.sendRequest(
langclient.DocumentSymbolRequest.type,
{ textDocument: langclient.TextDocumentIdentifier.create(uri.toString()) },
token
)
)) || [];
console.warn("Language client is not ready yet. Retrying in 100 ms...");
await new Promise(resolve => setTimeout(resolve, 100));
}
return (
(await waitForClient(
languageClientManager,
async (client, token) =>
client.sendRequest(
langclient.DocumentSymbolRequest.type,
{ textDocument: langclient.TextDocumentIdentifier.create(uri.toString()) },
token
),
s => (s || []).length > 0
)) || []
);
}

export async function waitForCodeActions(
languageClientManager: LanguageClientManager,
uri: vscode.Uri,
Expand Down

0 comments on commit 00004d8

Please sign in to comment.