@webgal/language-server 0.0.2-alpha.3 → 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 +1 -1
- package/build/browser.mjs +1 -1
- package/build/index.cjs +1 -1
- package/build/index.mjs +1 -1
- package/build/utils.cjs +7 -8
- package/build/utils.d.cts +1 -4
- package/build/utils.d.mts +1 -4
- package/build/utils.mjs +2 -2
- package/build/warnings-CWkIAwTu.mjs +144 -0
- package/build/warnings-De2NDXgx.cjs +155 -0
- package/package.json +3 -4
- package/build/providerState-B7hGbqQj.cjs +0 -3287
- package/build/providerState-CLCXHs37.mjs +0 -3270
package/build/browser.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
require('./
|
|
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 "./
|
|
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('./
|
|
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");
|
package/build/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./
|
|
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";
|
package/build/utils.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
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");
|
|
@@ -478,8 +478,8 @@ async function validateTextDocument(connection, textDocument, textOverride) {
|
|
|
478
478
|
let problems = 0;
|
|
479
479
|
const diagnostics = [];
|
|
480
480
|
let _sp = text.split(/\n|\t\n|\r\n/);
|
|
481
|
-
for (let i in
|
|
482
|
-
const _token =
|
|
481
|
+
for (let i in require_warnings.warningConfig) {
|
|
482
|
+
const _token = require_warnings.warningConfig[i];
|
|
483
483
|
const _pattern = _token.pattern;
|
|
484
484
|
if (_token.is_line) continue;
|
|
485
485
|
if (_token.customCheck && _token.customCheck instanceof Function) {
|
|
@@ -505,15 +505,15 @@ async function validateTextDocument(connection, textDocument, textOverride) {
|
|
|
505
505
|
uri: textDocument.uri,
|
|
506
506
|
range: Object.assign({}, diagnostic.range)
|
|
507
507
|
},
|
|
508
|
-
message:
|
|
508
|
+
message: require_warnings.getDiagnosticInformation(i)
|
|
509
509
|
}];
|
|
510
510
|
diagnostics.push(diagnostic);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
for (let _line_index = 0; _line_index < _sp.length; _line_index++) {
|
|
514
514
|
const _line_text = _sp[_line_index];
|
|
515
|
-
for (let i in
|
|
516
|
-
const _token =
|
|
515
|
+
for (let i in require_warnings.warningConfig) {
|
|
516
|
+
const _token = require_warnings.warningConfig[i];
|
|
517
517
|
const _pattern = _token.pattern;
|
|
518
518
|
if (!_token.is_line) continue;
|
|
519
519
|
const _newarr = _sp.slice(0, _line_index).join();
|
|
@@ -540,7 +540,7 @@ async function validateTextDocument(connection, textDocument, textOverride) {
|
|
|
540
540
|
uri: textDocument.uri,
|
|
541
541
|
range: Object.assign({}, diagnostic.range)
|
|
542
542
|
},
|
|
543
|
-
message:
|
|
543
|
+
message: require_warnings.getDiagnosticInformation(i)
|
|
544
544
|
}];
|
|
545
545
|
diagnostics.push(diagnostic);
|
|
546
546
|
}
|
|
@@ -612,7 +612,6 @@ exports.findTokenRange = findTokenRange;
|
|
|
612
612
|
exports.getDocumentSettings = getDocumentSettings;
|
|
613
613
|
exports.getPatternAtPosition = getPatternAtPosition;
|
|
614
614
|
exports.getStageCompletionContext = getStageCompletionContext;
|
|
615
|
-
exports.getState = require_providerState.getState;
|
|
616
615
|
exports.getTokenOrPatternAtPosition = getTokenOrPatternAtPosition;
|
|
617
616
|
exports.getWebgalDefinitionMap = getWebgalDefinitionMap;
|
|
618
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>;
|
|
@@ -108,4 +105,4 @@ declare function createClientVfsFileSystem(connection: SendRequestConnection, op
|
|
|
108
105
|
uriToPath?: (uri: URI) => string;
|
|
109
106
|
}): FileSystem;
|
|
110
107
|
//#endregion
|
|
111
|
-
export { StateConfig, WebgalDocumentLinkCandidate, WebgalVirtualCode, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext,
|
|
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>;
|
|
@@ -108,4 +105,4 @@ declare function createClientVfsFileSystem(connection: SendRequestConnection, op
|
|
|
108
105
|
uriToPath?: (uri: URI) => string;
|
|
109
106
|
}): FileSystem;
|
|
110
107
|
//#endregion
|
|
111
|
-
export { StateConfig, WebgalDocumentLinkCandidate, WebgalVirtualCode, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext,
|
|
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
|
|
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";
|
|
@@ -600,4 +600,4 @@ function createClientVfsFileSystem(connection, options) {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
//#endregion
|
|
603
|
-
export { StateConfig, bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createVolarFileSystemFromVirtualFileSystem, createWebgalVirtualCode, defaultSettings, documentSettings, findTokenRange, getDocumentSettings, getPatternAtPosition, getStageCompletionContext,
|
|
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.
|
|
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,7 +41,6 @@
|
|
|
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
45
|
"dev:ws": "pnpm build && node bin/webgal-language-server.js --ws",
|
|
47
46
|
"format": " prettier --write \"src/**/*.ts\"",
|
|
@@ -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.
|
|
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": "
|
|
70
|
+
"gitHead": "49b671a9dd0970e01eea1be9a8821f1d3131384b"
|
|
72
71
|
}
|