Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.exclude": {
"rascal-lsp": true,
"rascal-vscode-extension": true
}
}
4 changes: 4 additions & 0 deletions rascal-language-servers.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
},
{
"path": "rascal-vscode-extension"
},
{
"name": "root",
"path": "."
}
],
"extensions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,17 @@ private static <T> T last(List<T> l) {
}

private Optional<String> safeLanguage(ISourceLocation loc) {
return Optional.ofNullable(registeredExtensions.get(extension(loc)));
var ext = extension(loc);
if ("".equals(ext)) {
if (contributions.size() == 1) {
logger.trace("file was opened without an extension; falling back to the single registered language for: {}", loc);
return contributions.keySet().stream().findFirst();
} else {
logger.error("file was opened without an extension and there are multiple languages registered, so we cannot pick a fallback for: {}", loc);
return Optional.empty();
}
}
return Optional.ofNullable(registeredExtensions.get(ext));
}

private String language(ISourceLocation loc) {
Expand Down
41 changes: 37 additions & 4 deletions rascal-vscode-extension/src/test/vscode-suite/dsl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import { SideBarView, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
import { InputBox, TextEditor, SideBarView, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
import { Delays, IDEOperations, ignoreFails, printRascalOutputOnFailure, RascalREPL, sleep, TestWorkspace } from './utils';

import { expect } from 'chai';
Expand Down Expand Up @@ -75,7 +75,6 @@ parameterizedDescribe(function (errorRecovery: boolean) {
await repl.terminate();
}


before(async () => {
browser = VSBrowser.instance;
driver = browser.driver;
Expand Down Expand Up @@ -103,7 +102,7 @@ parameterizedDescribe(function (errorRecovery: boolean) {
await fs.writeFile(TestWorkspace.picoFile, picoFileBackup);
});

it("have highlighting and parse errors", async function () {
it("has highlighting and parse errors", async function () {
await ignoreFails(new Workbench().getEditorView().closeAllEditors());
const editor = await ide.openModule(TestWorkspace.picoFile);
const isPicoLoading = ide.statusContains("Pico");
Expand All @@ -126,7 +125,7 @@ parameterizedDescribe(function (errorRecovery: boolean) {
}
}).retries(2);

it("have highlighting and parse errors for second extension", async function () {
it("has highlighting and parse errors for second extension", async function () {
const editor = await ide.openModule(TestWorkspace.picoNewFile);
await ide.hasSyntaxHighlighting(editor);
try {
Expand All @@ -137,6 +136,40 @@ parameterizedDescribe(function (errorRecovery: boolean) {
}
});

it("has syntax highlighting in documents without extension", async function () {
await bench.executeCommand("workbench.action.files.newUntitledFile");
await bench.executeCommand("workbench.action.editor.changeLanguageMode");

const inputBox = new InputBox();
await inputBox.setText("parametric-rascalmpl");
await inputBox.confirm();

const file = "Untitled-1";
const editor = await driver.wait(async () => {
const result = await ignoreFails(new Workbench().getEditorView().openEditor(file)) as TextEditor;
if (result && await ignoreFails(result.getTitle()) === file) {
return result;
}
return undefined! as TextEditor;
}, Delays.normal, "Could not open file");
expect(editor).to.not.be.undefined;

await editor.setText(`begin
declare
a : natural;
a := 2
end
`);
await ide.hasSyntaxHighlighting(editor, Delays.slow);

try {
await editor.setTextAtLine(4, " a := ");
await ide.hasErrorSquiggly(editor, Delays.slow);
} finally {
await ide.revertOpenChanges();
}
}).retries(2);

it("error recovery works", async function () {
if (!errorRecovery) { this.skip(); }
const editor = await ide.openModule(TestWorkspace.picoNewFile);
Expand Down
Loading