@dbml/parse 7.1.1 → 8.0.0-alpha.0

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.
Files changed (202) hide show
  1. package/dist/dbml-parse.js +29 -19
  2. package/dist/dbml-parse.mjs +11960 -8292
  3. package/dist/src/compiler/index.d.ts +88 -52
  4. package/dist/src/compiler/projectLayout/index.d.ts +1 -0
  5. package/dist/src/compiler/projectLayout/layout.d.ts +27 -0
  6. package/dist/src/compiler/queries/canonicalName.d.ts +9 -0
  7. package/dist/src/compiler/queries/container/element.d.ts +2 -1
  8. package/dist/src/compiler/queries/container/scope.d.ts +3 -2
  9. package/dist/src/compiler/queries/container/scopeKind.d.ts +2 -1
  10. package/dist/src/compiler/queries/container/stack.d.ts +2 -1
  11. package/dist/src/compiler/queries/container/token.d.ts +2 -1
  12. package/dist/src/compiler/queries/files/fileDependencies.d.ts +3 -0
  13. package/dist/src/compiler/queries/files/reachableFiles.d.ts +3 -0
  14. package/dist/src/compiler/queries/files/usableMembers.d.ts +32 -0
  15. package/dist/src/compiler/queries/legacy/parse.d.ts +10 -9
  16. package/dist/src/compiler/queries/legacy/symbol.d.ts +1 -10
  17. package/dist/src/compiler/queries/legacy/token.d.ts +3 -2
  18. package/dist/src/compiler/queries/nodeAtPosition.d.ts +5 -0
  19. package/dist/src/compiler/queries/pipeline/bind.d.ts +5 -0
  20. package/dist/src/compiler/queries/pipeline/index.d.ts +2 -0
  21. package/dist/src/compiler/queries/pipeline/interpret.d.ts +6 -0
  22. package/dist/src/compiler/queries/pipeline/parse.d.ts +12 -0
  23. package/dist/src/compiler/queries/pipeline/validate.d.ts +4 -0
  24. package/dist/src/compiler/queries/resolutionIndex.d.ts +11 -0
  25. package/dist/src/compiler/queries/symbol/lookupMembers.d.ts +4 -0
  26. package/dist/src/compiler/queries/symbol/symbolAliases.d.ts +4 -0
  27. package/dist/src/compiler/queries/symbol/symbolUses.d.ts +4 -0
  28. package/dist/src/compiler/queries/transform/index.d.ts +1 -1
  29. package/dist/src/compiler/queries/transform/renameTable.d.ts +21 -16
  30. package/dist/src/compiler/queries/transform/syncDiagramView.d.ts +19 -6
  31. package/dist/src/compiler/queries/transform/utils.d.ts +5 -4
  32. package/dist/src/compiler/queries/utils.d.ts +6 -0
  33. package/dist/src/constants.d.ts +1 -2
  34. package/dist/src/core/global_modules/checks/bind.d.ts +9 -0
  35. package/dist/src/core/global_modules/checks/index.d.ts +2 -0
  36. package/dist/src/core/global_modules/checks/interpret.d.ts +10 -0
  37. package/dist/src/core/global_modules/diagramView/bind.d.ts +18 -0
  38. package/dist/src/core/global_modules/diagramView/index.d.ts +8 -0
  39. package/dist/src/core/global_modules/diagramView/interpret.d.ts +37 -0
  40. package/dist/src/core/global_modules/enum/bind.d.ts +11 -0
  41. package/dist/src/core/global_modules/enum/index.d.ts +8 -0
  42. package/dist/src/core/global_modules/enum/interpret.d.ts +15 -0
  43. package/dist/src/core/global_modules/index.d.ts +17 -0
  44. package/dist/src/core/global_modules/indexes/bind.d.ts +12 -0
  45. package/dist/src/core/global_modules/indexes/index.d.ts +2 -0
  46. package/dist/src/core/global_modules/indexes/interpret.d.ts +10 -0
  47. package/dist/src/core/global_modules/note/bind.d.ts +11 -0
  48. package/dist/src/core/global_modules/note/index.d.ts +2 -0
  49. package/dist/src/core/global_modules/note/interpret.d.ts +17 -0
  50. package/dist/src/core/global_modules/program/bind.d.ts +17 -0
  51. package/dist/src/core/global_modules/program/index.d.ts +2 -0
  52. package/dist/src/core/global_modules/program/interpret.d.ts +23 -0
  53. package/dist/src/core/global_modules/program/utils/constraints/fk.d.ts +13 -0
  54. package/dist/src/core/global_modules/program/utils/constraints/helper.d.ts +26 -0
  55. package/dist/src/core/global_modules/program/utils/constraints/pk.d.ts +6 -0
  56. package/dist/src/core/global_modules/program/utils/constraints/unique.d.ts +5 -0
  57. package/dist/src/core/global_modules/program/utils.d.ts +3 -0
  58. package/dist/src/core/global_modules/project/bind.d.ts +11 -0
  59. package/dist/src/core/global_modules/project/index.d.ts +2 -0
  60. package/dist/src/core/global_modules/project/interpret.d.ts +16 -0
  61. package/dist/src/core/global_modules/records/bind.d.ts +17 -0
  62. package/dist/src/core/global_modules/records/index.d.ts +2 -0
  63. package/dist/src/core/global_modules/records/interpret.d.ts +13 -0
  64. package/dist/src/core/{interpreter → global_modules}/records/utils/data/sqlTypes.d.ts +0 -8
  65. package/dist/src/core/{interpreter → global_modules}/records/utils/data/values.d.ts +1 -1
  66. package/dist/src/core/global_modules/records/utils/index.d.ts +1 -0
  67. package/dist/src/core/global_modules/ref/bind.d.ts +15 -0
  68. package/dist/src/core/global_modules/ref/index.d.ts +7 -0
  69. package/dist/src/core/global_modules/ref/interpret.d.ts +15 -0
  70. package/dist/src/core/global_modules/schema/index.d.ts +2 -0
  71. package/dist/src/core/global_modules/table/bind.d.ts +18 -0
  72. package/dist/src/core/global_modules/table/index.d.ts +9 -0
  73. package/dist/src/core/global_modules/table/interpret.d.ts +26 -0
  74. package/dist/src/core/global_modules/table/utils.d.ts +4 -0
  75. package/dist/src/core/global_modules/tableGroup/bind.d.ts +15 -0
  76. package/dist/src/core/global_modules/tableGroup/index.d.ts +8 -0
  77. package/dist/src/core/global_modules/tableGroup/interpret.d.ts +18 -0
  78. package/dist/src/core/global_modules/tablePartial/bind.d.ts +17 -0
  79. package/dist/src/core/global_modules/tablePartial/index.d.ts +7 -0
  80. package/dist/src/core/global_modules/tablePartial/interpret.d.ts +23 -0
  81. package/dist/src/core/global_modules/types.d.ts +17 -0
  82. package/dist/src/core/global_modules/use/index.d.ts +8 -0
  83. package/dist/src/core/global_modules/utils.d.ts +17 -0
  84. package/dist/src/core/local_modules/checks/index.d.ts +2 -0
  85. package/dist/src/core/local_modules/checks/validate.d.ts +17 -0
  86. package/dist/src/core/local_modules/custom/index.d.ts +2 -0
  87. package/dist/src/core/local_modules/custom/validate.d.ts +14 -0
  88. package/dist/src/core/local_modules/diagramView/index.d.ts +2 -0
  89. package/dist/src/core/local_modules/diagramView/validate.d.ts +24 -0
  90. package/dist/src/core/local_modules/enum/index.d.ts +2 -0
  91. package/dist/src/core/local_modules/enum/validate.d.ts +17 -0
  92. package/dist/src/core/local_modules/index.d.ts +10 -0
  93. package/dist/src/core/local_modules/indexes/index.d.ts +2 -0
  94. package/dist/src/core/local_modules/indexes/validate.d.ts +18 -0
  95. package/dist/src/core/local_modules/note/index.d.ts +2 -0
  96. package/dist/src/core/local_modules/note/validate.d.ts +16 -0
  97. package/dist/src/core/local_modules/program/index.d.ts +2 -0
  98. package/dist/src/core/local_modules/program/validate.d.ts +9 -0
  99. package/dist/src/core/local_modules/project/index.d.ts +2 -0
  100. package/dist/src/core/local_modules/project/validate.d.ts +15 -0
  101. package/dist/src/core/local_modules/records/index.d.ts +2 -0
  102. package/dist/src/core/local_modules/records/validate.d.ts +20 -0
  103. package/dist/src/core/local_modules/ref/index.d.ts +2 -0
  104. package/dist/src/core/local_modules/ref/validate.d.ts +20 -0
  105. package/dist/src/core/local_modules/table/index.d.ts +2 -0
  106. package/dist/src/core/local_modules/table/validate.d.ts +21 -0
  107. package/dist/src/core/local_modules/tableGroup/index.d.ts +2 -0
  108. package/dist/src/core/local_modules/tableGroup/validate.d.ts +19 -0
  109. package/dist/src/core/local_modules/tablePartial/index.d.ts +2 -0
  110. package/dist/src/core/local_modules/tablePartial/validate.d.ts +21 -0
  111. package/dist/src/core/local_modules/types.d.ts +12 -0
  112. package/dist/src/core/local_modules/use/index.d.ts +2 -0
  113. package/dist/src/core/local_modules/use/validate.d.ts +12 -0
  114. package/dist/src/core/parser/parser.d.ts +6 -0
  115. package/dist/src/core/parser/utils.d.ts +2 -49
  116. package/dist/src/core/types/errors.d.ts +9 -5
  117. package/dist/src/core/types/filepath.d.ts +8 -2
  118. package/dist/src/core/types/index.d.ts +2 -0
  119. package/dist/src/core/{analyzer/types.d.ts → types/keywords.d.ts} +6 -2
  120. package/dist/src/core/types/module.d.ts +1 -2
  121. package/dist/src/core/types/nodes.d.ts +61 -16
  122. package/dist/src/core/types/report.d.ts +3 -3
  123. package/dist/src/core/types/schemaJson.d.ts +14 -5
  124. package/dist/src/core/types/symbol/factory.d.ts +3 -2
  125. package/dist/src/core/types/symbol/index.d.ts +2 -3
  126. package/dist/src/core/types/symbol/metadata.d.ts +80 -0
  127. package/dist/src/core/types/symbol/symbols.d.ts +277 -86
  128. package/dist/src/core/{analyzer/utils.d.ts → utils/expression.d.ts} +10 -21
  129. package/dist/src/core/utils/interpret.d.ts +16 -0
  130. package/dist/src/core/utils/numbers.d.ts +1 -1
  131. package/dist/src/core/utils/span.d.ts +2 -4
  132. package/dist/src/core/utils/tokens.d.ts +15 -0
  133. package/dist/src/core/utils/validate.d.ts +103 -0
  134. package/dist/src/index.d.ts +13 -9
  135. package/dist/src/services/diagnostics/provider.d.ts +7 -6
  136. package/dist/src/services/index.d.ts +1 -0
  137. package/dist/src/services/monarch.d.ts +3 -2
  138. package/dist/src/services/suggestions/crossFile.d.ts +6 -0
  139. package/dist/src/services/suggestions/provider.d.ts +4 -1
  140. package/dist/src/services/suggestions/recordRowSnippet.d.ts +2 -1
  141. package/dist/src/services/suggestions/use.d.ts +5 -0
  142. package/dist/src/services/suggestions/utils/index.d.ts +10 -0
  143. package/dist/src/services/suggestions/utils/useMerger.d.ts +28 -0
  144. package/dist/src/services/types.d.ts +4 -0
  145. package/dist/src/services/utils.d.ts +4 -1
  146. package/package.json +3 -3
  147. package/dist/src/core/analyzer/analyzer.d.ts +0 -10
  148. package/dist/src/core/analyzer/binder/binder.d.ts +0 -10
  149. package/dist/src/core/analyzer/binder/elementBinder/checks.d.ts +0 -13
  150. package/dist/src/core/analyzer/binder/elementBinder/custom.d.ts +0 -16
  151. package/dist/src/core/analyzer/binder/elementBinder/diagramView.d.ts +0 -20
  152. package/dist/src/core/analyzer/binder/elementBinder/enum.d.ts +0 -16
  153. package/dist/src/core/analyzer/binder/elementBinder/indexes.d.ts +0 -17
  154. package/dist/src/core/analyzer/binder/elementBinder/note.d.ts +0 -16
  155. package/dist/src/core/analyzer/binder/elementBinder/project.d.ts +0 -16
  156. package/dist/src/core/analyzer/binder/elementBinder/records.d.ts +0 -22
  157. package/dist/src/core/analyzer/binder/elementBinder/ref.d.ts +0 -17
  158. package/dist/src/core/analyzer/binder/elementBinder/table.d.ts +0 -21
  159. package/dist/src/core/analyzer/binder/elementBinder/tableGroup.d.ts +0 -17
  160. package/dist/src/core/analyzer/binder/elementBinder/tablePartial.d.ts +0 -19
  161. package/dist/src/core/analyzer/binder/types.d.ts +0 -4
  162. package/dist/src/core/analyzer/binder/utils.d.ts +0 -33
  163. package/dist/src/core/analyzer/validator/elementValidators/checks.d.ts +0 -26
  164. package/dist/src/core/analyzer/validator/elementValidators/custom.d.ts +0 -23
  165. package/dist/src/core/analyzer/validator/elementValidators/diagramView.d.ts +0 -31
  166. package/dist/src/core/analyzer/validator/elementValidators/enum.d.ts +0 -28
  167. package/dist/src/core/analyzer/validator/elementValidators/indexes.d.ts +0 -27
  168. package/dist/src/core/analyzer/validator/elementValidators/note.d.ts +0 -25
  169. package/dist/src/core/analyzer/validator/elementValidators/project.d.ts +0 -24
  170. package/dist/src/core/analyzer/validator/elementValidators/records.d.ts +0 -29
  171. package/dist/src/core/analyzer/validator/elementValidators/ref.d.ts +0 -26
  172. package/dist/src/core/analyzer/validator/elementValidators/table.d.ts +0 -28
  173. package/dist/src/core/analyzer/validator/elementValidators/tableGroup.d.ts +0 -27
  174. package/dist/src/core/analyzer/validator/elementValidators/tablePartial.d.ts +0 -28
  175. package/dist/src/core/analyzer/validator/types.d.ts +0 -7
  176. package/dist/src/core/analyzer/validator/utils.d.ts +0 -65
  177. package/dist/src/core/analyzer/validator/validator.d.ts +0 -10
  178. package/dist/src/core/interpreter/elementInterpreter/diagramView.d.ts +0 -13
  179. package/dist/src/core/interpreter/elementInterpreter/enum.d.ts +0 -12
  180. package/dist/src/core/interpreter/elementInterpreter/project.d.ts +0 -12
  181. package/dist/src/core/interpreter/elementInterpreter/ref.d.ts +0 -14
  182. package/dist/src/core/interpreter/elementInterpreter/sticky_note.d.ts +0 -14
  183. package/dist/src/core/interpreter/elementInterpreter/table.d.ts +0 -22
  184. package/dist/src/core/interpreter/elementInterpreter/tableGroup.d.ts +0 -15
  185. package/dist/src/core/interpreter/elementInterpreter/tablePartial.d.ts +0 -19
  186. package/dist/src/core/interpreter/interpreter.d.ts +0 -10
  187. package/dist/src/core/interpreter/records/index.d.ts +0 -10
  188. package/dist/src/core/interpreter/records/utils/constraints/fk.d.ts +0 -3
  189. package/dist/src/core/interpreter/records/utils/constraints/helper.d.ts +0 -11
  190. package/dist/src/core/interpreter/records/utils/constraints/pk.d.ts +0 -3
  191. package/dist/src/core/interpreter/records/utils/constraints/unique.d.ts +0 -3
  192. package/dist/src/core/interpreter/records/utils/index.d.ts +0 -2
  193. package/dist/src/core/interpreter/types.d.ts +0 -47
  194. package/dist/src/core/interpreter/utils.d.ts +0 -37
  195. package/dist/src/core/types/symbol/symbolIndex.d.ts +0 -33
  196. package/dist/src/core/types/symbol/symbolTable.d.ts +0 -12
  197. package/dist/src/core/types/symbol/utils.d.ts +0 -4
  198. package/dist/src/core/utils/array.d.ts +0 -1
  199. package/dist/src/core/utils/enum.d.ts +0 -1
  200. package/dist/src/services/suggestions/utils.d.ts +0 -34
  201. /package/dist/src/core/{interpreter/records → global_modules/program}/utils/constraints/index.d.ts +0 -0
  202. /package/dist/src/core/{interpreter → global_modules}/records/utils/data/index.d.ts +0 -0
@@ -1,6 +1,7 @@
1
1
  import { default as Compiler } from '../../compiler';
2
+ import { Filepath } from '../../core/types/filepath';
2
3
  import { MarkerData } from '../types';
3
- interface Diagnostic {
4
+ export interface Diagnostic {
4
5
  type: 'error' | 'warning';
5
6
  text: string;
6
7
  startRow: number;
@@ -8,6 +9,7 @@ interface Diagnostic {
8
9
  endRow: number;
9
10
  endColumn: number;
10
11
  code?: string | number;
12
+ filepath: Filepath;
11
13
  }
12
14
  export default class DBMLDiagnosticsProvider {
13
15
  private compiler;
@@ -15,20 +17,19 @@ export default class DBMLDiagnosticsProvider {
15
17
  /**
16
18
  * Get all diagnostics (errors and warnings) from the current compilation
17
19
  */
18
- provideDiagnostics(): Diagnostic[];
20
+ provideDiagnostics(filepath?: Filepath): Diagnostic[];
19
21
  /**
20
22
  * Get only errors from the current compilation
21
23
  */
22
- provideErrors(): Diagnostic[];
24
+ provideErrors(filepath?: Filepath): Diagnostic[];
23
25
  /**
24
26
  * Get only warnings from the current compilation
25
27
  */
26
- provideWarnings(): Diagnostic[];
28
+ provideWarnings(filepath?: Filepath): Diagnostic[];
27
29
  /**
28
30
  * Convert Monaco markers format (for editor integration)
29
31
  */
30
- provideMarkers(): MarkerData[];
32
+ provideMarkers(filepath: Filepath): MarkerData[];
31
33
  private createDiagnostic;
32
34
  private getSeverityValue;
33
35
  }
34
- export {};
@@ -2,6 +2,7 @@ import { default as DBMLDefinitionProvider } from './definition/provider';
2
2
  import { default as DBMLDiagnosticsProvider } from './diagnostics/provider';
3
3
  import { default as DBMLReferencesProvider } from './references/provider';
4
4
  import { default as DBMLCompletionItemProvider } from './suggestions/provider';
5
+ export type { Diagnostic, } from './diagnostics/provider';
5
6
  export * from './types';
6
7
  export { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider, DBMLDiagnosticsProvider, };
7
8
  export { dbmlMonarchTokensProvider, } from './monarch';
@@ -1,3 +1,4 @@
1
- import { languages } from 'monaco-editor-core';
2
- declare const dbmlMonarchTokensProvider: languages.IMonarchLanguage;
1
+ import { LanguageConfiguration, MonarchLanguage } from './types';
2
+ export declare const dbmlLanguageConfig: LanguageConfiguration;
3
+ declare const dbmlMonarchTokensProvider: MonarchLanguage;
3
4
  export { dbmlMonarchTokensProvider, };
@@ -0,0 +1,6 @@
1
+ import { default as Compiler } from '../../compiler/index';
2
+ import { Filepath } from '../../core/types/filepath';
3
+ import { SymbolKind } from '../../core/types/symbol';
4
+ import { CompletionItem } from '../types';
5
+ export declare function collectCrossFileSuggestions(compiler: Compiler, acceptedKinds: SymbolKind[], currentFilepath: Filepath): CompletionItem[];
6
+ export declare function buildCrossFileCompletionItem(compiler: Compiler, symbolName: string, symbolKind: SymbolKind, sourceFilepath: Filepath, currentFilepath: Filepath, currentFileContent: string): CompletionItem;
@@ -1,8 +1,11 @@
1
1
  import { default as Compiler } from '../../compiler';
2
2
  import { CompletionItemProvider, CompletionList, Position, TextModel } from '../types';
3
+ export interface DBMLCompletionItemProviderOptions {
4
+ triggerCharacters?: string[];
5
+ }
3
6
  export default class DBMLCompletionItemProvider implements CompletionItemProvider {
4
7
  private compiler;
5
8
  triggerCharacters: string[];
6
- constructor(compiler: Compiler, triggerCharacters?: string[]);
9
+ constructor(compiler: Compiler, options?: DBMLCompletionItemProviderOptions);
7
10
  provideCompletionItems(model: TextModel, position: Position): CompletionList;
8
11
  }
@@ -1,3 +1,4 @@
1
1
  import { default as Compiler } from '../../compiler';
2
+ import { Filepath } from '../../core/types/filepath';
2
3
  import { CompletionList, Position, TextModel } from '../types';
3
- export declare function suggestRecordRowSnippet(compiler: Compiler, model: TextModel, position: Position, offset: number): CompletionList | null;
4
+ export declare function suggestRecordRowSnippet(compiler: Compiler, model: TextModel, position: Position, filepath: Filepath, offset: number): CompletionList | null;
@@ -0,0 +1,5 @@
1
+ import { default as Compiler } from '../../compiler';
2
+ import { Filepath } from '../../core/types/filepath';
3
+ import { SyntaxToken } from '../../core/types/tokens';
4
+ import { CompletionList, TextModel } from '../types';
5
+ export declare function suggestUseCompletion(compiler: Compiler, filepath: Filepath, offset: number, bOcToken: SyntaxToken | undefined, model: TextModel): CompletionList | null;
@@ -0,0 +1,10 @@
1
+ import { SymbolKind } from '../../../core/types/symbol';
2
+ import { SyntaxToken } from '../../../core/types/tokens';
3
+ import { CompletionItemKind, CompletionList } from '../../types';
4
+ export * from './useMerger';
5
+ export declare function pickCompletionItemKind(symbolKind: SymbolKind): CompletionItemKind;
6
+ export declare function shouldPrependSpace(token: SyntaxToken | undefined, offset: number): boolean;
7
+ export declare function noSuggestions(): CompletionList;
8
+ export declare function prependSpace(completionList: CompletionList): CompletionList;
9
+ export declare function addQuoteToSuggestionIfNeeded(completionList: CompletionList): CompletionList;
10
+ export declare function addSuggestAllSuggestion(completionList: CompletionList, separator?: string): CompletionList;
@@ -0,0 +1,28 @@
1
+ import { default as Compiler } from '../../../compiler';
2
+ import { SymbolKind } from '../../../core/types';
3
+ import { Filepath } from '../../../core/types/filepath';
4
+ import { UseDeclarationNode } from '../../../core/types/nodes';
5
+ export interface ParsedUseSpecifier {
6
+ kind?: string;
7
+ name: string;
8
+ }
9
+ export interface ParsedUseStatement {
10
+ startOffset: number;
11
+ endOffset: number;
12
+ sourceFile: string;
13
+ specifiers: ParsedUseSpecifier[];
14
+ node: UseDeclarationNode;
15
+ }
16
+ export interface UseStatementMergeResult {
17
+ topInsert: string;
18
+ removeRange?: {
19
+ startOffset: number;
20
+ endOffset: number;
21
+ };
22
+ }
23
+ export declare function scanExistingUses(compiler: Compiler, filepath: Filepath, fileContent: string): ParsedUseStatement[];
24
+ /** Merge a new symbol into the file's use statements.
25
+ * If a use from sourceFile exists, add the symbol to it.
26
+ * If not, create a new use statement at the top.
27
+ */
28
+ export declare function mergeSymbolIntoUses(compiler: Compiler, symbolName: string, symbolKind: SymbolKind, sourceFilepath: Filepath, currentFilepath: Filepath, fileContent: string): UseStatementMergeResult;
@@ -1,4 +1,8 @@
1
1
  import { CancellationToken as ICancellationToken, IDisposable, IPosition, IRange, editor, languages } from 'monaco-editor-core';
2
+ import { URI as Uri } from 'monaco-editor-core/esm/vs/base/common/uri.js';
3
+ export { Uri, };
4
+ export type LanguageConfiguration = languages.LanguageConfiguration;
5
+ export type MonarchLanguage = languages.IMonarchLanguage;
2
6
  export type Position = IPosition;
3
7
  export type TextModel = editor.ITextModel;
4
8
  export type ProviderResult<T> = languages.ProviderResult<T>;
@@ -1,2 +1,5 @@
1
- import { Position, TextModel } from './types';
1
+ import { SyntaxNode } from '../core/types/nodes';
2
+ import { SyntaxToken } from '../core/types/tokens';
3
+ import { Position, Range, TextModel } from './types';
2
4
  export declare function getOffsetFromMonacoPosition(model: TextModel, position: Position): number;
5
+ export declare function getEditorRange(model: TextModel, nodeOrToken: SyntaxNode | SyntaxToken): Range;
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": "7.1.1",
4
+ "version": "8.0.0-alpha.0",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -39,11 +39,11 @@
39
39
  "monaco-editor-core": "^0.44.0"
40
40
  },
41
41
  "dependencies": {
42
- "lodash-es": "^4.17.21",
42
+ "lodash-es": "^4.18.1",
43
43
  "luxon": "^3.7.2"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=18"
47
47
  },
48
- "gitHead": "db3691bdada0e754afb76ed4c24c519a80fcddf9"
48
+ "gitHead": "4b99e7eab601b7d53e268d5d80048ee035614a79"
49
49
  }
@@ -1,10 +0,0 @@
1
- import { ProgramNode } from '../types/nodes';
2
- import { default as Report } from '../types/report';
3
- import { NodeSymbolIdGenerator } from '../types/symbol/symbols';
4
- export default class Analyzer {
5
- private ast;
6
- private symbolFactory;
7
- constructor(ast: ProgramNode, symbolIdGenerator: NodeSymbolIdGenerator);
8
- analyze(): Report<ProgramNode>;
9
- validate(): Report<ProgramNode>;
10
- }
@@ -1,10 +0,0 @@
1
- import { ProgramNode } from '../../types/nodes';
2
- import { default as Report } from '../../types/report';
3
- import { default as SymbolFactory } from '../../types/symbol/factory';
4
- export default class Binder {
5
- private ast;
6
- private symbolFactory;
7
- constructor(ast: ProgramNode, symbolFactory: SymbolFactory);
8
- private resolvePartialInjections;
9
- resolve(): Report<ProgramNode>;
10
- }
@@ -1,13 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode, SyntaxToken } from '../../../..';
4
- import { ElementBinder } from '../types';
5
- export default class ChecksBinder implements ElementBinder {
6
- private symbolFactory;
7
- private declarationNode;
8
- private ast;
9
- constructor(declarationNode: ElementDeclarationNode & {
10
- type: SyntaxToken;
11
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
12
- bind(): CompileError[];
13
- }
@@ -1,16 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class CustomBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindSubElements;
16
- }
@@ -1,20 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class DiagramViewBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindSubElements;
16
- private bindTableReferences;
17
- private bindNoteReferences;
18
- private bindTableGroupReferences;
19
- private bindSchemaReferences;
20
- }
@@ -1,16 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class EnumBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindSubElements;
16
- }
@@ -1,17 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class IndexesBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindFields;
16
- private bindSubElements;
17
- }
@@ -1,16 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class NoteBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindSubElements;
16
- }
@@ -1,16 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class ProjectBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindSubElements;
16
- }
@@ -1,22 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class RecordsBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- private boundColumns;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
14
- bind(): CompileError[];
15
- private bindRecordsName;
16
- private bindTopLevelName;
17
- private bindInsideTableName;
18
- private bindBody;
19
- private bindDataRows;
20
- private bindDataRow;
21
- private bindSubElements;
22
- }
@@ -1,17 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class RefBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindFields;
16
- private bindSubElements;
17
- }
@@ -1,21 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class TableBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- resolvePartialInjections(): CompileError[];
15
- private bindBody;
16
- private bindFields;
17
- private tryToBindColumnType;
18
- private tryToBindEnumFieldRef;
19
- private bindInlineRef;
20
- private bindSubElements;
21
- }
@@ -1,17 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class TableGroupBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindFields;
16
- private bindSubElements;
17
- }
@@ -1,19 +0,0 @@
1
- import { CompileError } from '../../../types/errors';
2
- import { default as SymbolFactory } from '../../../types/symbol/factory';
3
- import { ElementDeclarationNode, ProgramNode } from '../../../types/nodes';
4
- import { SyntaxToken } from '../../../types/tokens';
5
- import { ElementBinder } from '../types';
6
- export default class TablePartialBinder implements ElementBinder {
7
- private symbolFactory;
8
- private declarationNode;
9
- private ast;
10
- constructor(declarationNode: ElementDeclarationNode & {
11
- type: SyntaxToken;
12
- }, ast: ProgramNode, symbolFactory: SymbolFactory);
13
- bind(): CompileError[];
14
- private bindBody;
15
- private bindFields;
16
- private tryToBindColumnType;
17
- private bindInlineRef;
18
- private bindSubElements;
19
- }
@@ -1,4 +0,0 @@
1
- import { CompileError } from '../../types/errors';
2
- export interface ElementBinder {
3
- bind(): CompileError[];
4
- }
@@ -1,33 +0,0 @@
1
- import { CompileError } from '../../types/errors';
2
- import { ElementDeclarationNode, PrimaryExpressionNode, ProgramNode, SyntaxNode, VariableNode } from '../../types/nodes';
3
- import { SymbolKind } from '../../types/symbol';
4
- import { SyntaxToken } from '../../types/tokens';
5
- import { default as ChecksBinder } from './elementBinder/checks';
6
- import { default as CustomBinder } from './elementBinder/custom';
7
- import { default as DiagramViewBinder } from './elementBinder/diagramView';
8
- import { default as EnumBinder } from './elementBinder/enum';
9
- import { default as IndexesBinder } from './elementBinder/indexes';
10
- import { default as NoteBinder } from './elementBinder/note';
11
- import { default as ProjectBinder } from './elementBinder/project';
12
- import { default as RecordsBinder } from './elementBinder/records';
13
- import { default as RefBinder } from './elementBinder/ref';
14
- import { default as TableBinder } from './elementBinder/table';
15
- import { default as TableGroupBinder } from './elementBinder/tableGroup';
16
- import { default as TablePartialBinder } from './elementBinder/tablePartial';
17
- export declare function pickBinder(element: ElementDeclarationNode & {
18
- type: SyntaxToken;
19
- }): typeof ChecksBinder | typeof CustomBinder | typeof EnumBinder | typeof TableBinder | typeof TableGroupBinder | typeof ProjectBinder | typeof RefBinder | typeof NoteBinder | typeof IndexesBinder | typeof TablePartialBinder | typeof RecordsBinder | typeof DiagramViewBinder;
20
- export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
21
- variables: (PrimaryExpressionNode & {
22
- expression: VariableNode;
23
- })[];
24
- tupleElements: (PrimaryExpressionNode & {
25
- expression: VariableNode;
26
- })[];
27
- }[];
28
- export declare function lookupAndBindInScope(initialScope: ElementDeclarationNode | ProgramNode, symbolInfos: {
29
- node: PrimaryExpressionNode & {
30
- expression: VariableNode;
31
- };
32
- kind: SymbolKind;
33
- }[]): CompileError[];
@@ -1,26 +0,0 @@
1
- import { ElementValidator } from '../types';
2
- import { CompileError, CompileWarning } from '../../../types/errors';
3
- import { ElementDeclarationNode } from '../../../types/nodes';
4
- import { default as SymbolFactory } from '../../../types/symbol/factory';
5
- import { default as SymbolTable } from '../../../types/symbol/symbolTable';
6
- import { SyntaxToken } from '../../../types/tokens';
7
- export default class ChecksValidator implements ElementValidator {
8
- private declarationNode;
9
- private publicSymbolTable;
10
- private symbolFactory;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
14
- validate(): {
15
- errors: CompileError[];
16
- warnings: CompileWarning[];
17
- };
18
- private validateContext;
19
- private validateName;
20
- private validateAlias;
21
- private validateSettingList;
22
- private validateBody;
23
- private validateFields;
24
- private validateFieldSetting;
25
- private validateSubElements;
26
- }
@@ -1,23 +0,0 @@
1
- import { ElementValidator } from '../types';
2
- import { CompileError, CompileWarning } from '../../../types/errors';
3
- import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode } from '../../../types/nodes';
4
- import { default as SymbolFactory } from '../../../types/symbol/factory';
5
- import { default as SymbolTable } from '../../../types/symbol/symbolTable';
6
- import { SyntaxToken } from '../../../types/tokens';
7
- export default class CustomValidator implements ElementValidator {
8
- private declarationNode;
9
- private publicSymbolTable;
10
- private symbolFactory;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
14
- validate(): {
15
- errors: CompileError[];
16
- warnings: CompileWarning[];
17
- };
18
- private validateContext;
19
- private validateName;
20
- private validateAlias;
21
- private validateSettingList;
22
- validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
23
- }
@@ -1,31 +0,0 @@
1
- import { ElementValidator } from '../types';
2
- import { CompileError, CompileWarning } from '../../../types/errors';
3
- import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode } from '../../../types/nodes';
4
- import { default as SymbolFactory } from '../../../types/symbol/factory';
5
- import { default as SymbolTable } from '../../../types/symbol/symbolTable';
6
- import { SyntaxToken } from '../../../types/tokens';
7
- export default class DiagramViewValidator implements ElementValidator {
8
- private declarationNode;
9
- private publicSymbolTable;
10
- private symbolFactory;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
14
- validate(): {
15
- errors: CompileError[];
16
- warnings: CompileWarning[];
17
- };
18
- private validateContext;
19
- private validateName;
20
- private validateAlias;
21
- registerElement(): CompileError[];
22
- private validateSettingList;
23
- validateBody(body?: FunctionApplicationNode | BlockExpressionNode): {
24
- errors: CompileError[];
25
- warnings: CompileWarning[];
26
- };
27
- validateFields(fields: FunctionApplicationNode[]): CompileError[];
28
- private validateSubElements;
29
- private validateSubBlock;
30
- registerSubBlockFields(sub: ElementDeclarationNode): CompileError[];
31
- }
@@ -1,28 +0,0 @@
1
- import { ElementValidator } from '../types';
2
- import { CompileError, CompileWarning } from '../../../types/errors';
3
- import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode, ListExpressionNode } from '../../../types/nodes';
4
- import { default as SymbolFactory } from '../../../types/symbol/factory';
5
- import { default as SymbolTable } from '../../../types/symbol/symbolTable';
6
- import { SyntaxToken } from '../../../types/tokens';
7
- export default class EnumValidator implements ElementValidator {
8
- private declarationNode;
9
- private publicSymbolTable;
10
- private symbolFactory;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
14
- validate(): {
15
- errors: CompileError[];
16
- warnings: CompileWarning[];
17
- };
18
- private validateContext;
19
- private validateName;
20
- private validateAlias;
21
- registerElement(): CompileError[];
22
- private validateSettingList;
23
- validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
24
- validateFields(fields: FunctionApplicationNode[]): CompileError[];
25
- validateFieldSettings(settings: ListExpressionNode): CompileError[];
26
- private validateSubElements;
27
- registerField(field: FunctionApplicationNode): CompileError[];
28
- }
@@ -1,27 +0,0 @@
1
- import { ElementValidator } from '../types';
2
- import { CompileError, CompileWarning } from '../../../types/errors';
3
- import { ElementDeclarationNode, SyntaxNode } from '../../../types/nodes';
4
- import { default as SymbolFactory } from '../../../types/symbol/factory';
5
- import { default as SymbolTable } from '../../../types/symbol/symbolTable';
6
- import { SyntaxToken } from '../../../types/tokens';
7
- export default class IndexesValidator implements ElementValidator {
8
- private declarationNode;
9
- private publicSymbolTable;
10
- private symbolFactory;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
14
- validate(): {
15
- errors: CompileError[];
16
- warnings: CompileWarning[];
17
- };
18
- private validateContext;
19
- private validateName;
20
- private validateAlias;
21
- private validateSettingList;
22
- private validateBody;
23
- private validateFields;
24
- private validateFieldSetting;
25
- private validateSubElements;
26
- }
27
- export declare function isValidIndexesType(value?: SyntaxNode): boolean;
@@ -1,25 +0,0 @@
1
- import { ElementValidator } from '../types';
2
- import { CompileError, CompileWarning } from '../../../types/errors';
3
- import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode } from '../../../types/nodes';
4
- import { default as SymbolFactory } from '../../../types/symbol/factory';
5
- import { default as SymbolTable } from '../../../types/symbol/symbolTable';
6
- import { SyntaxToken } from '../../../types/tokens';
7
- export default class NoteValidator implements ElementValidator {
8
- private declarationNode;
9
- private publicSymbolTable;
10
- private symbolFactory;
11
- constructor(declarationNode: ElementDeclarationNode & {
12
- type: SyntaxToken;
13
- }, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
14
- validate(): {
15
- errors: CompileError[];
16
- warnings: CompileWarning[];
17
- };
18
- private validateContext;
19
- private validateName;
20
- private validateAlias;
21
- private validateSettingList;
22
- validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
23
- validateFields(fields: FunctionApplicationNode[]): CompileError[];
24
- private validateSubElements;
25
- }