diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java index 402e3f452..0b69721bd 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java @@ -38,6 +38,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.function.Function; @@ -166,12 +167,15 @@ IFunction makeParseTreeGetter(Evaluator e) { return e.getFunctionValueFactory().function(getParseTreeType, (t, u) -> { ISourceLocation resolvedLocation = Locations.toClientLocation((ISourceLocation) t[0]); try { - var tree = rascalTextDocumentService.getFile(resolvedLocation).getLastTreeWithoutErrors(); + var tree = rascalTextDocumentService.getFile(resolvedLocation).getCurrentTreeAsync(false).get(); if (tree != null) { return tree.get(); } - } catch (ResponseErrorException e1) { - // File is not open in the IDE + } catch (ResponseErrorException | ExecutionException e1) { + // File is not open in the IDE | Parse threw an exception + // In either case, fall through and try a direct parse + } catch (InterruptedException e1) { + Thread.currentThread().interrupt(); } // Parse the source file try (var reader = URIResolverRegistry.getInstance().getCharacterReader(resolvedLocation)) { diff --git a/rascal-vscode-extension/src/test/vscode-suite/ide.test.ts b/rascal-vscode-extension/src/test/vscode-suite/ide.test.ts index a8a801f9e..c8a941ee9 100644 --- a/rascal-vscode-extension/src/test/vscode-suite/ide.test.ts +++ b/rascal-vscode-extension/src/test/vscode-suite/ide.test.ts @@ -58,7 +58,10 @@ describe('IDE', function () { await makeSureRascalModulesAreLoaded(); }); - beforeEach(async () => { + beforeEach(async function () { + if (this.test?.title) { + await ide.screenshot("IDE-" + this.test?.title); + } }); afterEach(async function () { @@ -157,11 +160,6 @@ describe('IDE', function () { }); it("go to definition works across projects", async () => { - // due to a current bug, we have to make sure that the lib in the other project is correctly resolved - const libEditor = await ide.openModule(TestWorkspace.libFile); - await triggerTypeChecker(libEditor, "", true); - await bench.getEditorView().closeAllEditors(); - const editor = await ide.openModule(TestWorkspace.libCallFile); await triggerTypeChecker(editor, TestWorkspace.libCallFileTpl, true); await editor.selectText("fib"); diff --git a/rascal-vscode-extension/src/test/vscode-suite/utils.ts b/rascal-vscode-extension/src/test/vscode-suite/utils.ts index 30cfb41f2..39117c249 100644 --- a/rascal-vscode-extension/src/test/vscode-suite/utils.ts +++ b/rascal-vscode-extension/src/test/vscode-suite/utils.ts @@ -25,13 +25,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -import { assert } from "chai"; +import { assert, expect } from "chai"; import { stat, unlink } from "fs/promises"; -import path = require("path"); +import * as os from 'os'; import { env } from "process"; import { BottomBarPanel, By, CodeLens, EditorView, Key, Locator, TerminalView, TextEditor, VSBrowser, WebDriver, WebElement, WebElementCondition, Workbench, until } from "vscode-extension-tester"; -import * as os from 'os'; -import { expect } from 'chai'; +import path = require("path"); export async function sleep(ms: number) { return new Promise(r => setTimeout(r, ms)); @@ -278,8 +277,9 @@ export class IDEOperations { try { await new Workbench().executeCommand("workbench.action.revertAndCloseActiveEditor"); } catch (ex) { - this.screenshot("revert failed " + tryCount); - console.log("Revert failed, but we ignore it", ex); + const title = ignoreFails(new TextEditor().getTitle()) ?? 'unknown'; + this.screenshot(`revert of ${title} failed ` + tryCount); + console.log(`Revert of ${title} failed, but we ignore it`, ex); } try { let anyEditor = true; @@ -295,7 +295,7 @@ export class IDEOperations { } catch (ignored) { this.screenshot("open editor check failed " + tryCount); - console.log("Open editor dirtry check failed: ", ignored); + console.log("Open editor dirty check failed: ", ignored); return false; } @@ -313,12 +313,18 @@ export class IDEOperations { }, Delays.normal, "Could not open file") as Promise; } + async appendSpace(editor: TextEditor, line = 1) { + const prompt = await new Workbench().openCommandPrompt(); + await prompt.setText(`:${line},10000`); + await prompt.confirm(); + await editor.typeText(' '); + } + async triggerTypeChecker(editor: TextEditor, { checkName = "Rascal check", waitForFinish = false, timeout = Delays.verySlow, tplFile = "" } = {}) { - const lastLine = await editor.getNumberOfLines(); if (tplFile) { await ignoreFails(unlink(tplFile)); } - await editor.setTextAtLine(lastLine, await editor.getTextAtLine(lastLine) + " "); + await this.appendSpace(editor); await sleep(50); await editor.save(); if (waitForFinish) {