@tsuzuri-lab/sed-language-server 0.1.1 → 0.2.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 +49 -39
- package/package.json +8 -4
- package/src/analysis.js +275 -0
- package/src/server.js +49 -46
- package/vendor/tree-sitter-sed-gnu.wasm +0 -0
- package/vendor/tree-sitter-sed-posix.wasm +0 -0
- package/src/completion.js +0 -148
- package/src/definition.js +0 -46
- package/src/diagnostics.js +0 -1865
- package/src/document-structure.js +0 -774
- package/src/sed-syntax.js +0 -2321
- package/src/syntax-profile.js +0 -99
package/src/syntax-profile.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const dialects = Object.freeze(["posix", "gnu"]);
|
|
2
|
-
const regexpModes = Object.freeze(["bre", "ere"]);
|
|
3
|
-
|
|
4
|
-
const profiles = Object.freeze({
|
|
5
|
-
"posix:bre": Object.freeze({ dialect: "posix", regexpMode: "bre" }),
|
|
6
|
-
"posix:ere": Object.freeze({ dialect: "posix", regexpMode: "ere" }),
|
|
7
|
-
"gnu:bre": Object.freeze({ dialect: "gnu", regexpMode: "bre" }),
|
|
8
|
-
"gnu:ere": Object.freeze({ dialect: "gnu", regexpMode: "ere" }),
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export const defaultSyntaxProfile = profiles["posix:bre"];
|
|
12
|
-
|
|
13
|
-
function successfulResult(profile) {
|
|
14
|
-
return Object.freeze({ ok: true, profile });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function failedResult(errors) {
|
|
18
|
-
return Object.freeze({ ok: false, errors: Object.freeze(errors) });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function invalidOption(code, option, received, expected, message) {
|
|
22
|
-
return Object.freeze({
|
|
23
|
-
code,
|
|
24
|
-
option,
|
|
25
|
-
received,
|
|
26
|
-
expected,
|
|
27
|
-
message,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function resolveSyntaxProfile(options) {
|
|
32
|
-
if (options === undefined) {
|
|
33
|
-
return successfulResult(defaultSyntaxProfile);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
options === null ||
|
|
38
|
-
typeof options !== "object" ||
|
|
39
|
-
Array.isArray(options)
|
|
40
|
-
) {
|
|
41
|
-
return failedResult([
|
|
42
|
-
invalidOption(
|
|
43
|
-
"syntax-profile-invalid-options",
|
|
44
|
-
null,
|
|
45
|
-
options,
|
|
46
|
-
"a non-null options object",
|
|
47
|
-
"Syntax profile options must be provided as a non-null object.",
|
|
48
|
-
),
|
|
49
|
-
]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const dialect =
|
|
53
|
-
options.dialect === undefined
|
|
54
|
-
? defaultSyntaxProfile.dialect
|
|
55
|
-
: options.dialect;
|
|
56
|
-
const regexpMode =
|
|
57
|
-
options.regexpMode === undefined
|
|
58
|
-
? defaultSyntaxProfile.regexpMode
|
|
59
|
-
: options.regexpMode;
|
|
60
|
-
const errors = [];
|
|
61
|
-
|
|
62
|
-
if (!dialects.includes(dialect)) {
|
|
63
|
-
errors.push(
|
|
64
|
-
invalidOption(
|
|
65
|
-
"syntax-profile-invalid-dialect",
|
|
66
|
-
"dialect",
|
|
67
|
-
dialect,
|
|
68
|
-
dialects,
|
|
69
|
-
'The syntax profile dialect must be either "posix" or "gnu".',
|
|
70
|
-
),
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!regexpModes.includes(regexpMode)) {
|
|
75
|
-
errors.push(
|
|
76
|
-
invalidOption(
|
|
77
|
-
"syntax-profile-invalid-regexp-mode",
|
|
78
|
-
"regexpMode",
|
|
79
|
-
regexpMode,
|
|
80
|
-
regexpModes,
|
|
81
|
-
'The syntax profile regexpMode must be either "bre" or "ere".',
|
|
82
|
-
),
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (errors.length > 0) {
|
|
87
|
-
return failedResult(errors);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return successfulResult(profiles[`${dialect}:${regexpMode}`]);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function requireSyntaxProfile(options) {
|
|
94
|
-
const result = resolveSyntaxProfile(options);
|
|
95
|
-
if (!result.ok) {
|
|
96
|
-
throw new TypeError(result.errors.map(({ message }) => message).join(" "));
|
|
97
|
-
}
|
|
98
|
-
return result.profile;
|
|
99
|
-
}
|