@webgal/language-server 0.0.2-alpha.2 → 0.0.2-alpha.4

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/build/browser.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('./providerState-B7hGbqQj.cjs');
2
+ require('./warnings-De2NDXgx.cjs');
3
3
  const require_utils = require('./utils.cjs');
4
4
  const require_onInitialize = require('./onInitialize-7r14ko5I.cjs');
5
5
  let _volar_language_server_browser = require("@volar/language-server/browser");
package/build/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./providerState-CLCXHs37.mjs";
1
+ import "./warnings-CWkIAwTu.mjs";
2
2
  import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createWebgalVirtualCode, updateWebgalVirtualCode } from "./utils.mjs";
3
3
  import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DLHBz6ds.mjs";
4
4
  import { createConnection, createConnection as createConnection$1, createServer, createSimpleProject } from "@volar/language-server/browser";
package/build/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- require('./providerState-B7hGbqQj.cjs');
1
+ require('./warnings-De2NDXgx.cjs');
2
2
  const require_utils = require('./utils.cjs');
3
3
  const require_onInitialize = require('./onInitialize-7r14ko5I.cjs');
4
4
  let _volar_language_server_node = require("@volar/language-server/node");
@@ -22,8 +22,8 @@ async function startWebSocketServer(options) {
22
22
  });
23
23
  }
24
24
  function getWsOptions(argv) {
25
- let port = Number(process.env.WEBGAL_LSP_WS_PORT ?? 3001);
26
- let path = process.env.WEBGAL_LSP_WS_PATH ?? "/webgal-lsp";
25
+ let port = 5882;
26
+ let path = "/webgal-lsp";
27
27
  for (const arg of argv) {
28
28
  if (arg.startsWith("--ws=")) {
29
29
  const value = Number(arg.slice(5));
package/build/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./providerState-CLCXHs37.mjs";
1
+ import "./warnings-CWkIAwTu.mjs";
2
2
  import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createWebgalVirtualCode, updateWebgalVirtualCode } from "./utils.mjs";
3
3
  import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DLHBz6ds.mjs";
4
4
  import { createConnection, createServer, createSimpleProject } from "@volar/language-server/node";
@@ -22,8 +22,8 @@ async function startWebSocketServer(options) {
22
22
  });
23
23
  }
24
24
  function getWsOptions(argv) {
25
- let port = Number(process.env.WEBGAL_LSP_WS_PORT ?? 3001);
26
- let path = process.env.WEBGAL_LSP_WS_PATH ?? "/webgal-lsp";
25
+ let port = 5882;
26
+ let path = "/webgal-lsp";
27
27
  for (const arg of argv) {
28
28
  if (arg.startsWith("--ws=")) {
29
29
  const value = Number(arg.slice(5));
package/build/utils.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_providerState = require('./providerState-B7hGbqQj.cjs');
2
+ const require_warnings = require('./warnings-De2NDXgx.cjs');
3
3
  let _webgal_language_core = require("@webgal/language-core");
4
4
  let _volar_language_server = require("@volar/language-server");
5
5
  let _volar_language_service = require("@volar/language-service");
@@ -173,6 +173,8 @@ const analyzeWebgalFoldingRanges = (text) => {
173
173
  return foldingRanges;
174
174
  };
175
175
  const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
176
+ const originalId = scriptId.toString();
177
+ const normalizedId = originalId.toLowerCase();
176
178
  const length = snapshot.getLength();
177
179
  const text = getSnapshotText(snapshot);
178
180
  const lines = text.split(/\r?\n/);
@@ -181,7 +183,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
181
183
  const linkCandidates = analyzeWebgalDocumentLinks(lines);
182
184
  const foldingRanges = analyzeWebgalFoldingRanges(text);
183
185
  return {
184
- id: scriptId.toString(),
186
+ id: normalizedId,
185
187
  languageId,
186
188
  snapshot,
187
189
  mappings: [{
@@ -190,6 +192,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
190
192
  lengths: [length],
191
193
  data: fullCodeInformation
192
194
  }],
195
+ webgalOriginalId: originalId,
193
196
  webgalDefinitionMap: map,
194
197
  webgalDocumentLinkCandidates: linkCandidates,
195
198
  webgalFoldingRanges: foldingRanges,
@@ -475,8 +478,8 @@ async function validateTextDocument(connection, textDocument, textOverride) {
475
478
  let problems = 0;
476
479
  const diagnostics = [];
477
480
  let _sp = text.split(/\n|\t\n|\r\n/);
478
- for (let i in require_providerState.warningConfig) {
479
- const _token = require_providerState.warningConfig[i];
481
+ for (let i in require_warnings.warningConfig) {
482
+ const _token = require_warnings.warningConfig[i];
480
483
  const _pattern = _token.pattern;
481
484
  if (_token.is_line) continue;
482
485
  if (_token.customCheck && _token.customCheck instanceof Function) {
@@ -502,15 +505,15 @@ async function validateTextDocument(connection, textDocument, textOverride) {
502
505
  uri: textDocument.uri,
503
506
  range: Object.assign({}, diagnostic.range)
504
507
  },
505
- message: require_providerState.getDiagnosticInformation(i)
508
+ message: require_warnings.getDiagnosticInformation(i)
506
509
  }];
507
510
  diagnostics.push(diagnostic);
508
511
  }
509
512
  }
510
513
  for (let _line_index = 0; _line_index < _sp.length; _line_index++) {
511
514
  const _line_text = _sp[_line_index];
512
- for (let i in require_providerState.warningConfig) {
513
- const _token = require_providerState.warningConfig[i];
515
+ for (let i in require_warnings.warningConfig) {
516
+ const _token = require_warnings.warningConfig[i];
514
517
  const _pattern = _token.pattern;
515
518
  if (!_token.is_line) continue;
516
519
  const _newarr = _sp.slice(0, _line_index).join();
@@ -537,7 +540,7 @@ async function validateTextDocument(connection, textDocument, textOverride) {
537
540
  uri: textDocument.uri,
538
541
  range: Object.assign({}, diagnostic.range)
539
542
  },
540
- message: require_providerState.getDiagnosticInformation(i)
543
+ message: require_warnings.getDiagnosticInformation(i)
541
544
  }];
542
545
  diagnostics.push(diagnostic);
543
546
  }
@@ -609,7 +612,6 @@ exports.findTokenRange = findTokenRange;
609
612
  exports.getDocumentSettings = getDocumentSettings;
610
613
  exports.getPatternAtPosition = getPatternAtPosition;
611
614
  exports.getStageCompletionContext = getStageCompletionContext;
612
- exports.getState = require_providerState.getState;
613
615
  exports.getTokenOrPatternAtPosition = getTokenOrPatternAtPosition;
614
616
  exports.getWebgalDefinitionMap = getWebgalDefinitionMap;
615
617
  exports.getWebgalDocumentLinkCandidates = getWebgalDocumentLinkCandidates;
package/build/utils.d.cts CHANGED
@@ -13,9 +13,6 @@ interface ServerSettings {
13
13
  isShowHint: "关闭" | "最前面" | "变量名前" | "变量名后" | "最后面";
14
14
  }
15
15
  //#endregion
16
- //#region src/utils/providerState.d.ts
17
- declare const getState: (propertiesArray: string[], prev?: any) => any;
18
- //#endregion
19
16
  //#region src/utils/index.d.ts
20
17
  type SendRequestConnection = {
21
18
  sendRequest: (method: string, ...params: any[]) => Promise<any>;
@@ -27,6 +24,7 @@ type WebgalVirtualCode = VirtualCode & {
27
24
  webgalFoldingRanges?: FoldingRange[];
28
25
  webgalLines?: string[];
29
26
  webgalLineCommandTypes?: string[];
27
+ webgalOriginalId?: string;
30
28
  };
31
29
  type WebgalDocumentLinkCandidate = {
32
30
  line: number;
@@ -107,4 +105,4 @@ declare function createClientVfsFileSystem(connection: SendRequestConnection, op
107
105
  uriToPath?: (uri: URI) => string;
108
106
  }): FileSystem;
109
107
  //#endregion
110
- export { StateConfig, WebgalDocumentLinkCandidate, WebgalVirtualCode, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext, getState, getTokenOrPatternAtPosition, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, globalSettings, isPathChar, listPathCandidates, setGlobalSettings, updateWebgalVirtualCode, validateTextDocument };
108
+ export { StateConfig, WebgalDocumentLinkCandidate, WebgalVirtualCode, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext, getTokenOrPatternAtPosition, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, globalSettings, isPathChar, listPathCandidates, setGlobalSettings, updateWebgalVirtualCode, validateTextDocument };
package/build/utils.d.mts CHANGED
@@ -13,9 +13,6 @@ interface ServerSettings {
13
13
  isShowHint: "关闭" | "最前面" | "变量名前" | "变量名后" | "最后面";
14
14
  }
15
15
  //#endregion
16
- //#region src/utils/providerState.d.ts
17
- declare const getState: (propertiesArray: string[], prev?: any) => any;
18
- //#endregion
19
16
  //#region src/utils/index.d.ts
20
17
  type SendRequestConnection = {
21
18
  sendRequest: (method: string, ...params: any[]) => Promise<any>;
@@ -27,6 +24,7 @@ type WebgalVirtualCode = VirtualCode & {
27
24
  webgalFoldingRanges?: FoldingRange[];
28
25
  webgalLines?: string[];
29
26
  webgalLineCommandTypes?: string[];
27
+ webgalOriginalId?: string;
30
28
  };
31
29
  type WebgalDocumentLinkCandidate = {
32
30
  line: number;
@@ -107,4 +105,4 @@ declare function createClientVfsFileSystem(connection: SendRequestConnection, op
107
105
  uriToPath?: (uri: URI) => string;
108
106
  }): FileSystem;
109
107
  //#endregion
110
- export { StateConfig, WebgalDocumentLinkCandidate, WebgalVirtualCode, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext, getState, getTokenOrPatternAtPosition, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, globalSettings, isPathChar, listPathCandidates, setGlobalSettings, updateWebgalVirtualCode, validateTextDocument };
108
+ export { StateConfig, WebgalDocumentLinkCandidate, WebgalVirtualCode, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext, getTokenOrPatternAtPosition, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, globalSettings, isPathChar, listPathCandidates, setGlobalSettings, updateWebgalVirtualCode, validateTextDocument };
package/build/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as getDiagnosticInformation, r as warningConfig, t as getState } from "./providerState-CLCXHs37.mjs";
1
+ import { n as warningConfig, t as getDiagnosticInformation } from "./warnings-CWkIAwTu.mjs";
2
2
  import { fsAccessor, source } from "@webgal/language-core";
3
3
  import { DiagnosticSeverity, FoldingRangeKind, Range } from "@volar/language-server";
4
4
  import { FileType } from "@volar/language-service";
@@ -172,6 +172,8 @@ const analyzeWebgalFoldingRanges = (text) => {
172
172
  return foldingRanges;
173
173
  };
174
174
  const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
175
+ const originalId = scriptId.toString();
176
+ const normalizedId = originalId.toLowerCase();
175
177
  const length = snapshot.getLength();
176
178
  const text = getSnapshotText(snapshot);
177
179
  const lines = text.split(/\r?\n/);
@@ -180,7 +182,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
180
182
  const linkCandidates = analyzeWebgalDocumentLinks(lines);
181
183
  const foldingRanges = analyzeWebgalFoldingRanges(text);
182
184
  return {
183
- id: scriptId.toString(),
185
+ id: normalizedId,
184
186
  languageId,
185
187
  snapshot,
186
188
  mappings: [{
@@ -189,6 +191,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
189
191
  lengths: [length],
190
192
  data: fullCodeInformation
191
193
  }],
194
+ webgalOriginalId: originalId,
192
195
  webgalDefinitionMap: map,
193
196
  webgalDocumentLinkCandidates: linkCandidates,
194
197
  webgalFoldingRanges: foldingRanges,
@@ -597,4 +600,4 @@ function createClientVfsFileSystem(connection, options) {
597
600
  }
598
601
 
599
602
  //#endregion
600
- export { StateConfig, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext, getState, getTokenOrPatternAtPosition, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, globalSettings, isPathChar, listPathCandidates, setGlobalSettings, updateWebgalVirtualCode, validateTextDocument };
603
+ export { StateConfig, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext, getTokenOrPatternAtPosition, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, globalSettings, isPathChar, listPathCandidates, setGlobalSettings, updateWebgalVirtualCode, validateTextDocument };
@@ -0,0 +1,144 @@
1
+ import { source } from "@webgal/language-core";
2
+ import { DiagnosticSeverity } from "@volar/language-server";
3
+
4
+ //#region src/warnings.ts
5
+ function remove_space(_text) {
6
+ _text = _text.replace(/^([\n\r\t]+)/, function(input, match) {
7
+ return input.slice(match.length);
8
+ });
9
+ return _text;
10
+ }
11
+ const warningConfig = {
12
+ "0001": {
13
+ id: "0001",
14
+ message: (...args) => {
15
+ return `${args[0]} 前面包含一个以上的空格或换行`;
16
+ },
17
+ DiagnosticInformation: "指令格式不规范(%id%)",
18
+ pattern: /(\s{2,}-[A-Za-z]+)\b/g,
19
+ is_line: false
20
+ },
21
+ "0002": {
22
+ id: "0002",
23
+ message: (...args) => {
24
+ return `${args[0]} 变量名开头为数字`;
25
+ },
26
+ DiagnosticInformation: "变量命名不规范(%id%)",
27
+ pattern: /^setVar:([0-9]+\S+);/g,
28
+ is_line: true,
29
+ customCheck: function(textDocument, _text, _base_offset, _newarr) {
30
+ const _ori_text = _text;
31
+ _text = remove_space(_text);
32
+ let _offset = 0;
33
+ for (let i = 0; i < _newarr.length; i++) {
34
+ const _data = _newarr[i];
35
+ if (/(\r\n)/.test(_data) || _data == "\\r\\n") _offset += 2;
36
+ else _offset += _data.length;
37
+ }
38
+ if (this.pattern.exec(_text)) {
39
+ const diagnostic = {
40
+ severity: DiagnosticSeverity.Warning,
41
+ range: {
42
+ start: textDocument.positionAt(_offset),
43
+ end: textDocument.positionAt(_offset + _text.length)
44
+ },
45
+ message: message(this.id, _ori_text.trim()),
46
+ source
47
+ };
48
+ diagnostic.relatedInformation = [{
49
+ location: {
50
+ uri: textDocument.uri,
51
+ range: Object.assign({}, diagnostic.range)
52
+ },
53
+ message: getDiagnosticInformation(this.id)
54
+ }];
55
+ return diagnostic;
56
+ }
57
+ return null;
58
+ }
59
+ },
60
+ "0003": {
61
+ id: "0003",
62
+ message: (...args) => {
63
+ return `${args[0]} 冒号后面需要添加一个空格`;
64
+ },
65
+ DiagnosticInformation: "指令不规范(%id%)",
66
+ pattern: /^([^\s]+):[^\s](.+)/g,
67
+ is_line: true
68
+ },
69
+ "0004": {
70
+ id: "0004",
71
+ message: (...args) => {
72
+ return `${args[0]} 插值变量周围存在空格`;
73
+ },
74
+ DiagnosticInformation: "变量插值不规范(%id%)",
75
+ pattern: /{(\S+\s{1,}|\s{1,}\S+|\s{1,}\S+\s{1,})}/g,
76
+ is_line: false
77
+ },
78
+ "0005": {
79
+ id: "0005",
80
+ message: (...args) => {
81
+ return `${args[0]} 语句缺少结束标识`;
82
+ },
83
+ DiagnosticInformation: "语句不规范(%id%)",
84
+ pattern: /none/g,
85
+ customCheck: function(textDocument, _text, _base_offset, _newarr) {
86
+ _text = remove_space(_text);
87
+ let _offset = 0;
88
+ for (let i = 0; i < _newarr.length; i++) {
89
+ const _data = _newarr[i];
90
+ if (/(\r\n)/.test(_data) || _data == "\\r\\n") _offset += 2;
91
+ else _offset += _data.length;
92
+ }
93
+ const _res_match_start = _text.endsWith(";") ? true : false;
94
+ const _res = _text.startsWith(";") || _res_match_start ? true : false;
95
+ if (!_text.includes(";") && !_res && _text.length > 0) {
96
+ const diagnostic = {
97
+ severity: DiagnosticSeverity.Warning,
98
+ range: {
99
+ start: textDocument.positionAt(_offset),
100
+ end: textDocument.positionAt(_offset + _text.trim().length)
101
+ },
102
+ message: message(this.id, _text.trim()),
103
+ source
104
+ };
105
+ diagnostic.relatedInformation = [{
106
+ location: {
107
+ uri: textDocument.uri,
108
+ range: Object.assign({}, diagnostic.range)
109
+ },
110
+ message: getDiagnosticInformation(this.id)
111
+ }];
112
+ return diagnostic;
113
+ }
114
+ return null;
115
+ },
116
+ is_line: true
117
+ }
118
+ };
119
+ /**
120
+ * @description: 获取诊断结果
121
+ * @param {string} id
122
+ * @param {array} args
123
+ * @return {*}
124
+ */
125
+ function message(id, ...args) {
126
+ const _data = warningConfig[id];
127
+ if (!_data) return false;
128
+ return _data.message(...args);
129
+ }
130
+ /**
131
+ * @description: 获取诊断类型信息
132
+ * @param {string} id
133
+ * @return {*}
134
+ */
135
+ function getDiagnosticInformation(id) {
136
+ const _data = warningConfig[id];
137
+ if (!_data) return "未知错误类型";
138
+ return _data.DiagnosticInformation.replace(/%(\w+)%/g, function() {
139
+ return id;
140
+ });
141
+ }
142
+
143
+ //#endregion
144
+ export { warningConfig as n, getDiagnosticInformation as t };
@@ -0,0 +1,155 @@
1
+ let _webgal_language_core = require("@webgal/language-core");
2
+ let _volar_language_server = require("@volar/language-server");
3
+
4
+ //#region src/warnings.ts
5
+ function remove_space(_text) {
6
+ _text = _text.replace(/^([\n\r\t]+)/, function(input, match) {
7
+ return input.slice(match.length);
8
+ });
9
+ return _text;
10
+ }
11
+ const warningConfig = {
12
+ "0001": {
13
+ id: "0001",
14
+ message: (...args) => {
15
+ return `${args[0]} 前面包含一个以上的空格或换行`;
16
+ },
17
+ DiagnosticInformation: "指令格式不规范(%id%)",
18
+ pattern: /(\s{2,}-[A-Za-z]+)\b/g,
19
+ is_line: false
20
+ },
21
+ "0002": {
22
+ id: "0002",
23
+ message: (...args) => {
24
+ return `${args[0]} 变量名开头为数字`;
25
+ },
26
+ DiagnosticInformation: "变量命名不规范(%id%)",
27
+ pattern: /^setVar:([0-9]+\S+);/g,
28
+ is_line: true,
29
+ customCheck: function(textDocument, _text, _base_offset, _newarr) {
30
+ const _ori_text = _text;
31
+ _text = remove_space(_text);
32
+ let _offset = 0;
33
+ for (let i = 0; i < _newarr.length; i++) {
34
+ const _data = _newarr[i];
35
+ if (/(\r\n)/.test(_data) || _data == "\\r\\n") _offset += 2;
36
+ else _offset += _data.length;
37
+ }
38
+ if (this.pattern.exec(_text)) {
39
+ const diagnostic = {
40
+ severity: _volar_language_server.DiagnosticSeverity.Warning,
41
+ range: {
42
+ start: textDocument.positionAt(_offset),
43
+ end: textDocument.positionAt(_offset + _text.length)
44
+ },
45
+ message: message(this.id, _ori_text.trim()),
46
+ source: _webgal_language_core.source
47
+ };
48
+ diagnostic.relatedInformation = [{
49
+ location: {
50
+ uri: textDocument.uri,
51
+ range: Object.assign({}, diagnostic.range)
52
+ },
53
+ message: getDiagnosticInformation(this.id)
54
+ }];
55
+ return diagnostic;
56
+ }
57
+ return null;
58
+ }
59
+ },
60
+ "0003": {
61
+ id: "0003",
62
+ message: (...args) => {
63
+ return `${args[0]} 冒号后面需要添加一个空格`;
64
+ },
65
+ DiagnosticInformation: "指令不规范(%id%)",
66
+ pattern: /^([^\s]+):[^\s](.+)/g,
67
+ is_line: true
68
+ },
69
+ "0004": {
70
+ id: "0004",
71
+ message: (...args) => {
72
+ return `${args[0]} 插值变量周围存在空格`;
73
+ },
74
+ DiagnosticInformation: "变量插值不规范(%id%)",
75
+ pattern: /{(\S+\s{1,}|\s{1,}\S+|\s{1,}\S+\s{1,})}/g,
76
+ is_line: false
77
+ },
78
+ "0005": {
79
+ id: "0005",
80
+ message: (...args) => {
81
+ return `${args[0]} 语句缺少结束标识`;
82
+ },
83
+ DiagnosticInformation: "语句不规范(%id%)",
84
+ pattern: /none/g,
85
+ customCheck: function(textDocument, _text, _base_offset, _newarr) {
86
+ _text = remove_space(_text);
87
+ let _offset = 0;
88
+ for (let i = 0; i < _newarr.length; i++) {
89
+ const _data = _newarr[i];
90
+ if (/(\r\n)/.test(_data) || _data == "\\r\\n") _offset += 2;
91
+ else _offset += _data.length;
92
+ }
93
+ const _res_match_start = _text.endsWith(";") ? true : false;
94
+ const _res = _text.startsWith(";") || _res_match_start ? true : false;
95
+ if (!_text.includes(";") && !_res && _text.length > 0) {
96
+ const diagnostic = {
97
+ severity: _volar_language_server.DiagnosticSeverity.Warning,
98
+ range: {
99
+ start: textDocument.positionAt(_offset),
100
+ end: textDocument.positionAt(_offset + _text.trim().length)
101
+ },
102
+ message: message(this.id, _text.trim()),
103
+ source: _webgal_language_core.source
104
+ };
105
+ diagnostic.relatedInformation = [{
106
+ location: {
107
+ uri: textDocument.uri,
108
+ range: Object.assign({}, diagnostic.range)
109
+ },
110
+ message: getDiagnosticInformation(this.id)
111
+ }];
112
+ return diagnostic;
113
+ }
114
+ return null;
115
+ },
116
+ is_line: true
117
+ }
118
+ };
119
+ /**
120
+ * @description: 获取诊断结果
121
+ * @param {string} id
122
+ * @param {array} args
123
+ * @return {*}
124
+ */
125
+ function message(id, ...args) {
126
+ const _data = warningConfig[id];
127
+ if (!_data) return false;
128
+ return _data.message(...args);
129
+ }
130
+ /**
131
+ * @description: 获取诊断类型信息
132
+ * @param {string} id
133
+ * @return {*}
134
+ */
135
+ function getDiagnosticInformation(id) {
136
+ const _data = warningConfig[id];
137
+ if (!_data) return "未知错误类型";
138
+ return _data.DiagnosticInformation.replace(/%(\w+)%/g, function() {
139
+ return id;
140
+ });
141
+ }
142
+
143
+ //#endregion
144
+ Object.defineProperty(exports, 'getDiagnosticInformation', {
145
+ enumerable: true,
146
+ get: function () {
147
+ return getDiagnosticInformation;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, 'warningConfig', {
151
+ enumerable: true,
152
+ get: function () {
153
+ return warningConfig;
154
+ }
155
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webgal/language-server",
3
- "version": "0.0.2-alpha.2",
3
+ "version": "0.0.2-alpha.4",
4
4
  "main": "build/index.cjs",
5
5
  "module": "build/index.mjs",
6
6
  "types": "build/index.d.mts",
@@ -41,9 +41,8 @@
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsdown",
44
- "gen": "tsx scripts/gen.ts",
45
44
  "dev": "pnpm build && node bin/webgal-language-server.js --stdio",
46
- "dev:ws": "pnpm build && node bin/webgal-language-server.js --ws=3001",
45
+ "dev:ws": "pnpm build && node bin/webgal-language-server.js --ws",
47
46
  "format": " prettier --write \"src/**/*.ts\"",
48
47
  "lint": "eslint src --ext ts --fix",
49
48
  "typecheck": "tsc --noEmit",
@@ -55,7 +54,7 @@
55
54
  "@volar/language-service": "~2.4.0",
56
55
  "@volar/typescript": "~2.4.0",
57
56
  "@webgal/language-core": "0.0.2-alpha.1",
58
- "@webgal/language-service": "0.0.2-alpha.3",
57
+ "@webgal/language-service": "0.0.2-alpha.5",
59
58
  "tsc-alias": "^1.8.16",
60
59
  "vscode-languageserver": "^9.0.1",
61
60
  "vscode-languageserver-textdocument": "^1.0.11",
@@ -68,5 +67,5 @@
68
67
  "tsdown": "^0.20.3",
69
68
  "tsx": "^4.21.0"
70
69
  },
71
- "gitHead": "ebff8c309c7b7940bdebed1dc096d99a318af3cc"
70
+ "gitHead": "49b671a9dd0970e01eea1be9a8821f1d3131384b"
72
71
  }