@domainlang/language 0.7.0 → 0.9.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 (88) hide show
  1. package/out/domain-lang-module.d.ts +2 -0
  2. package/out/domain-lang-module.js +21 -2
  3. package/out/domain-lang-module.js.map +1 -1
  4. package/out/lsp/domain-lang-completion.d.ts +142 -1
  5. package/out/lsp/domain-lang-completion.js +620 -22
  6. package/out/lsp/domain-lang-completion.js.map +1 -1
  7. package/out/lsp/domain-lang-document-symbol-provider.d.ts +79 -0
  8. package/out/lsp/domain-lang-document-symbol-provider.js +210 -0
  9. package/out/lsp/domain-lang-document-symbol-provider.js.map +1 -0
  10. package/out/lsp/domain-lang-index-manager.d.ts +34 -5
  11. package/out/lsp/domain-lang-index-manager.js +66 -27
  12. package/out/lsp/domain-lang-index-manager.js.map +1 -1
  13. package/out/lsp/domain-lang-node-kind-provider.d.ts +27 -0
  14. package/out/lsp/domain-lang-node-kind-provider.js +87 -0
  15. package/out/lsp/domain-lang-node-kind-provider.js.map +1 -0
  16. package/out/lsp/domain-lang-scope-provider.d.ts +53 -20
  17. package/out/lsp/domain-lang-scope-provider.js +119 -44
  18. package/out/lsp/domain-lang-scope-provider.js.map +1 -1
  19. package/out/lsp/domain-lang-workspace-manager.d.ts +23 -2
  20. package/out/lsp/domain-lang-workspace-manager.js +51 -6
  21. package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
  22. package/out/lsp/hover/domain-lang-hover.d.ts +16 -6
  23. package/out/lsp/hover/domain-lang-hover.js +160 -134
  24. package/out/lsp/hover/domain-lang-hover.js.map +1 -1
  25. package/out/lsp/hover/hover-builders.d.ts +57 -0
  26. package/out/lsp/hover/hover-builders.js +171 -0
  27. package/out/lsp/hover/hover-builders.js.map +1 -0
  28. package/out/main.js +2 -1
  29. package/out/main.js.map +1 -1
  30. package/out/sdk/index.d.ts +31 -11
  31. package/out/sdk/index.js +30 -11
  32. package/out/sdk/index.js.map +1 -1
  33. package/out/sdk/loader-node.d.ts +2 -0
  34. package/out/sdk/loader-node.js +3 -1
  35. package/out/sdk/loader-node.js.map +1 -1
  36. package/out/sdk/loader.d.ts +55 -2
  37. package/out/sdk/loader.js +87 -28
  38. package/out/sdk/loader.js.map +1 -1
  39. package/out/sdk/query.js +14 -11
  40. package/out/sdk/query.js.map +1 -1
  41. package/out/sdk/validator.d.ts +134 -0
  42. package/out/sdk/validator.js +249 -0
  43. package/out/sdk/validator.js.map +1 -0
  44. package/out/services/package-boundary-detector.d.ts +101 -0
  45. package/out/services/package-boundary-detector.js +211 -0
  46. package/out/services/package-boundary-detector.js.map +1 -0
  47. package/out/services/performance-optimizer.js +6 -2
  48. package/out/services/performance-optimizer.js.map +1 -1
  49. package/out/services/types.d.ts +24 -0
  50. package/out/services/types.js.map +1 -1
  51. package/out/services/workspace-manager.d.ts +73 -6
  52. package/out/services/workspace-manager.js +210 -57
  53. package/out/services/workspace-manager.js.map +1 -1
  54. package/out/utils/import-utils.d.ts +9 -6
  55. package/out/utils/import-utils.js +26 -15
  56. package/out/utils/import-utils.js.map +1 -1
  57. package/out/validation/constants.d.ts +7 -0
  58. package/out/validation/constants.js +21 -3
  59. package/out/validation/constants.js.map +1 -1
  60. package/out/validation/import.d.ts +11 -1
  61. package/out/validation/import.js +42 -14
  62. package/out/validation/import.js.map +1 -1
  63. package/out/validation/maps.js +50 -1
  64. package/out/validation/maps.js.map +1 -1
  65. package/package.json +8 -9
  66. package/src/domain-lang-module.ts +24 -3
  67. package/src/lsp/domain-lang-completion.ts +736 -27
  68. package/src/lsp/domain-lang-document-symbol-provider.ts +254 -0
  69. package/src/lsp/domain-lang-index-manager.ts +79 -27
  70. package/src/lsp/domain-lang-node-kind-provider.ts +119 -0
  71. package/src/lsp/domain-lang-scope-provider.ts +171 -55
  72. package/src/lsp/domain-lang-workspace-manager.ts +64 -6
  73. package/src/lsp/hover/domain-lang-hover.ts +189 -131
  74. package/src/lsp/hover/hover-builders.ts +208 -0
  75. package/src/main.ts +3 -1
  76. package/src/sdk/index.ts +33 -11
  77. package/src/sdk/loader-node.ts +6 -1
  78. package/src/sdk/loader.ts +125 -34
  79. package/src/sdk/query.ts +15 -11
  80. package/src/sdk/validator.ts +358 -0
  81. package/src/services/package-boundary-detector.ts +238 -0
  82. package/src/services/performance-optimizer.ts +6 -2
  83. package/src/services/types.ts +25 -0
  84. package/src/services/workspace-manager.ts +259 -62
  85. package/src/utils/import-utils.ts +27 -15
  86. package/src/validation/constants.ts +23 -6
  87. package/src/validation/import.ts +49 -14
  88. package/src/validation/maps.ts +59 -2
@@ -7,6 +7,7 @@ import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
7
7
  import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
8
8
  import { ImportResolver } from './services/import-resolver.js';
9
9
  import { WorkspaceManager } from './services/workspace-manager.js';
10
+ import { PackageBoundaryDetector } from './services/package-boundary-detector.js';
10
11
  /**
11
12
  * Declaration of custom services - add your own service classes here.
12
13
  */
@@ -14,6 +15,7 @@ export type DomainLangAddedServices = {
14
15
  imports: {
15
16
  ImportResolver: ImportResolver;
16
17
  WorkspaceManager: WorkspaceManager;
18
+ PackageBoundaryDetector: PackageBoundaryDetector;
17
19
  };
18
20
  references: {
19
21
  QualifiedNameProvider: QualifiedNameProvider;
@@ -9,11 +9,17 @@ import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
9
9
  import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
10
10
  import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
11
11
  import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
12
+ import { DomainLangNodeKindProvider } from './lsp/domain-lang-node-kind-provider.js';
13
+ import { DomainLangDocumentSymbolProvider } from './lsp/domain-lang-document-symbol-provider.js';
12
14
  import { ImportResolver } from './services/import-resolver.js';
13
15
  import { WorkspaceManager } from './services/workspace-manager.js';
16
+ import { PackageBoundaryDetector } from './services/package-boundary-detector.js';
14
17
  import { DomainLangWorkspaceManager } from './lsp/domain-lang-workspace-manager.js';
15
18
  import { DomainLangIndexManager } from './lsp/domain-lang-index-manager.js';
16
19
  const DomainLangSharedModule = {
20
+ lsp: {
21
+ NodeKindProvider: () => new DomainLangNodeKindProvider()
22
+ },
17
23
  workspace: {
18
24
  WorkspaceManager: (services) => new DomainLangWorkspaceManager(services),
19
25
  IndexManager: (services) => new DomainLangIndexManager(services)
@@ -27,7 +33,8 @@ const DomainLangSharedModule = {
27
33
  export const DomainLangModule = {
28
34
  imports: {
29
35
  ImportResolver: (services) => new ImportResolver(services),
30
- WorkspaceManager: () => new WorkspaceManager({ autoResolve: false, allowNetwork: false })
36
+ WorkspaceManager: () => new WorkspaceManager({ autoResolve: false, allowNetwork: false }),
37
+ PackageBoundaryDetector: () => new PackageBoundaryDetector()
31
38
  },
32
39
  references: {
33
40
  ScopeComputation: (services) => new DomainLangScopeComputation(services),
@@ -38,7 +45,8 @@ export const DomainLangModule = {
38
45
  Formatter: () => new DomainLangFormatter(),
39
46
  HoverProvider: (services) => new DomainLangHoverProvider(services),
40
47
  CompletionProvider: (services) => new DomainLangCompletionProvider(services),
41
- CodeActionProvider: () => new DomainLangCodeActionProvider()
48
+ CodeActionProvider: () => new DomainLangCodeActionProvider(),
49
+ DocumentSymbolProvider: (services) => new DomainLangDocumentSymbolProvider(services)
42
50
  },
43
51
  };
44
52
  /**
@@ -61,6 +69,17 @@ export function createDomainLangServices(context) {
61
69
  const DomainLang = inject(createDefaultModule({ shared }), DomainLangGeneratedModule, DomainLangModule);
62
70
  shared.ServiceRegistry.register(DomainLang);
63
71
  registerValidationChecks(DomainLang);
72
+ // Late-bind language services into shared module services.
73
+ // IndexManager and WorkspaceManager are in the shared module (created first),
74
+ // but need access to ImportResolver from the language module (created second).
75
+ const indexManager = shared.workspace.IndexManager;
76
+ if (indexManager instanceof DomainLangIndexManager) {
77
+ indexManager.setLanguageServices(DomainLang);
78
+ }
79
+ const workspaceManager = shared.workspace.WorkspaceManager;
80
+ if (workspaceManager instanceof DomainLangWorkspaceManager) {
81
+ workspaceManager.setLanguageServices(DomainLang);
82
+ }
64
83
  if (!context.connection) {
65
84
  // We don't run inside a language server
66
85
  // Therefore, initialize the configuration provider instantly
@@ -1 +1 @@
1
- {"version":3,"file":"domain-lang-module.js","sourceRoot":"","sources":["../src/domain-lang-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,SAAS,CAAC;AAQ9C,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AA2B5E,MAAM,sBAAsB,GAAgE;IACxF,SAAS,EAAE;QACP,gBAAgB,EAAE,CAAC,QAA+B,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAC,QAAQ,CAAC;QAC/F,YAAY,EAAE,CAAC,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 +6,153 @@
6
6
  * - Grammar-aligned: Completions match grammar structure exactly
7
7
  * - Simple: Uses parent node to determine context
8
8
  * - Maintainable: Clear mapping from grammar to completions
9
+ * - Import-aware: Provides completions for local paths, aliases, and dependencies
9
10
  */
11
+ import type { LangiumDocument } from 'langium';
12
+ import { GrammarAST } from 'langium';
10
13
  import { CompletionAcceptor, CompletionContext, DefaultCompletionProvider, NextFeature } from 'langium/lsp';
14
+ import { CompletionList } from 'vscode-languageserver';
15
+ import type { CancellationToken, CompletionParams } from 'vscode-languageserver-protocol';
16
+ import type { DomainLangServices } from '../domain-lang-module.js';
11
17
  export declare class DomainLangCompletionProvider extends DefaultCompletionProvider {
12
- protected completionFor(context: CompletionContext, next: NextFeature, acceptor: CompletionAcceptor): void;
18
+ private readonly workspaceManager;
19
+ readonly completionOptions: {
20
+ triggerCharacters: string[];
21
+ };
22
+ constructor(services: DomainLangServices);
23
+ /**
24
+ * Override getCompletion to handle import string completions for incomplete strings.
25
+ *
26
+ * **Why this override is necessary:**
27
+ * When the cursor sits inside an incomplete string token (e.g. `import "partial`)
28
+ * Langium's lexer cannot produce a valid STRING token, so `completionFor()` never
29
+ * fires for the `uri` property. This override detects the incomplete-string case
30
+ * via regex and returns completions directly. For all other positions the parent
31
+ * implementation (which routes through `completionFor`) is used.
32
+ */
33
+ getCompletion(document: LangiumDocument, params: CompletionParams, cancelToken?: CancellationToken): Promise<CompletionList | undefined>;
34
+ /**
35
+ * Post-process completion results to replace full-FQN items with segmented items
36
+ * when the cursor is at a dotted path.
37
+ *
38
+ * **Why this is necessary:**
39
+ * Langium's `buildContexts` creates a "data type rule" context that triggers our
40
+ * `completionForCrossReference` override, which correctly produces segmented items.
41
+ * However, when the CST is broken (e.g., partial `Core.B` doesn't fully parse as
42
+ * a QualifiedName), `findDataTypeRuleStart` returns `undefined` and only token-based
43
+ * contexts fire. These contexts have features that are ID terminals (not cross-references),
44
+ * so `completionForCrossReference` is never called. Langium's default pipeline then
45
+ * produces full-FQN items like `Core.Baunwalls.Jannie`.
46
+ *
47
+ * This post-processing step catches those FQN items and segments them,
48
+ * ensuring consistent behavior regardless of parse state.
49
+ */
50
+ private segmentDottedCompletions;
51
+ /** Check if any items are already segmented by our completionForCrossReference. */
52
+ private hasSegmentedItems;
53
+ /** Remove full-FQN items that leaked alongside segmented items. */
54
+ private removeLeakedFqnItems;
55
+ /** Calculate line/character positions from text offsets. */
56
+ private calculateTextPositions;
57
+ /** Transform FQN completion items into segmented (next-segment-only) items. */
58
+ private transformToSegmentedItems;
59
+ /** Transform a single FQN item into a segmented item, or keep non-matching items. */
60
+ private segmentSingleItem;
61
+ /**
62
+ * Check if two dotted names share a common prefix up to the first differing segment.
63
+ */
64
+ private sharesDottedPrefix;
65
+ /**
66
+ * Scan backwards from cursor to find a dotted identifier path.
67
+ * Returns the full typed text and start position, or undefined if no dots found.
68
+ *
69
+ * This is intentionally cursor-based (not tokenOffset-based) to be robust
70
+ * across all Langium completion contexts.
71
+ */
72
+ private extractDottedPathAtCursor;
73
+ /** Walk backwards through `.ID` pairs from the given position. */
74
+ private walkBackThroughDotIdPairs;
75
+ /**
76
+ * Collect import completion items for a given partial input string.
77
+ *
78
+ * Shared by both the `getCompletion` override (incomplete string case)
79
+ * and the `completionFor` path (normal Langium feature-based routing).
80
+ */
81
+ private collectImportItems;
82
+ protected completionFor(context: CompletionContext, next: NextFeature, acceptor: CompletionAcceptor): Promise<void>;
83
+ /**
84
+ * Override cross-reference completion to provide dot-segmented completions.
85
+ *
86
+ * When the user types a dotted prefix (e.g., `Core.`), only the next
87
+ * namespace segment is shown instead of the full qualified name —
88
+ * matching how modern IDEs handle hierarchical completions.
89
+ *
90
+ * Example: Scope contains `Core.CoreDomain`, `Core.BaunWalls.Jannie`, `Core.BaunWalls.Anna`
91
+ * - No dots typed → default FQN labels: `Core.CoreDomain`, `Core.BaunWalls.Jannie`, ...
92
+ * - `Core.` typed → segmented: `CoreDomain`, `BaunWalls`
93
+ * - `Core.BaunWalls.` typed → segmented: `Jannie`, `Anna`
94
+ */
95
+ protected completionForCrossReference(context: CompletionContext, next: NextFeature<GrammarAST.CrossReference>, acceptor: CompletionAcceptor): void | Promise<void>;
96
+ /**
97
+ * Walk backwards from `tokenOffset` through preceding `.ID` pairs
98
+ * to find the start of the full dotted path.
99
+ * QualifiedName = ID ('.' ID)* — Langium tokenises each ID separately.
100
+ */
101
+ private findDottedPathStart;
102
+ /**
103
+ * Iterate scope candidates and emit segmented completion items.
104
+ * Splits FQN candidates by the typed prefix, extracting only the next segment.
105
+ */
106
+ private acceptSegmentedCandidates;
13
107
  private safeCompletionFor;
108
+ /**
109
+ * Detect if we're completing inside an import statement's uri property.
110
+ *
111
+ * This checks:
112
+ * 1. The NextFeature's type and property (when completing STRING for uri)
113
+ * 2. The current AST node (when inside an ImportStatement)
114
+ * 3. Text-based pattern matching (fallback for edge cases)
115
+ */
116
+ private isImportUriCompletion;
117
+ /** Check if the node or any ancestor is an ImportStatement. */
118
+ private isInImportStatementHierarchy;
119
+ /** Check if text before cursor matches an import string pattern. */
120
+ private isImportTextPattern;
121
+ /**
122
+ * Add import completions asynchronously.
123
+ * This method ensures the manifest is loaded before providing completions.
124
+ */
125
+ private addImportCompletions;
126
+ /**
127
+ * Extract the current input inside the import string.
128
+ */
129
+ private extractImportInput;
130
+ /**
131
+ * Add local path starters.
132
+ */
133
+ private addLocalPathStarters;
134
+ /**
135
+ * Add all starter options when input is empty.
136
+ */
137
+ private addAllStarterOptions;
138
+ /**
139
+ * Add alias completions that match the current input.
140
+ */
141
+ private addAliasCompletions;
142
+ /**
143
+ * Add dependency completions that match the current input.
144
+ */
145
+ private addDependencyCompletions;
146
+ /**
147
+ * Add filtered options for partial input that doesn't start with special characters.
148
+ * Shows aliases and dependencies that match the user's partial input.
149
+ */
150
+ private addFilteredOptions;
14
151
  private handleNodeCompletions;
152
+ /**
153
+ * Add import statement snippet at top level.
154
+ */
155
+ private addImportSnippet;
15
156
  private handleContainerCompletions;
16
157
  private addTopLevelSnippets;
17
158
  /**