@volar/kit 1.6.6 → 1.6.8
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/out/createFormatter.js +2 -2
- package/out/createLinter.js +10 -11
- package/package.json +3 -3
package/out/createFormatter.js
CHANGED
|
@@ -43,7 +43,7 @@ function createFormatter(config, compilerOptions = utils_1.defaultCompilerOption
|
|
|
43
43
|
const document = service.context.getTextDocument(uri);
|
|
44
44
|
if (!document)
|
|
45
45
|
throw `file not found: ${fileName}`;
|
|
46
|
-
const edits = await service.format(uri, options, undefined, undefined
|
|
46
|
+
const edits = await service.format(uri, options, undefined, undefined);
|
|
47
47
|
if (edits?.length) {
|
|
48
48
|
const newString = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
49
49
|
return newString;
|
|
@@ -55,7 +55,7 @@ function createFormatter(config, compilerOptions = utils_1.defaultCompilerOption
|
|
|
55
55
|
dummyScriptLanguageId = languageId;
|
|
56
56
|
dummyScriptVersion++;
|
|
57
57
|
const document = service.context.getTextDocument(dummyScriptUri);
|
|
58
|
-
const edits = await service.format(dummyScriptUri, options, undefined, undefined
|
|
58
|
+
const edits = await service.format(dummyScriptUri, options, undefined, undefined);
|
|
59
59
|
if (edits?.length) {
|
|
60
60
|
const newString = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
61
61
|
return newString;
|
package/out/createLinter.js
CHANGED
|
@@ -14,11 +14,6 @@ function createLinter(config, host) {
|
|
|
14
14
|
rootUri: vscode_uri_1.URI.file(host.getCurrentDirectory()),
|
|
15
15
|
getConfiguration: section => (0, utils_1.getConfiguration)(settings, section),
|
|
16
16
|
}, config, host);
|
|
17
|
-
const formatHost = {
|
|
18
|
-
getCurrentDirectory: () => host.getCurrentDirectory(),
|
|
19
|
-
getCanonicalFileName: (fileName) => host.useCaseSensitiveFileNames?.() ? fileName : fileName.toLowerCase(),
|
|
20
|
-
getNewLine: () => host.getNewLine?.() ?? '\n',
|
|
21
|
-
};
|
|
22
17
|
return {
|
|
23
18
|
check,
|
|
24
19
|
fixErrors,
|
|
@@ -41,10 +36,10 @@ function createLinter(config, host) {
|
|
|
41
36
|
const document = service.context.getTextDocument(uri);
|
|
42
37
|
if (document) {
|
|
43
38
|
const range = { start: document.positionAt(0), end: document.positionAt(document.getText().length) };
|
|
44
|
-
const codeActions = await service.doCodeActions(uri, range, { diagnostics, only, triggerKind:
|
|
39
|
+
const codeActions = await service.doCodeActions(uri, range, { diagnostics, only, triggerKind: 1 });
|
|
45
40
|
if (codeActions) {
|
|
46
41
|
for (let i = 0; i < codeActions.length; i++) {
|
|
47
|
-
codeActions[i] = await service.doCodeActionResolve(codeActions[i]
|
|
42
|
+
codeActions[i] = await service.doCodeActionResolve(codeActions[i]);
|
|
48
43
|
}
|
|
49
44
|
const edits = codeActions.map(codeAction => codeAction.edit).filter((edit) => !!edit);
|
|
50
45
|
if (edits.length) {
|
|
@@ -61,7 +56,7 @@ function createLinter(config, host) {
|
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
58
|
for (const change of rootEdit.documentChanges ?? []) {
|
|
64
|
-
if (
|
|
59
|
+
if ('textDocument' in change) {
|
|
65
60
|
const editDocument = service.context.getTextDocument(change.textDocument.uri);
|
|
66
61
|
if (editDocument) {
|
|
67
62
|
const newString = vscode_languageserver_textdocument_1.TextDocument.applyEdits(editDocument, change.edits);
|
|
@@ -83,19 +78,23 @@ function createLinter(config, host) {
|
|
|
83
78
|
}
|
|
84
79
|
console.log(text);
|
|
85
80
|
}
|
|
86
|
-
function formatErrors(fileName, diagnostics) {
|
|
81
|
+
function formatErrors(fileName, diagnostics, rootPath = process.cwd()) {
|
|
87
82
|
fileName = (0, utils_1.asPosix)(fileName);
|
|
88
83
|
const uri = (0, utils_1.fileNameToUri)(fileName);
|
|
89
84
|
const document = service.context.getTextDocument(uri);
|
|
90
85
|
const errors = diagnostics.map(diagnostic => ({
|
|
91
|
-
category: diagnostic.severity ===
|
|
86
|
+
category: diagnostic.severity === 1 ? ts.DiagnosticCategory.Error : ts.DiagnosticCategory.Warning,
|
|
92
87
|
code: diagnostic.code,
|
|
93
88
|
file: ts.createSourceFile(fileName, document.getText(), ts.ScriptTarget.JSON),
|
|
94
89
|
start: document.offsetAt(diagnostic.range.start),
|
|
95
90
|
length: document.offsetAt(diagnostic.range.end) - document.offsetAt(diagnostic.range.start),
|
|
96
91
|
messageText: diagnostic.message,
|
|
97
92
|
}));
|
|
98
|
-
const text = ts.formatDiagnosticsWithColorAndContext(errors,
|
|
93
|
+
const text = ts.formatDiagnosticsWithColorAndContext(errors, {
|
|
94
|
+
getCurrentDirectory: () => rootPath ?? host.getCurrentDirectory(),
|
|
95
|
+
getCanonicalFileName: (fileName) => host.useCaseSensitiveFileNames?.() ? fileName : fileName.toLowerCase(),
|
|
96
|
+
getNewLine: () => host.getNewLine?.() ?? '\n',
|
|
97
|
+
});
|
|
99
98
|
return text;
|
|
100
99
|
}
|
|
101
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/kit",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/kit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-service": "1.6.
|
|
16
|
+
"@volar/language-service": "1.6.8",
|
|
17
17
|
"typesafe-path": "^0.2.2",
|
|
18
18
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
19
19
|
"vscode-uri": "^3.0.7"
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "3d269c7e69850ac5497469bede13f057db8a4980"
|
|
25
25
|
}
|