@rank-lang/lsp 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/features/completion.d.ts +4 -0
- package/dist/features/completion.js +23 -0
- package/dist/features/definition.d.ts +4 -0
- package/dist/features/definition.js +32 -0
- package/dist/features/diagnostics.d.ts +3 -0
- package/dist/features/diagnostics.js +133 -0
- package/dist/features/hover.d.ts +4 -0
- package/dist/features/hover.js +75 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +57 -0
- package/dist/session.d.ts +14 -0
- package/dist/session.js +167 -0
- package/dist/util/convert.d.ts +6 -0
- package/dist/util/convert.js +40 -0
- package/dist/util/stdlib-hover.d.ts +4 -0
- package/dist/util/stdlib-hover.js +109 -0
- package/dist/util/type-symbols.d.ts +13 -0
- package/dist/util/type-symbols.js +118 -0
- package/package.json +41 -0
- package/src/features/completion.ts +37 -0
- package/src/features/definition.ts +49 -0
- package/src/features/diagnostics.ts +195 -0
- package/src/features/hover.ts +127 -0
- package/src/server.ts +73 -0
- package/src/session.ts +224 -0
- package/src/util/convert.ts +54 -0
- package/src/util/stdlib-hover.ts +178 -0
- package/src/util/type-symbols.ts +165 -0
- package/test/convert.test.ts +46 -0
- package/test/editor-features.test.ts +1167 -0
- package/test/session.test.ts +58 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +10 -0
- package/vitest.config.ts +36 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
|
|
3
|
+
import type { Diagnostic } from "@rank-lang/compiler";
|
|
4
|
+
import { describe, expect, test } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { toLspDiagnostic } from "../src/util/convert.ts";
|
|
7
|
+
|
|
8
|
+
describe("toLspDiagnostic", () => {
|
|
9
|
+
test("maps compiler labels to relatedInformation", () => {
|
|
10
|
+
const diagnostic: Diagnostic = {
|
|
11
|
+
code: "TYP001",
|
|
12
|
+
severity: "error",
|
|
13
|
+
message: "Value bound to value is not assignable to string; got number.",
|
|
14
|
+
sourcePath: "/tmp/main.rank",
|
|
15
|
+
span: {
|
|
16
|
+
start: { offset: 0, line: 1, column: 1 },
|
|
17
|
+
end: { offset: 5, line: 1, column: 6 },
|
|
18
|
+
},
|
|
19
|
+
labels: [
|
|
20
|
+
{
|
|
21
|
+
sourcePath: "/tmp/types.rank",
|
|
22
|
+
span: {
|
|
23
|
+
start: { offset: 0, line: 2, column: 3 },
|
|
24
|
+
end: { offset: 6, line: 2, column: 9 },
|
|
25
|
+
},
|
|
26
|
+
message: "declared here",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const converted = toLspDiagnostic(diagnostic);
|
|
32
|
+
|
|
33
|
+
expect(converted.relatedInformation).toEqual([
|
|
34
|
+
{
|
|
35
|
+
location: {
|
|
36
|
+
uri: pathToFileURL("/tmp/types.rank").href,
|
|
37
|
+
range: {
|
|
38
|
+
start: { line: 1, character: 2 },
|
|
39
|
+
end: { line: 1, character: 8 },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
message: "declared here",
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
});
|