@dbml/parse 8.2.2 → 8.2.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.
@@ -1249,8 +1249,8 @@ var isAbsolute = function(r) {
1249
1249
  return r.path.startsWith(j);
1250
1250
  }
1251
1251
  toUri(r = {}) {
1252
- let j = r.protocol ?? this.protocol;
1253
- if (j === void 0) return this.path;
1252
+ let j = r.protocol || this.protocol;
1253
+ if (!j) return this.path;
1254
1254
  let M = WIN_DRIVE_RE.test(this.path) ? `${j}:///` : `${j}://`;
1255
1255
  return new URL(M + this.path).href;
1256
1256
  }
@@ -3169,7 +3169,10 @@ var IndexesBinder = class {
3169
3169
  this.compiler = r, this.declarationNode = j;
3170
3170
  }
3171
3171
  bind() {
3172
- return !(this.declarationNode.parent instanceof ElementDeclarationNode) || !this.declarationNode.parent.isKind(ElementKind.Table) || !(this.declarationNode.body instanceof BlockExpressionNode) ? [] : this.bindBody(this.declarationNode.body);
3172
+ return !(this.declarationNode.parent instanceof ElementDeclarationNode) || !this.declarationNode.parent.isKind(ElementKind.Table) && !this.declarationNode.parent.isKind(ElementKind.TablePartial) || !(this.declarationNode.body instanceof BlockExpressionNode) ? [] : this.bindBody(this.declarationNode.body);
3173
+ }
3174
+ get ownerContainerKind() {
3175
+ return this.declarationNode.parent.isKind(ElementKind.TablePartial) ? "TablePartial" : "Table";
3173
3176
  }
3174
3177
  bindBody(r) {
3175
3178
  if (!r) return [];
@@ -3181,11 +3184,11 @@ var IndexesBinder = class {
3181
3184
  return r.flatMap((r) => {
3182
3185
  if (!r.callee) return [];
3183
3186
  let M = destructureComplexVariable(this.declarationNode.parent.name)?.join(".") ?? "<unnamed>";
3184
- return [r.callee, ...r.args].flatMap(scanNonListNodeForBinding).flatMap((r) => r.variables.length + r.tupleElements.length > 1 ? [] : r.variables.length ? r.variables[0] : r.tupleElements).flatMap((r) => {
3187
+ return [r.callee, ...r.args].flatMap(scanNonListNodeForBinding).flatMap((r) => r.variables.length > 1 ? [] : r.variables.length ? r.variables[0] : r.tupleElements).flatMap((r) => {
3185
3188
  let N = extractVarNameFromPrimaryVariable(r);
3186
3189
  if (N === void 0) return [];
3187
3190
  let P = this.compiler.nodeReferee(r);
3188
- return !P.getValue() || P.hasValue(UNHANDLED) ? new CompileError(CompileErrorCode.BINDING_ERROR, `No column named '${N}' inside Table '${M}'`, r) : [];
3191
+ return !P.getValue() || P.hasValue(UNHANDLED) ? new CompileError(CompileErrorCode.BINDING_ERROR, `No column named '${N}' inside ${this.ownerContainerKind} '${M}'`, r) : [];
3189
3192
  });
3190
3193
  });
3191
3194
  }
@@ -11964,7 +11967,7 @@ var DBMLDefinitionProvider = class {
11964
11967
  let P;
11965
11968
  if (M.declaration && [SyntaxNodeKind.PRIMARY_EXPRESSION, SyntaxNodeKind.VARIABLE].includes(r.kind) && ({declaration: P} = M), P) {
11966
11969
  let { startPos: r, endPos: j } = P, M = N;
11967
- return N && P.filepath && (M = URI.parse(P.filepath.toUri())), [{
11970
+ return N && P.filepath && (M = URI.parse(P.filepath.toUri({ protocol: N.scheme }))), [{
11968
11971
  range: {
11969
11972
  startColumn: r.column + 1,
11970
11973
  startLineNumber: r.line + 1,
@@ -12035,7 +12038,7 @@ var DBMLDefinitionProvider = class {
12035
12038
  let M = this.compiler.nodeSymbol(r).getFiltered(UNHANDLED) ?? this.compiler.nodeReferee(r).getFiltered(UNHANDLED), P = M ? this.compiler.symbolReferences(M) : void 0;
12036
12039
  if (P && P.length > 0) return P.map((r) => {
12037
12040
  let j = N;
12038
- return N && r.filepath && (j = URI.parse(r.filepath.toUri())), {
12041
+ return N && r.filepath && (j = URI.parse(r.filepath.toUri({ protocol: N.scheme }))), {
12039
12042
  range: {
12040
12043
  startColumn: r.startPos.column + 1,
12041
12044
  startLineNumber: r.startPos.line + 1,
@@ -13798,12 +13801,6 @@ var ParsingContextStack = class {
13798
13801
  if (this.check(SyntaxTokenKind.RBRACE) || this.check(SyntaxTokenKind.STRING_LITERAL) || this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(r) || isAtStartOfLine(this.previous(), r)) break;
13799
13802
  markInvalid(r), this.advance();
13800
13803
  }
13801
- }, this.synchronizeUseSpecifier = () => {
13802
- for (; !this.isAtEnd();) {
13803
- let r = this.peek();
13804
- if (this.check(SyntaxTokenKind.RBRACE) || isAtStartOfLine(this.previous(), r)) break;
13805
- markInvalid(r), this.advance();
13806
- }
13807
13804
  }, this.synchronizeProgram = () => {
13808
13805
  let r = this.peek();
13809
13806
  r.kind === SyntaxTokenKind.EOF ? this.logError(r, CompileErrorCode.UNEXPECTED_EOF, "Unexpected EOF") : markInvalid(this.advance());
@@ -14038,16 +14035,12 @@ var ParsingContextStack = class {
14038
14035
  try {
14039
14036
  this.consume("Expect an import kind specifier (e.g. table, enum)", SyntaxTokenKind.IDENTIFIER), r.importKind = this.previous();
14040
14037
  } catch (r) {
14041
- if (!(r instanceof PartialParsingError)) throw r;
14042
- if (!this.canHandle(r)) throw new PartialParsingError(r.token, j(), r.handlerContext);
14043
- this.synchronizeUseSpecifier();
14038
+ throw r instanceof PartialParsingError ? new PartialParsingError(r.token, j(), r.handlerContext) : r;
14044
14039
  }
14045
14040
  if (this.check(SyntaxTokenKind.IDENTIFIER, SyntaxTokenKind.QUOTED_STRING)) try {
14046
14041
  r.name = this.normalExpression();
14047
14042
  } catch (M) {
14048
- if (!(M instanceof PartialParsingError)) throw M;
14049
- if (M.partialNode instanceof SyntaxNode && (r.name = M.partialNode), !this.canHandle(M)) throw new PartialParsingError(M.token, j(), M.handlerContext);
14050
- this.synchronizeUseSpecifier();
14043
+ throw M instanceof PartialParsingError ? (M.partialNode instanceof SyntaxNode && (r.name = M.partialNode), new PartialParsingError(M.token, j(), M.handlerContext)) : M;
14051
14044
  }
14052
14045
  else r.importKind && this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an element name");
14053
14046
  if (isAsKeyword(this.peek())) {
@@ -14058,7 +14051,6 @@ var ParsingContextStack = class {
14058
14051
  } catch (r) {
14059
14052
  if (!(r instanceof PartialParsingError)) throw r;
14060
14053
  if (!this.canHandle(r)) throw new PartialParsingError(r.token, j(), r.handlerContext);
14061
- this.synchronizeUseSpecifier();
14062
14054
  }
14063
14055
  }
14064
14056
  return j();
@@ -6,6 +6,7 @@ export default class IndexesBinder {
6
6
  private declarationNode;
7
7
  constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
8
8
  bind(): CompileError[];
9
+ private get ownerContainerKind();
9
10
  private bindBody;
10
11
  private bindFields;
11
12
  private bindSubElements;
@@ -31,7 +31,6 @@ export default class Parser {
31
31
  private useSpecifierList;
32
32
  private synchronizeUseSpecifierList;
33
33
  private useSpecifier;
34
- private synchronizeUseSpecifier;
35
34
  private synchronizeProgram;
36
35
  private elementDeclaration;
37
36
  private synchronizeElementDeclarationName;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/parse",
4
- "version": "8.2.2",
4
+ "version": "8.2.4",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=18"
48
48
  },
49
- "gitHead": "34294e84c8a6acd1508c2d0442a8a93a12c79126"
49
+ "gitHead": "a8358e7ca39ab47272ee59a1915709d8f0f82f06"
50
50
  }