Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into add-normalize-note-content
Browse files Browse the repository at this point in the history
  • Loading branch information
Huy-DNA committed Mar 11, 2024
2 parents 39d5b88 + 6e9b22b commit 6488c47
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
8 changes: 7 additions & 1 deletion packages/parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# @dbml-experimental/parser

## 1.2.3
## 1.2.4

### Patch Changes

- add a note normalization step for more ui-friendly markdown notes

## 1.2.3

### Patch Changes

- fix catch tables reappearing in multiple tablegroups

## 1.2.2

### Patch Changes
Expand Down
1 change: 1 addition & 0 deletions packages/parser/src/lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export enum CompileErrorCode {
SAME_ENDPOINT,
UNEQUAL_FIELDS_BINARY_REF,
CONFLICTING_SETTING,
TABLE_REAPPEAR_IN_TABLEGROUP,
}

export class CompileError extends Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class TableGroupInterpreter implements ElementInterpreter {
this.env = env;
this.tableGroup = { tables: [] };
}

Check failure on line 20 in packages/parser/src/lib/interpreter/elementInterpreter/tableGroup.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
interpret(): CompileError[] {
const errors: CompileError[] = [];
this.tableGroup.token = getTokenPosition(this.declarationNode);
Expand Down Expand Up @@ -57,13 +57,13 @@ export class TableGroupInterpreter implements ElementInterpreter {
}

const tableid = destructureMemberAccessExpression((field as FunctionApplicationNode).callee!).unwrap().pop()!.referee!.id;
if (this.env.tableOwnerGroup[tableid]) {
const tableGroup = this.env.tableOwnerGroup[tableid];
if (this.env.groupOfTable[tableid]) {
const tableGroup = this.env.groupOfTable[tableid];
const { schemaName, name } = this.env.tableGroups.get(tableGroup)!;
const groupName = schemaName ? `${schemaName}.${name}` : name;
errors.push(new CompileError(CompileErrorCode.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${fragments.join('.')}" already appears in group "${groupName}"`, field));
} else {
this.env.tableOwnerGroup[tableid] = this.declarationNode;
this.env.groupOfTable[tableid] = this.declarationNode;
}

return {
Expand All @@ -74,4 +74,4 @@ export class TableGroupInterpreter implements ElementInterpreter {

return errors;
}
}
}

Check failure on line 77 in packages/parser/src/lib/interpreter/elementInterpreter/tableGroup.ts

View workflow job for this annotation

GitHub Actions / lint

Newline required at end of file but not found
2 changes: 1 addition & 1 deletion packages/parser/src/lib/interpreter/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default class Interpreter {
refIds: { },
ref: new Map(),
enums: new Map(),
tableOwnerGroup: { },
tableGroups: new Map(),
groupOfTable: { },
aliases: [],
project: new Map(),
};
Expand Down
3 changes: 2 additions & 1 deletion packages/parser/src/lib/interpreter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export interface InterpreterDatabase {
refIds: { [refid: string]: ElementDeclarationNode };
ref: Map<ElementDeclarationNode, Ref>;
enums: Map<ElementDeclarationNode, Enum>;
tableOwnerGroup: { [tableid: string]: ElementDeclarationNode };
// for keeping track of the owner table group of a table
groupOfTable: { [tableid: string]: ElementDeclarationNode };
tableGroups: Map<ElementDeclarationNode, TableGroup>;
aliases: Alias[];
project: Map<ElementDeclarationNode, Project>;
Expand Down
4 changes: 3 additions & 1 deletion packages/parser/src/lib/interpreter/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import _ from 'lodash';
import { ColumnSymbol } from '../analyzer/symbol/symbols';
import {
destructureComplexVariableTuple, destructureComplexVariable, destructureMemberAccessExpression, extractVarNameFromPrimaryVariable,
destructureComplexVariable,
destructureComplexVariableTuple,
destructureMemberAccessExpression, extractVarNameFromPrimaryVariable,
} from '../analyzer/utils';
import {
LiteralNode, PrimaryExpressionNode, SyntaxNode, TupleExpressionNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
{
"code": 5005,
"diagnostic": "Table \"users\" already appears in group \"A1\"",
"nodeOrToken": {
"id": 36,
Expand Down Expand Up @@ -168,6 +169,7 @@
"name": "CompileError"
},
{
"code": 5005,
"diagnostic": "Table \"AU\" already appears in group \"A3\"",
"nodeOrToken": {
"id": 53,
Expand Down

0 comments on commit 6488c47

Please sign in to comment.