dql-language-support 1.0.1 → 1.0.2

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.
@@ -0,0 +1,9 @@
1
+
2
+ > dql-language-support@1.0.2 build /Users/Kranthi_1/DuckCode-DQL/DQL/dql/apps/vscode-extension
3
+ > pnpm run typecheck && node ./scripts/build.mjs
4
+
5
+
6
+ > dql-language-support@1.0.2 typecheck /Users/Kranthi_1/DuckCode-DQL/DQL/dql/apps/vscode-extension
7
+ > tsc -p . --noEmit
8
+
9
+ [dql-vscode-extension] build complete
@@ -14194,15 +14194,19 @@ function formatCall(callName, decorators, query, args, level, state) {
14194
14194
  const lines = [];
14195
14195
  lines.push(...formatDecorators(decorators, level, state));
14196
14196
  lines.push(`${indent(level, state)}${callName}(`);
14197
- const bodyLines = [];
14197
+ const parts = [];
14198
14198
  if (query) {
14199
- bodyLines.push(...formatSQLQuery(query, level + 1, state));
14199
+ parts.push(formatSQLQuery(query, level + 1, state));
14200
14200
  }
14201
- bodyLines.push(...args.map((arg) => `${indent(level + 1, state)}${formatNamedArg(arg)}`));
14202
- if (bodyLines.length > 0) {
14203
- for (let i = 0; i < bodyLines.length; i++) {
14204
- const isLast = i === bodyLines.length - 1;
14205
- lines.push(isLast ? bodyLines[i] : `${bodyLines[i]},`);
14201
+ for (const arg of args) {
14202
+ parts.push([`${indent(level + 1, state)}${formatNamedArg(arg)}`]);
14203
+ }
14204
+ for (let i = 0; i < parts.length; i++) {
14205
+ const isLast = i === parts.length - 1;
14206
+ const chunk = parts[i];
14207
+ for (let j = 0; j < chunk.length; j++) {
14208
+ const lastInChunk = j === chunk.length - 1;
14209
+ lines.push(lastInChunk && !isLast ? `${chunk[j]},` : chunk[j]);
14206
14210
  }
14207
14211
  }
14208
14212
  lines.push(`${indent(level, state)})`);
@@ -14276,9 +14280,17 @@ function formatBlock(node, level, state) {
14276
14280
  return lines.join("\n");
14277
14281
  }
14278
14282
  function formatSQLQuery(query, level, state) {
14279
- const sql = query.rawSQL.trim();
14280
- if (!sql) return [`${indent(level, state)}SELECT 1`];
14281
- return sql.split("\n").map((line) => `${indent(level, state)}${line.trimEnd()}`);
14283
+ const sql = query.rawSQL.replace(/^\n+|\s+$/g, "");
14284
+ if (!sql.trim()) return [`${indent(level, state)}SELECT 1`];
14285
+ const rawLines = sql.split("\n").map((line) => line.trimEnd());
14286
+ const tail = rawLines.slice(1).filter((l) => l.length > 0);
14287
+ const sample = tail.length ? tail : rawLines.filter((l) => l.length > 0);
14288
+ const minLeading = sample.length ? Math.min(...sample.map((l) => l.match(/^[ \t]*/)[0].length)) : 0;
14289
+ return rawLines.map((line) => {
14290
+ if (line.length === 0) return "";
14291
+ const stripped = line.startsWith(" ".repeat(minLeading)) || line.startsWith(" ".repeat(minLeading)) ? line.slice(minLeading) : line.trimStart();
14292
+ return `${indent(level, state)}${stripped}`;
14293
+ });
14282
14294
  }
14283
14295
  function formatNamedArg(arg) {
14284
14296
  return `${arg.name} = ${formatExpression(arg.value)}`;