@514labs/moose-lsp 1.4.0 → 1.4.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/dist/codeActions.d.ts +7 -2
- package/dist/codeActions.js +57 -10
- package/dist/codeActions.js.map +1 -1
- package/dist/codeActions.test.js +64 -2
- package/dist/codeActions.test.js.map +1 -1
- package/dist/diagnostics.d.ts +9 -1
- package/dist/diagnostics.js +24 -0
- package/dist/diagnostics.js.map +1 -1
- package/dist/diagnostics.test.js +56 -5
- package/dist/diagnostics.test.js.map +1 -1
- package/dist/node_modules/@514labs/moose-sql-validator-wasm/package.json +1 -1
- package/dist/node_modules/@514labs/moose-sql-validator-wasm/pkg/sql_validator_bg.wasm +0 -0
- package/dist/pythonSqlExtractor.js +5 -1
- package/dist/pythonSqlExtractor.js.map +1 -1
- package/dist/server.integration.test.js +222 -26
- package/dist/server.integration.test.js.map +1 -1
- package/dist/server.js +209 -87
- package/dist/server.js.map +1 -1
- package/dist/serverLogic.js +9 -0
- package/dist/serverLogic.js.map +1 -1
- package/dist/serverLogic.test.js +127 -10
- package/dist/serverLogic.test.js.map +1 -1
- package/dist/sqlExtractor.js +43 -12
- package/dist/sqlExtractor.js.map +1 -1
- package/dist/sqlExtractor.test.js +106 -4
- package/dist/sqlExtractor.test.js.map +1 -1
- package/dist/sqlLocations.d.ts +9 -1
- package/dist/sqlLocations.js +9 -1
- package/dist/sqlLocations.js.map +1 -1
- package/dist/sqlLocations.test.js +49 -1
- package/dist/sqlLocations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -3584,11 +3584,11 @@ var require_main2 = __commonJS({
|
|
|
3584
3584
|
DiagnosticSeverity3.Information = 3;
|
|
3585
3585
|
DiagnosticSeverity3.Hint = 4;
|
|
3586
3586
|
})(DiagnosticSeverity2 || (exports3.DiagnosticSeverity = DiagnosticSeverity2 = {}));
|
|
3587
|
-
var
|
|
3588
|
-
(function(
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
})(
|
|
3587
|
+
var DiagnosticTag2;
|
|
3588
|
+
(function(DiagnosticTag3) {
|
|
3589
|
+
DiagnosticTag3.Unnecessary = 1;
|
|
3590
|
+
DiagnosticTag3.Deprecated = 2;
|
|
3591
|
+
})(DiagnosticTag2 || (exports3.DiagnosticTag = DiagnosticTag2 = {}));
|
|
3592
3592
|
var CodeDescription;
|
|
3593
3593
|
(function(CodeDescription2) {
|
|
3594
3594
|
function is(value) {
|
|
@@ -4375,18 +4375,18 @@ var require_main2 = __commonJS({
|
|
|
4375
4375
|
}
|
|
4376
4376
|
DocumentSymbol2.is = is;
|
|
4377
4377
|
})(DocumentSymbol || (exports3.DocumentSymbol = DocumentSymbol = {}));
|
|
4378
|
-
var
|
|
4379
|
-
(function(
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
})(
|
|
4378
|
+
var CodeActionKind3;
|
|
4379
|
+
(function(CodeActionKind4) {
|
|
4380
|
+
CodeActionKind4.Empty = "";
|
|
4381
|
+
CodeActionKind4.QuickFix = "quickfix";
|
|
4382
|
+
CodeActionKind4.Refactor = "refactor";
|
|
4383
|
+
CodeActionKind4.RefactorExtract = "refactor.extract";
|
|
4384
|
+
CodeActionKind4.RefactorInline = "refactor.inline";
|
|
4385
|
+
CodeActionKind4.RefactorRewrite = "refactor.rewrite";
|
|
4386
|
+
CodeActionKind4.Source = "source";
|
|
4387
|
+
CodeActionKind4.SourceOrganizeImports = "source.organizeImports";
|
|
4388
|
+
CodeActionKind4.SourceFixAll = "source.fixAll";
|
|
4389
|
+
})(CodeActionKind3 || (exports3.CodeActionKind = CodeActionKind3 = {}));
|
|
4390
4390
|
var CodeActionTriggerKind;
|
|
4391
4391
|
(function(CodeActionTriggerKind2) {
|
|
4392
4392
|
CodeActionTriggerKind2.Invoked = 1;
|
|
@@ -219722,7 +219722,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
219722
219722
|
init_cjs_shims();
|
|
219723
219723
|
var path8 = __toESM(require("path"));
|
|
219724
219724
|
var import_moose_sql_validator_wasm2 = require("@514labs/moose-sql-validator-wasm");
|
|
219725
|
-
var
|
|
219725
|
+
var import_node4 = __toESM(require_node3());
|
|
219726
219726
|
|
|
219727
219727
|
// ../../node_modules/.pnpm/vscode-languageserver-textdocument@1.0.12/node_modules/vscode-languageserver-textdocument/lib/esm/main.js
|
|
219728
219728
|
init_cjs_shims();
|
|
@@ -220129,6 +220129,7 @@ async function loadClickHouseData(requestedVersion) {
|
|
|
220129
220129
|
// src/codeActions.ts
|
|
220130
220130
|
init_cjs_shims();
|
|
220131
220131
|
var import_typescript = __toESM(require_typescript());
|
|
220132
|
+
var import_node = __toESM(require_node3());
|
|
220132
220133
|
|
|
220133
220134
|
// src/formatting.ts
|
|
220134
220135
|
init_cjs_shims();
|
|
@@ -220277,17 +220278,21 @@ function createFormatSqlEdit(sourceFile, node) {
|
|
|
220277
220278
|
}
|
|
220278
220279
|
function findTemplateNodeById(sourceFile, locationId) {
|
|
220279
220280
|
let targetNode;
|
|
220281
|
+
function isSqlTag(tag) {
|
|
220282
|
+
if (import_typescript.default.isIdentifier(tag) && tag.text === "sql") return true;
|
|
220283
|
+
if (import_typescript.default.isPropertyAccessExpression(tag) && import_typescript.default.isIdentifier(tag.expression) && tag.expression.text === "sql" && (tag.name.text === "statement" || tag.name.text === "fragment")) {
|
|
220284
|
+
return true;
|
|
220285
|
+
}
|
|
220286
|
+
return false;
|
|
220287
|
+
}
|
|
220280
220288
|
function visit(node) {
|
|
220281
|
-
if (import_typescript.default.isTaggedTemplateExpression(node)) {
|
|
220282
|
-
const
|
|
220283
|
-
|
|
220284
|
-
|
|
220285
|
-
|
|
220286
|
-
|
|
220287
|
-
|
|
220288
|
-
if (id === locationId) {
|
|
220289
|
-
targetNode = node;
|
|
220290
|
-
}
|
|
220289
|
+
if (import_typescript.default.isTaggedTemplateExpression(node) && isSqlTag(node.tag)) {
|
|
220290
|
+
const start = sourceFile.getLineAndCharacterOfPosition(
|
|
220291
|
+
node.template.getStart()
|
|
220292
|
+
);
|
|
220293
|
+
const id = `${sourceFile.fileName}:${start.line + 1}:${start.character + 1}`;
|
|
220294
|
+
if (id === locationId) {
|
|
220295
|
+
targetNode = node;
|
|
220291
220296
|
}
|
|
220292
220297
|
}
|
|
220293
220298
|
if (!targetNode) {
|
|
@@ -220297,10 +220302,50 @@ function findTemplateNodeById(sourceFile, locationId) {
|
|
|
220297
220302
|
visit(sourceFile);
|
|
220298
220303
|
return targetNode;
|
|
220299
220304
|
}
|
|
220305
|
+
function createDeprecationCodeActions(uri, diagnostics) {
|
|
220306
|
+
const actions = [];
|
|
220307
|
+
for (const diagnostic of diagnostics) {
|
|
220308
|
+
const data = diagnostic.data;
|
|
220309
|
+
if (data?.type !== "deprecated-sql-tag") continue;
|
|
220310
|
+
actions.push(
|
|
220311
|
+
{
|
|
220312
|
+
title: "Convert to 'sql.statement'",
|
|
220313
|
+
kind: import_node.CodeActionKind.QuickFix,
|
|
220314
|
+
diagnostics: [diagnostic],
|
|
220315
|
+
edit: {
|
|
220316
|
+
changes: {
|
|
220317
|
+
[uri]: [
|
|
220318
|
+
{
|
|
220319
|
+
range: diagnostic.range,
|
|
220320
|
+
newText: "sql.statement"
|
|
220321
|
+
}
|
|
220322
|
+
]
|
|
220323
|
+
}
|
|
220324
|
+
}
|
|
220325
|
+
},
|
|
220326
|
+
{
|
|
220327
|
+
title: "Convert to 'sql.fragment'",
|
|
220328
|
+
kind: import_node.CodeActionKind.QuickFix,
|
|
220329
|
+
diagnostics: [diagnostic],
|
|
220330
|
+
edit: {
|
|
220331
|
+
changes: {
|
|
220332
|
+
[uri]: [
|
|
220333
|
+
{
|
|
220334
|
+
range: diagnostic.range,
|
|
220335
|
+
newText: "sql.fragment"
|
|
220336
|
+
}
|
|
220337
|
+
]
|
|
220338
|
+
}
|
|
220339
|
+
}
|
|
220340
|
+
}
|
|
220341
|
+
);
|
|
220342
|
+
}
|
|
220343
|
+
return actions;
|
|
220344
|
+
}
|
|
220300
220345
|
|
|
220301
220346
|
// src/diagnostics.ts
|
|
220302
220347
|
init_cjs_shims();
|
|
220303
|
-
var
|
|
220348
|
+
var import_node2 = __toESM(require_node3());
|
|
220304
220349
|
function createLocationDiagnostic(location, validationError) {
|
|
220305
220350
|
const uri = `file://${location.file}`;
|
|
220306
220351
|
const range2 = {
|
|
@@ -220315,16 +220360,38 @@ function createLocationDiagnostic(location, validationError) {
|
|
|
220315
220360
|
};
|
|
220316
220361
|
const diagnostic = {
|
|
220317
220362
|
range: range2,
|
|
220318
|
-
severity:
|
|
220363
|
+
severity: import_node2.DiagnosticSeverity.Error,
|
|
220319
220364
|
message: `Invalid SQL: ${validationError.message}`,
|
|
220320
220365
|
source: "moose-sql"
|
|
220321
220366
|
};
|
|
220322
220367
|
return { uri, diagnostic };
|
|
220323
220368
|
}
|
|
220369
|
+
function createDeprecationDiagnostic(location) {
|
|
220370
|
+
const uri = `file://${location.file}`;
|
|
220371
|
+
const range2 = {
|
|
220372
|
+
start: {
|
|
220373
|
+
line: location.tagLine - 1,
|
|
220374
|
+
character: location.tagColumn - 1
|
|
220375
|
+
},
|
|
220376
|
+
end: {
|
|
220377
|
+
line: location.tagLine - 1,
|
|
220378
|
+
character: location.tagEndColumn - 1
|
|
220379
|
+
}
|
|
220380
|
+
};
|
|
220381
|
+
const diagnostic = {
|
|
220382
|
+
range: range2,
|
|
220383
|
+
severity: import_node2.DiagnosticSeverity.Hint,
|
|
220384
|
+
tags: [import_node2.DiagnosticTag.Deprecated],
|
|
220385
|
+
message: "The 'sql' tag is deprecated. Use 'sql.statement' for complete SQL statements or 'sql.fragment' for SQL expressions and conditions.",
|
|
220386
|
+
source: "moose-sql",
|
|
220387
|
+
data: { type: "deprecated-sql-tag" }
|
|
220388
|
+
};
|
|
220389
|
+
return { uri, diagnostic };
|
|
220390
|
+
}
|
|
220324
220391
|
|
|
220325
220392
|
// src/hover.ts
|
|
220326
220393
|
init_cjs_shims();
|
|
220327
|
-
var
|
|
220394
|
+
var import_node3 = __toESM(require_node3());
|
|
220328
220395
|
function getWordAtPosition(text, position) {
|
|
220329
220396
|
if (position < 0 || position > text.length) {
|
|
220330
220397
|
return "";
|
|
@@ -220497,7 +220564,7 @@ function createHoverContent(info, data) {
|
|
|
220497
220564
|
}
|
|
220498
220565
|
}
|
|
220499
220566
|
return {
|
|
220500
|
-
kind:
|
|
220567
|
+
kind: import_node3.MarkupKind.Markdown,
|
|
220501
220568
|
value: parts.join("\n\n")
|
|
220502
220569
|
};
|
|
220503
220570
|
}
|
|
@@ -227643,7 +227710,11 @@ function createSqlLocation(filePath, text, startPosition, endPosition) {
|
|
|
227643
227710
|
// 1-based
|
|
227644
227711
|
endLine: endPosition.row + 1,
|
|
227645
227712
|
endColumn: endPosition.column + 1,
|
|
227646
|
-
templateText: text
|
|
227713
|
+
templateText: text,
|
|
227714
|
+
tagKind: "statement",
|
|
227715
|
+
tagLine: startPosition.row + 1,
|
|
227716
|
+
tagColumn: startPosition.column + 1,
|
|
227717
|
+
tagEndColumn: startPosition.column + 1
|
|
227647
227718
|
};
|
|
227648
227719
|
}
|
|
227649
227720
|
function extractPythonSqlLocations(sourceCode, filePath) {
|
|
@@ -227805,6 +227876,14 @@ function isPythonFile(filePath) {
|
|
|
227805
227876
|
function validateSqlLocations(sqlLocations, validateSql2, createDiagnostic) {
|
|
227806
227877
|
const diagnosticsMap = /* @__PURE__ */ new Map();
|
|
227807
227878
|
for (const location of sqlLocations) {
|
|
227879
|
+
if (location.tagKind === "bare") {
|
|
227880
|
+
const { uri, diagnostic } = createDeprecationDiagnostic(location);
|
|
227881
|
+
if (!diagnosticsMap.has(uri)) {
|
|
227882
|
+
diagnosticsMap.set(uri, []);
|
|
227883
|
+
}
|
|
227884
|
+
diagnosticsMap.get(uri)?.push(diagnostic);
|
|
227885
|
+
}
|
|
227886
|
+
if (location.tagKind === "fragment") continue;
|
|
227808
227887
|
const preparedSql = prepareSqlForValidation(location.templateText);
|
|
227809
227888
|
const result = validateSql2(preparedSql);
|
|
227810
227889
|
if (!result.valid && result.error) {
|
|
@@ -227821,23 +227900,43 @@ function validateSqlLocations(sqlLocations, validateSql2, createDiagnostic) {
|
|
|
227821
227900
|
// src/sqlExtractor.ts
|
|
227822
227901
|
init_cjs_shims();
|
|
227823
227902
|
var import_typescript2 = __toESM(require_typescript());
|
|
227824
|
-
function
|
|
227903
|
+
function getMooseSqlTagKind(node, typeChecker) {
|
|
227825
227904
|
const tag = node.tag;
|
|
227826
|
-
|
|
227827
|
-
|
|
227905
|
+
let sqlIdentifier;
|
|
227906
|
+
let tagKind;
|
|
227907
|
+
if (import_typescript2.default.isIdentifier(tag) && tag.text === "sql") {
|
|
227908
|
+
sqlIdentifier = tag;
|
|
227909
|
+
tagKind = "bare";
|
|
227910
|
+
} else if (import_typescript2.default.isPropertyAccessExpression(tag) && import_typescript2.default.isIdentifier(tag.expression) && tag.expression.text === "sql") {
|
|
227911
|
+
const propName = tag.name.text;
|
|
227912
|
+
if (propName === "statement") {
|
|
227913
|
+
tagKind = "statement";
|
|
227914
|
+
} else if (propName === "fragment") {
|
|
227915
|
+
tagKind = "fragment";
|
|
227916
|
+
} else {
|
|
227917
|
+
return null;
|
|
227918
|
+
}
|
|
227919
|
+
sqlIdentifier = tag.expression;
|
|
227920
|
+
} else {
|
|
227921
|
+
return null;
|
|
227922
|
+
}
|
|
227923
|
+
const symbol = typeChecker.getSymbolAtLocation(sqlIdentifier);
|
|
227924
|
+
if (!symbol) {
|
|
227925
|
+
return tagKind;
|
|
227828
227926
|
}
|
|
227829
|
-
const
|
|
227830
|
-
if (
|
|
227831
|
-
const isFromMooseLib =
|
|
227927
|
+
const resolvedSymbol = symbol.flags & import_typescript2.default.SymbolFlags.Alias ? typeChecker.getAliasedSymbol(symbol) : symbol;
|
|
227928
|
+
if (resolvedSymbol?.declarations?.length) {
|
|
227929
|
+
const isFromMooseLib = resolvedSymbol.declarations.some((decl) => {
|
|
227832
227930
|
const sourceFile = decl.getSourceFile();
|
|
227833
227931
|
const fileName = sourceFile.fileName;
|
|
227834
227932
|
return fileName.includes("moose-lib") || fileName.includes("@514labs/moose-lib") || fileName.includes("514labs/moose-lib") || fileName.includes("sqlHelpers");
|
|
227835
227933
|
});
|
|
227836
227934
|
if (isFromMooseLib) {
|
|
227837
|
-
return
|
|
227935
|
+
return tagKind;
|
|
227838
227936
|
}
|
|
227937
|
+
return null;
|
|
227839
227938
|
}
|
|
227840
|
-
return
|
|
227939
|
+
return tagKind;
|
|
227841
227940
|
}
|
|
227842
227941
|
function extractTemplateText2(template) {
|
|
227843
227942
|
if (import_typescript2.default.isNoSubstitutionTemplateLiteral(template)) {
|
|
@@ -227849,11 +227948,15 @@ function extractTemplateText2(template) {
|
|
|
227849
227948
|
}
|
|
227850
227949
|
return text;
|
|
227851
227950
|
}
|
|
227852
|
-
function extractSqlLocation(node, sourceFile) {
|
|
227951
|
+
function extractSqlLocation(node, sourceFile, tagKind) {
|
|
227853
227952
|
const start = sourceFile.getLineAndCharacterOfPosition(
|
|
227854
227953
|
node.template.getStart()
|
|
227855
227954
|
);
|
|
227856
227955
|
const end = sourceFile.getLineAndCharacterOfPosition(node.template.getEnd());
|
|
227956
|
+
const tagStart = sourceFile.getLineAndCharacterOfPosition(
|
|
227957
|
+
node.tag.getStart()
|
|
227958
|
+
);
|
|
227959
|
+
const tagEnd = sourceFile.getLineAndCharacterOfPosition(node.tag.getEnd());
|
|
227857
227960
|
return {
|
|
227858
227961
|
id: `${sourceFile.fileName}:${start.line + 1}:${start.character + 1}`,
|
|
227859
227962
|
file: sourceFile.fileName,
|
|
@@ -227863,14 +227966,21 @@ function extractSqlLocation(node, sourceFile) {
|
|
|
227863
227966
|
// 1-based
|
|
227864
227967
|
endLine: end.line + 1,
|
|
227865
227968
|
endColumn: end.character + 1,
|
|
227866
|
-
templateText: extractTemplateText2(node.template)
|
|
227969
|
+
templateText: extractTemplateText2(node.template),
|
|
227970
|
+
tagKind,
|
|
227971
|
+
tagLine: tagStart.line + 1,
|
|
227972
|
+
tagColumn: tagStart.character + 1,
|
|
227973
|
+
tagEndColumn: tagEnd.character + 1
|
|
227867
227974
|
};
|
|
227868
227975
|
}
|
|
227869
227976
|
function extractSqlLocations(sourceFile, typeChecker) {
|
|
227870
227977
|
const locations = [];
|
|
227871
227978
|
function visit(node) {
|
|
227872
|
-
if (import_typescript2.default.isTaggedTemplateExpression(node)
|
|
227873
|
-
|
|
227979
|
+
if (import_typescript2.default.isTaggedTemplateExpression(node)) {
|
|
227980
|
+
const tagKind = getMooseSqlTagKind(node, typeChecker);
|
|
227981
|
+
if (tagKind !== null) {
|
|
227982
|
+
locations.push(extractSqlLocation(node, sourceFile, tagKind));
|
|
227983
|
+
}
|
|
227874
227984
|
}
|
|
227875
227985
|
import_typescript2.default.forEachChild(node, visit);
|
|
227876
227986
|
}
|
|
@@ -227989,8 +228099,8 @@ function createTypeScriptService() {
|
|
|
227989
228099
|
}
|
|
227990
228100
|
|
|
227991
228101
|
// src/server.ts
|
|
227992
|
-
var connection = (0,
|
|
227993
|
-
var documents = new
|
|
228102
|
+
var connection = (0, import_node4.createConnection)(import_node4.ProposedFeatures.all);
|
|
228103
|
+
var documents = new import_node4.TextDocuments(TextDocument);
|
|
227994
228104
|
var mooseProjectRoot = null;
|
|
227995
228105
|
var mooseProjectType = null;
|
|
227996
228106
|
var tsService = null;
|
|
@@ -228259,14 +228369,14 @@ connection.onInitialize(
|
|
|
228259
228369
|
capabilities: {
|
|
228260
228370
|
textDocumentSync: {
|
|
228261
228371
|
openClose: true,
|
|
228262
|
-
change:
|
|
228372
|
+
change: import_node4.TextDocumentSyncKind.Full,
|
|
228263
228373
|
// Full sync for as-you-type validation
|
|
228264
228374
|
save: {
|
|
228265
228375
|
includeText: true
|
|
228266
228376
|
}
|
|
228267
228377
|
},
|
|
228268
228378
|
codeActionProvider: {
|
|
228269
|
-
codeActionKinds: ["source.formatSql"]
|
|
228379
|
+
codeActionKinds: [import_node4.CodeActionKind.QuickFix, "source.formatSql"]
|
|
228270
228380
|
},
|
|
228271
228381
|
completionProvider: {
|
|
228272
228382
|
triggerCharacters: [".", "(", " "],
|
|
@@ -228320,59 +228430,71 @@ connection.onCodeAction((params) => {
|
|
|
228320
228430
|
if (!document2) return [];
|
|
228321
228431
|
const filePath = new URL(params.textDocument.uri).pathname;
|
|
228322
228432
|
if (!shouldValidateFile(filePath, mooseProjectRoot)) return [];
|
|
228323
|
-
|
|
228324
|
-
|
|
228325
|
-
|
|
228326
|
-
|
|
228327
|
-
|
|
228328
|
-
|
|
228329
|
-
|
|
228330
|
-
);
|
|
228331
|
-
const location = findSqlTemplateAtPosition(
|
|
228332
|
-
sqlLocations,
|
|
228333
|
-
params.range.start.line,
|
|
228334
|
-
params.range.start.character
|
|
228433
|
+
const actions = [];
|
|
228434
|
+
if (params.context.diagnostics.length > 0) {
|
|
228435
|
+
actions.push(
|
|
228436
|
+
...createDeprecationCodeActions(
|
|
228437
|
+
params.textDocument.uri,
|
|
228438
|
+
params.context.diagnostics
|
|
228439
|
+
)
|
|
228335
228440
|
);
|
|
228336
|
-
|
|
228337
|
-
|
|
228338
|
-
|
|
228339
|
-
|
|
228340
|
-
|
|
228341
|
-
|
|
228342
|
-
|
|
228343
|
-
|
|
228344
|
-
|
|
228345
|
-
|
|
228346
|
-
|
|
228347
|
-
|
|
228441
|
+
}
|
|
228442
|
+
if (isTypeScriptFile(filePath) && tsService?.isHealthy()) {
|
|
228443
|
+
try {
|
|
228444
|
+
const sourceFile = tsService.getSourceFile(filePath);
|
|
228445
|
+
if (sourceFile) {
|
|
228446
|
+
const sqlLocations = extractSqlLocations(
|
|
228447
|
+
sourceFile,
|
|
228448
|
+
tsService.getTypeChecker()
|
|
228449
|
+
);
|
|
228450
|
+
const location = findSqlTemplateAtPosition(
|
|
228451
|
+
sqlLocations,
|
|
228452
|
+
params.range.start.line,
|
|
228453
|
+
params.range.start.character
|
|
228454
|
+
);
|
|
228455
|
+
if (location) {
|
|
228456
|
+
const node = findTemplateNodeById(sourceFile, location.id);
|
|
228457
|
+
if (node) {
|
|
228458
|
+
const edit = createFormatSqlEdit(sourceFile, node);
|
|
228459
|
+
if (edit) {
|
|
228460
|
+
actions.push({
|
|
228461
|
+
title: "Format SQL",
|
|
228462
|
+
kind: `${import_node4.CodeActionKind.Source}.formatSql`,
|
|
228463
|
+
edit: {
|
|
228464
|
+
changes: {
|
|
228465
|
+
[params.textDocument.uri]: [edit]
|
|
228466
|
+
}
|
|
228467
|
+
}
|
|
228468
|
+
});
|
|
228469
|
+
}
|
|
228348
228470
|
}
|
|
228349
228471
|
}
|
|
228350
228472
|
}
|
|
228351
|
-
|
|
228352
|
-
|
|
228353
|
-
return [];
|
|
228473
|
+
} catch {
|
|
228474
|
+
}
|
|
228354
228475
|
}
|
|
228476
|
+
return actions;
|
|
228355
228477
|
});
|
|
228356
228478
|
function mapCompletionItemKind(kind) {
|
|
228357
228479
|
switch (kind) {
|
|
228358
228480
|
case "function":
|
|
228359
|
-
return
|
|
228481
|
+
return import_node4.CompletionItemKind.Function;
|
|
228360
228482
|
case "aggregate_function":
|
|
228361
|
-
return
|
|
228483
|
+
return import_node4.CompletionItemKind.Method;
|
|
228362
228484
|
case "table_function":
|
|
228363
|
-
return
|
|
228485
|
+
return import_node4.CompletionItemKind.Function;
|
|
228364
228486
|
case "keyword":
|
|
228365
|
-
return
|
|
228487
|
+
return import_node4.CompletionItemKind.Keyword;
|
|
228366
228488
|
case "data_type":
|
|
228367
|
-
return
|
|
228489
|
+
return import_node4.CompletionItemKind.TypeParameter;
|
|
228368
228490
|
case "table_engine":
|
|
228369
|
-
return
|
|
228491
|
+
return import_node4.CompletionItemKind.Class;
|
|
228370
228492
|
case "format":
|
|
228371
|
-
return
|
|
228493
|
+
return import_node4.CompletionItemKind.Constant;
|
|
228372
228494
|
case "setting":
|
|
228373
|
-
return
|
|
228495
|
+
return import_node4.CompletionItemKind.Property;
|
|
228374
228496
|
default:
|
|
228375
|
-
return
|
|
228497
|
+
return import_node4.CompletionItemKind.Text;
|
|
228376
228498
|
}
|
|
228377
228499
|
}
|
|
228378
228500
|
function toRustCompletionItem(rustItem, useSnippets) {
|
|
@@ -228382,10 +228504,10 @@ function toRustCompletionItem(rustItem, useSnippets) {
|
|
|
228382
228504
|
if (rustItem.hasParams) {
|
|
228383
228505
|
if (useSnippets) {
|
|
228384
228506
|
insertText = `${rustItem.label}($1)$0`;
|
|
228385
|
-
insertTextFormat =
|
|
228507
|
+
insertTextFormat = import_node4.InsertTextFormat.Snippet;
|
|
228386
228508
|
} else {
|
|
228387
228509
|
insertText = `${rustItem.label}()`;
|
|
228388
|
-
insertTextFormat =
|
|
228510
|
+
insertTextFormat = import_node4.InsertTextFormat.PlainText;
|
|
228389
228511
|
}
|
|
228390
228512
|
}
|
|
228391
228513
|
return {
|