Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes, docs, editor files and examples all use the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f44f09b6a
commit
7cf9727bcd
94 files changed
+858
-858
No files matched your search
+19
-19
@@ -1,7 +1,7 @@
|
||||
//! Tests of the language server: feed it editor messages, read what it answers.
|
||||
|
||||
use dino::json::{self, Json};
|
||||
use dino::lsp;
|
||||
use rex::json::{self, Json};
|
||||
use rex::lsp;
|
||||
|
||||
fn frame(v: &Json) -> Vec<u8> {
|
||||
let body = v.to_string();
|
||||
@@ -68,7 +68,7 @@ fn initialize_announces_features() {
|
||||
#[test]
|
||||
fn errors_show_up_as_diagnostics() {
|
||||
let src = "func main() {\n var x: int = \"no\"\n}\n";
|
||||
let mut msgs = vec![open("file:///tmp/dino-lsp-test/a.dino", src)];
|
||||
let mut msgs = vec![open("file:///tmp/rex-lsp-test/a.rex", src)];
|
||||
msgs.extend(exit_messages());
|
||||
let (out, _) = talk(msgs);
|
||||
let d = match out[0].path(&["params", "diagnostics"]) {
|
||||
@@ -83,7 +83,7 @@ fn errors_show_up_as_diagnostics() {
|
||||
|
||||
#[test]
|
||||
fn fixing_the_code_clears_the_diagnostics() {
|
||||
let uri = "file:///tmp/dino-lsp-test/b.dino";
|
||||
let uri = "file:///tmp/rex-lsp-test/b.rex";
|
||||
let change = notify(
|
||||
"textDocument/didChange",
|
||||
Json::obj(vec![
|
||||
@@ -102,7 +102,7 @@ fn fixing_the_code_clears_the_diagnostics() {
|
||||
fn error_columns_count_utf16_units() {
|
||||
// the emoji takes two units in the editor's counting
|
||||
let src = "func main() {\n print(\"😀\", nope)\n}\n";
|
||||
let mut msgs = vec![open("file:///tmp/dino-lsp-test/c.dino", src)];
|
||||
let mut msgs = vec![open("file:///tmp/rex-lsp-test/c.rex", src)];
|
||||
msgs.extend(exit_messages());
|
||||
let (out, _) = talk(msgs);
|
||||
let d = match out[0].path(&["params", "diagnostics"]) {
|
||||
@@ -117,7 +117,7 @@ fn error_columns_count_utf16_units() {
|
||||
|
||||
#[test]
|
||||
fn formatting_returns_the_tidy_text() {
|
||||
let uri = "file:///tmp/dino-lsp-test/d.dino";
|
||||
let uri = "file:///tmp/rex-lsp-test/d.rex";
|
||||
let fmt_req = request(
|
||||
2,
|
||||
"textDocument/formatting",
|
||||
@@ -136,10 +136,10 @@ fn formatting_returns_the_tidy_text() {
|
||||
|
||||
#[test]
|
||||
fn imports_are_read_next_to_the_file() {
|
||||
let dir = std::env::temp_dir().join(format!("dino-lsp-{}", std::process::id()));
|
||||
let dir = std::env::temp_dir().join(format!("rex-lsp-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("util.dino"), "pub func twice(x: int): int { return x * 2 }\n").unwrap();
|
||||
let uri = format!("file://{}/main.dino", dir.display());
|
||||
std::fs::write(dir.join("util.rex"), "pub func twice(x: int): int { return x * 2 }\n").unwrap();
|
||||
let uri = format!("file://{}/main.rex", dir.display());
|
||||
let src = "import util\nfunc main() {\n print(util.twice(2))\n}\n";
|
||||
let mut msgs = vec![open(&uri, src)];
|
||||
msgs.extend(exit_messages());
|
||||
@@ -159,7 +159,7 @@ fn unknown_requests_get_an_error() {
|
||||
#[test]
|
||||
fn editor_files_are_valid_json() {
|
||||
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("editors/vscode");
|
||||
for f in ["package.json", "language-configuration.json", "syntaxes/dino.tmLanguage.json"] {
|
||||
for f in ["package.json", "language-configuration.json", "syntaxes/rex.tmLanguage.json"] {
|
||||
let text = std::fs::read_to_string(dir.join(f)).unwrap();
|
||||
json::parse(&text).unwrap_or_else(|e| panic!("{f}: {e}"));
|
||||
}
|
||||
@@ -177,7 +177,7 @@ fn at(uri: &str, line: i64, ch: i64) -> Json {
|
||||
}
|
||||
|
||||
fn ask(method: &str, params: Json) -> Json {
|
||||
let mut msgs = vec![request(1, "initialize", Json::obj(vec![])), open("file:///x/a.dino", SRC), request(2, method, params)];
|
||||
let mut msgs = vec![request(1, "initialize", Json::obj(vec![])), open("file:///x/a.rex", SRC), request(2, method, params)];
|
||||
msgs.extend(exit_messages());
|
||||
let (out, _) = talk(msgs);
|
||||
out.into_iter().find(|m| m.get("id") == Some(&Json::Num(2.0))).unwrap().get("result").cloned().unwrap_or(Json::Null)
|
||||
@@ -185,40 +185,40 @@ fn ask(method: &str, params: Json) -> Json {
|
||||
|
||||
#[test]
|
||||
fn outline_lists_top_level_names() {
|
||||
let r = ask("textDocument/documentSymbol", Json::obj(vec![("textDocument", Json::obj(vec![("uri", Json::str("file:///x/a.dino"))]))]));
|
||||
let r = ask("textDocument/documentSymbol", Json::obj(vec![("textDocument", Json::obj(vec![("uri", Json::str("file:///x/a.rex"))]))]));
|
||||
let text = r.to_string();
|
||||
assert!(text.contains("\"add\"") && text.contains("\"P\"") && text.contains("\"main\"") && text.contains("\"x\""), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn definition_jumps_to_the_function() {
|
||||
let r = ask("textDocument/definition", at("file:///x/a.dino", 11, 14));
|
||||
let r = ask("textDocument/definition", at("file:///x/a.rex", 11, 14));
|
||||
assert_eq!(r.path(&["range", "start", "line"]).and_then(Json::as_i64), Some(1), "{r:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn definition_finds_a_local() {
|
||||
let r = ask("textDocument/definition", at("file:///x/a.dino", 3, 12));
|
||||
let r = ask("textDocument/definition", at("file:///x/a.rex", 3, 12));
|
||||
assert_eq!(r.path(&["range", "start", "line"]).and_then(Json::as_i64), Some(2), "{r:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hover_shows_the_signature_and_comment() {
|
||||
let r = ask("textDocument/hover", at("file:///x/a.dino", 11, 14));
|
||||
let r = ask("textDocument/hover", at("file:///x/a.rex", 11, 14));
|
||||
let v = r.path(&["contents", "value"]).and_then(Json::as_str).unwrap_or("").to_string();
|
||||
assert!(v.contains("func add(a: int, b: int): int") && v.contains("Adds two numbers."), "{v}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completion_offers_names_and_keywords() {
|
||||
let r = ask("textDocument/completion", at("file:///x/a.dino", 12, 4)).to_string();
|
||||
let r = ask("textDocument/completion", at("file:///x/a.rex", 12, 4)).to_string();
|
||||
assert!(r.contains("\"add\"") && r.contains("\"t\"") && r.contains("\"func\"") && r.contains("\"string\""), "{r:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signature_help_marks_the_parameter() {
|
||||
let src = "func add(a: int, b: int): int {\n return a + b\n}\nfunc main() {\n add(1, \n}\n";
|
||||
let mut msgs = vec![request(1, "initialize", Json::obj(vec![])), open("file:///x/b.dino", src), request(2, "textDocument/signatureHelp", at("file:///x/b.dino", 4, 11))];
|
||||
let mut msgs = vec![request(1, "initialize", Json::obj(vec![])), open("file:///x/b.rex", src), request(2, "textDocument/signatureHelp", at("file:///x/b.rex", 4, 11))];
|
||||
msgs.extend(exit_messages());
|
||||
let (out, _) = talk(msgs);
|
||||
let r = out.into_iter().find(|m| m.get("id") == Some(&Json::Num(2.0))).unwrap().get("result").cloned().unwrap();
|
||||
@@ -229,10 +229,10 @@ fn signature_help_marks_the_parameter() {
|
||||
// ---------- C headers ----------
|
||||
|
||||
fn with_header(src: &str, method: &str, line: i64, ch: i64) -> Json {
|
||||
let dir = std::env::temp_dir().join(format!("dino-lsp-c-{}-{}", std::process::id(), method.replace('/', "_")));
|
||||
let dir = std::env::temp_dir().join(format!("rex-lsp-c-{}-{}", std::process::id(), method.replace('/', "_")));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("geo.h"), "typedef struct { double x, y; } Point;\n#define ORIGIN_NAME \"origin\"\n/* distance */\ndouble dist(Point a, Point b);\nint clamp(int v, int lo, int hi);\n").unwrap();
|
||||
let uri = format!("file://{}/main.dino", dir.display());
|
||||
let uri = format!("file://{}/main.rex", dir.display());
|
||||
let mut msgs = vec![request(1, "initialize", Json::obj(vec![])), open(&uri, src), request(2, method, at(&uri, line, ch))];
|
||||
msgs.extend(exit_messages());
|
||||
let (out, _) = talk(msgs);
|
||||
|
||||
Reference in new issue
Block a user