vne-language 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -6,4 +6,4 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- - Initial release
9
+ - Initial release
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vne-language",
3
3
  "displayName": "vne-language",
4
4
  "description": "Syntax highlighting for .vne scenario files",
5
- "version": "0.2.0",
5
+ "version": "0.2.1",
6
6
  "main": "./src/extension.js",
7
7
  "scripts": {
8
8
  "package:vsix": "vsce package",
@@ -1,7 +1,6 @@
1
1
  const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2
2
 
3
- const actionLiterals = (entry = {}) =>
4
- Object.values(entry.actions || {}).filter((value) => typeof value === "string" && value.length > 0);
3
+ const actionLiterals = (entry = {}) => Object.values(entry.actions || {}).filter((value) => typeof value === "string" && value.length > 0);
5
4
 
6
5
  const mergeCommands = (manifests = []) => {
7
6
  const modules = {};
@@ -61,10 +60,7 @@ const lineKeywordPattern = (keywords = []) => {
61
60
  */
62
61
  const buildGrammar = (baseGrammar, manifests = [], options = {}) => {
63
62
  const { modules, blocks } = mergeCommands(manifests);
64
- const commandPatterns = [
65
- ...patternsForNamedCommands(modules),
66
- ...patternsForNamedCommands(blocks),
67
- ];
63
+ const commandPatterns = [...patternsForNamedCommands(modules), ...patternsForNamedCommands(blocks)];
68
64
 
69
65
  const keywordPattern = lineKeywordPattern(options.lineKeywords || []);
70
66
  const basePatterns = Array.isArray(baseGrammar.patterns) ? baseGrammar.patterns : [];
@@ -9,8 +9,7 @@
9
9
 
10
10
  const escapeRegExp = (value) => String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11
11
 
12
- const actionLiterals = (entry) =>
13
- Object.values((entry && entry.actions) || {}).filter((value) => typeof value === "string" && value.length > 0);
12
+ const actionLiterals = (entry) => Object.values((entry && entry.actions) || {}).filter((value) => typeof value === "string" && value.length > 0);
14
13
 
15
14
  const enumLiterals = (arg) => {
16
15
  if (!arg || arg.kind !== "enum" || !arg.values || typeof arg.values !== "object") return [];
@@ -239,9 +238,7 @@
239
238
  type: "keyword",
240
239
  });
241
240
 
242
- const specs =
243
- (entry.argsByAction && entry.argsByAction[first.text]) ||
244
- (actions.length ? [{ kind: "id" }] : []);
241
+ const specs = (entry.argsByAction && entry.argsByAction[first.text]) || (actions.length ? [{ kind: "id" }] : []);
245
242
  pushArgRanges(ranges, lineIndex, tokens.slice(1), specs);
246
243
  } else if (Array.isArray(entry.args) && entry.args.length) {
247
244
  pushArgRanges(ranges, lineIndex, tokens, entry.args);
package/src/extension.js CHANGED
@@ -86,9 +86,7 @@ const watchedRoots = new Set();
86
86
  const activate = (context) => {
87
87
  const provider = createSemanticTokensProvider();
88
88
 
89
- context.subscriptions.push(
90
- vscode.languages.registerDocumentSemanticTokensProvider({ language: "vnelang" }, provider, legend),
91
- );
89
+ context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider({ language: "vnelang" }, provider, legend));
92
90
 
93
91
  context.subscriptions.push(onDidChangeSemanticTokensEmitter);
94
92
 
@@ -4,10 +4,7 @@ const { resolveGameRoot } = require("./resolve-game-root.js");
4
4
  const { loadCommandsFromNodeModules } = require("./load-commands.js");
5
5
  const { collectCommandTokenRanges } = require("./semantic-tokens.js");
6
6
 
7
- const sampleVne = path.resolve(
8
- __dirname,
9
- "../../../games/vn.skeleton/game/main/scenario/tests/index.vne",
10
- );
7
+ const sampleVne = path.resolve(__dirname, "../../../games/vn.skeleton/game/main/scenario/tests/index.vne");
11
8
 
12
9
  const assert = (condition, message) => {
13
10
  if (!condition) throw new Error(message);
@@ -27,35 +24,16 @@ const main = async () => {
27
24
  assert(commands.modules["audio.music"], "expected audio.music module from contracts");
28
25
  assert(commands.blocks.qte, "expected qte block from contracts");
29
26
  assert(commands.blocks.choose, "expected choose block from contracts");
30
- assert(
31
- Object.values(commands.modules.stack.actions || {}).includes("jump"),
32
- "expected stack jump action",
33
- );
34
- assert(
35
- Object.values(commands.modules.scenario.actions || {}).includes("goto"),
36
- "expected scenario goto action",
37
- );
38
- assert(
39
- Object.values(commands.modules.save.actions || {}).includes("key"),
40
- "expected save key action",
41
- );
42
- assert(
43
- Object.values(commands.modules["bl.bg"].actions || {}).includes("show"),
44
- "expected bl.bg show action",
45
- );
46
- assert(
47
- Object.values(commands.modules["audio.music"].actions || {}).includes("play"),
48
- "expected audio.music play action",
49
- );
27
+ assert(Object.values(commands.modules.stack.actions || {}).includes("jump"), "expected stack jump action");
28
+ assert(Object.values(commands.modules.scenario.actions || {}).includes("goto"), "expected scenario goto action");
29
+ assert(Object.values(commands.modules.save.actions || {}).includes("key"), "expected save key action");
30
+ assert(Object.values(commands.modules["bl.bg"].actions || {}).includes("show"), "expected bl.bg show action");
31
+ assert(Object.values(commands.modules["audio.music"].actions || {}).includes("play"), "expected audio.music play action");
50
32
  assert(commands.modules["text.meet"], "expected text.meet module from contracts");
51
33
  assert(commands.modules["ul.sprite"], "expected ul.sprite module from layer contracts");
34
+ assert(Array.isArray(commands.modules["text.meet"].args) && commands.modules["text.meet"].args[0]?.kind === "id", "expected text.meet args id slot");
52
35
  assert(
53
- Array.isArray(commands.modules["text.meet"].args) && commands.modules["text.meet"].args[0]?.kind === "id",
54
- "expected text.meet args id slot",
55
- );
56
- assert(
57
- Array.isArray(commands.modules["ul.sprite"].argsByAction?.show) &&
58
- commands.modules["ul.sprite"].argsByAction.show.some((arg) => arg.kind === "enum"),
36
+ Array.isArray(commands.modules["ul.sprite"].argsByAction?.show) && commands.modules["ul.sprite"].argsByAction.show.some((arg) => arg.kind === "enum"),
59
37
  "expected ul.sprite show position enum slot",
60
38
  );
61
39
  assert(commands.lineKeywords.includes("async"), "expected LINE_KEYWORDS from scenario contract");