@rejot-dev/thalo 0.0.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.
- package/LICENSE +21 -0
- package/README.md +396 -0
- package/dist/ast/ast-types.d.ts +469 -0
- package/dist/ast/ast-types.d.ts.map +1 -0
- package/dist/ast/ast-types.js +11 -0
- package/dist/ast/ast-types.js.map +1 -0
- package/dist/ast/builder.js +158 -0
- package/dist/ast/builder.js.map +1 -0
- package/dist/ast/extract.js +748 -0
- package/dist/ast/extract.js.map +1 -0
- package/dist/ast/node-at-position.d.ts +147 -0
- package/dist/ast/node-at-position.d.ts.map +1 -0
- package/dist/ast/node-at-position.js +382 -0
- package/dist/ast/node-at-position.js.map +1 -0
- package/dist/ast/visitor.js +232 -0
- package/dist/ast/visitor.js.map +1 -0
- package/dist/checker/check.d.ts +53 -0
- package/dist/checker/check.d.ts.map +1 -0
- package/dist/checker/check.js +105 -0
- package/dist/checker/check.js.map +1 -0
- package/dist/checker/rules/actualize-missing-updated.js +34 -0
- package/dist/checker/rules/actualize-missing-updated.js.map +1 -0
- package/dist/checker/rules/actualize-unresolved-target.js +42 -0
- package/dist/checker/rules/actualize-unresolved-target.js.map +1 -0
- package/dist/checker/rules/alter-before-define.js +53 -0
- package/dist/checker/rules/alter-before-define.js.map +1 -0
- package/dist/checker/rules/alter-undefined-entity.js +32 -0
- package/dist/checker/rules/alter-undefined-entity.js.map +1 -0
- package/dist/checker/rules/create-requires-section.js +34 -0
- package/dist/checker/rules/create-requires-section.js.map +1 -0
- package/dist/checker/rules/define-entity-requires-section.js +31 -0
- package/dist/checker/rules/define-entity-requires-section.js.map +1 -0
- package/dist/checker/rules/duplicate-entity-definition.js +37 -0
- package/dist/checker/rules/duplicate-entity-definition.js.map +1 -0
- package/dist/checker/rules/duplicate-field-in-schema.js +38 -0
- package/dist/checker/rules/duplicate-field-in-schema.js.map +1 -0
- package/dist/checker/rules/duplicate-link-id.js +52 -0
- package/dist/checker/rules/duplicate-link-id.js.map +1 -0
- package/dist/checker/rules/duplicate-metadata-key.js +21 -0
- package/dist/checker/rules/duplicate-metadata-key.js.map +1 -0
- package/dist/checker/rules/duplicate-section-heading.js +41 -0
- package/dist/checker/rules/duplicate-section-heading.js.map +1 -0
- package/dist/checker/rules/duplicate-section-in-schema.js +38 -0
- package/dist/checker/rules/duplicate-section-in-schema.js.map +1 -0
- package/dist/checker/rules/duplicate-timestamp.js +104 -0
- package/dist/checker/rules/duplicate-timestamp.js.map +1 -0
- package/dist/checker/rules/empty-required-value.js +45 -0
- package/dist/checker/rules/empty-required-value.js.map +1 -0
- package/dist/checker/rules/empty-section.js +21 -0
- package/dist/checker/rules/empty-section.js.map +1 -0
- package/dist/checker/rules/invalid-date-range-value.js +56 -0
- package/dist/checker/rules/invalid-date-range-value.js.map +1 -0
- package/dist/checker/rules/invalid-default-value.js +86 -0
- package/dist/checker/rules/invalid-default-value.js.map +1 -0
- package/dist/checker/rules/invalid-field-type.js +45 -0
- package/dist/checker/rules/invalid-field-type.js.map +1 -0
- package/dist/checker/rules/missing-required-field.js +48 -0
- package/dist/checker/rules/missing-required-field.js.map +1 -0
- package/dist/checker/rules/missing-required-section.js +51 -0
- package/dist/checker/rules/missing-required-section.js.map +1 -0
- package/dist/checker/rules/missing-title.js +56 -0
- package/dist/checker/rules/missing-title.js.map +1 -0
- package/dist/checker/rules/remove-undefined-field.js +42 -0
- package/dist/checker/rules/remove-undefined-field.js.map +1 -0
- package/dist/checker/rules/remove-undefined-section.js +42 -0
- package/dist/checker/rules/remove-undefined-section.js.map +1 -0
- package/dist/checker/rules/rules.d.ts +71 -0
- package/dist/checker/rules/rules.d.ts.map +1 -0
- package/dist/checker/rules/rules.js +102 -0
- package/dist/checker/rules/rules.js.map +1 -0
- package/dist/checker/rules/synthesis-empty-query.js +35 -0
- package/dist/checker/rules/synthesis-empty-query.js.map +1 -0
- package/dist/checker/rules/synthesis-missing-prompt.js +42 -0
- package/dist/checker/rules/synthesis-missing-prompt.js.map +1 -0
- package/dist/checker/rules/synthesis-missing-sources.js +32 -0
- package/dist/checker/rules/synthesis-missing-sources.js.map +1 -0
- package/dist/checker/rules/synthesis-unknown-query-entity.js +39 -0
- package/dist/checker/rules/synthesis-unknown-query-entity.js.map +1 -0
- package/dist/checker/rules/timestamp-out-of-order.js +55 -0
- package/dist/checker/rules/timestamp-out-of-order.js.map +1 -0
- package/dist/checker/rules/unknown-entity.js +32 -0
- package/dist/checker/rules/unknown-entity.js.map +1 -0
- package/dist/checker/rules/unknown-field.js +40 -0
- package/dist/checker/rules/unknown-field.js.map +1 -0
- package/dist/checker/rules/unknown-section.js +47 -0
- package/dist/checker/rules/unknown-section.js.map +1 -0
- package/dist/checker/rules/unresolved-link.js +34 -0
- package/dist/checker/rules/unresolved-link.js.map +1 -0
- package/dist/checker/rules/update-without-create.js +65 -0
- package/dist/checker/rules/update-without-create.js.map +1 -0
- package/dist/checker/visitor.d.ts +69 -0
- package/dist/checker/visitor.d.ts.map +1 -0
- package/dist/checker/visitor.js +67 -0
- package/dist/checker/visitor.js.map +1 -0
- package/dist/checker/workspace-index.d.ts +50 -0
- package/dist/checker/workspace-index.d.ts.map +1 -0
- package/dist/checker/workspace-index.js +108 -0
- package/dist/checker/workspace-index.js.map +1 -0
- package/dist/commands/actualize.d.ts +113 -0
- package/dist/commands/actualize.d.ts.map +1 -0
- package/dist/commands/actualize.js +111 -0
- package/dist/commands/actualize.js.map +1 -0
- package/dist/commands/check.d.ts +65 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +61 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/format.d.ts +90 -0
- package/dist/commands/format.d.ts.map +1 -0
- package/dist/commands/format.js +80 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/query.d.ts +152 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +151 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/constants.d.ts +31 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +51 -0
- package/dist/constants.js.map +1 -0
- package/dist/files.d.ts +58 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +103 -0
- package/dist/files.js.map +1 -0
- package/dist/formatters.d.ts +39 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +200 -0
- package/dist/formatters.js.map +1 -0
- package/dist/fragment.d.ts +22 -0
- package/dist/fragment.d.ts.map +1 -0
- package/dist/git/git.js +240 -0
- package/dist/git/git.js.map +1 -0
- package/dist/merge/conflict-detector.d.ts +89 -0
- package/dist/merge/conflict-detector.d.ts.map +1 -0
- package/dist/merge/conflict-detector.js +352 -0
- package/dist/merge/conflict-detector.js.map +1 -0
- package/dist/merge/conflict-formatter.js +143 -0
- package/dist/merge/conflict-formatter.js.map +1 -0
- package/dist/merge/driver.d.ts +54 -0
- package/dist/merge/driver.d.ts.map +1 -0
- package/dist/merge/driver.js +112 -0
- package/dist/merge/driver.js.map +1 -0
- package/dist/merge/entry-matcher.d.ts +50 -0
- package/dist/merge/entry-matcher.d.ts.map +1 -0
- package/dist/merge/entry-matcher.js +141 -0
- package/dist/merge/entry-matcher.js.map +1 -0
- package/dist/merge/entry-merger.js +194 -0
- package/dist/merge/entry-merger.js.map +1 -0
- package/dist/merge/merge-result-builder.d.ts +62 -0
- package/dist/merge/merge-result-builder.d.ts.map +1 -0
- package/dist/merge/merge-result-builder.js +89 -0
- package/dist/merge/merge-result-builder.js.map +1 -0
- package/dist/mod.d.ts +31 -0
- package/dist/mod.js +23 -0
- package/dist/model/document.d.ts +134 -0
- package/dist/model/document.d.ts.map +1 -0
- package/dist/model/document.js +275 -0
- package/dist/model/document.js.map +1 -0
- package/dist/model/line-index.d.ts +85 -0
- package/dist/model/line-index.d.ts.map +1 -0
- package/dist/model/line-index.js +159 -0
- package/dist/model/line-index.js.map +1 -0
- package/dist/model/workspace.d.ts +296 -0
- package/dist/model/workspace.d.ts.map +1 -0
- package/dist/model/workspace.js +562 -0
- package/dist/model/workspace.js.map +1 -0
- package/dist/parser.js +27 -0
- package/dist/parser.js.map +1 -0
- package/dist/parser.native.d.ts +51 -0
- package/dist/parser.native.d.ts.map +1 -0
- package/dist/parser.native.js +62 -0
- package/dist/parser.native.js.map +1 -0
- package/dist/parser.shared.d.ts +99 -0
- package/dist/parser.shared.d.ts.map +1 -0
- package/dist/parser.shared.js +124 -0
- package/dist/parser.shared.js.map +1 -0
- package/dist/parser.web.d.ts +67 -0
- package/dist/parser.web.d.ts.map +1 -0
- package/dist/parser.web.js +49 -0
- package/dist/parser.web.js.map +1 -0
- package/dist/schema/registry.d.ts +108 -0
- package/dist/schema/registry.d.ts.map +1 -0
- package/dist/schema/registry.js +281 -0
- package/dist/schema/registry.js.map +1 -0
- package/dist/semantic/analyzer.d.ts +107 -0
- package/dist/semantic/analyzer.d.ts.map +1 -0
- package/dist/semantic/analyzer.js +261 -0
- package/dist/semantic/analyzer.js.map +1 -0
- package/dist/services/change-tracker/change-tracker.d.ts +111 -0
- package/dist/services/change-tracker/change-tracker.d.ts.map +1 -0
- package/dist/services/change-tracker/change-tracker.js +62 -0
- package/dist/services/change-tracker/change-tracker.js.map +1 -0
- package/dist/services/change-tracker/create-tracker.d.ts +42 -0
- package/dist/services/change-tracker/create-tracker.d.ts.map +1 -0
- package/dist/services/change-tracker/create-tracker.js +53 -0
- package/dist/services/change-tracker/create-tracker.js.map +1 -0
- package/dist/services/change-tracker/git-tracker.d.ts +59 -0
- package/dist/services/change-tracker/git-tracker.d.ts.map +1 -0
- package/dist/services/change-tracker/git-tracker.js +218 -0
- package/dist/services/change-tracker/git-tracker.js.map +1 -0
- package/dist/services/change-tracker/timestamp-tracker.d.ts +22 -0
- package/dist/services/change-tracker/timestamp-tracker.d.ts.map +1 -0
- package/dist/services/change-tracker/timestamp-tracker.js +74 -0
- package/dist/services/change-tracker/timestamp-tracker.js.map +1 -0
- package/dist/services/definition.d.ts +37 -0
- package/dist/services/definition.d.ts.map +1 -0
- package/dist/services/definition.js +43 -0
- package/dist/services/definition.js.map +1 -0
- package/dist/services/entity-navigation.d.ts +200 -0
- package/dist/services/entity-navigation.d.ts.map +1 -0
- package/dist/services/entity-navigation.js +211 -0
- package/dist/services/entity-navigation.js.map +1 -0
- package/dist/services/hover.d.ts +81 -0
- package/dist/services/hover.d.ts.map +1 -0
- package/dist/services/hover.js +669 -0
- package/dist/services/hover.js.map +1 -0
- package/dist/services/query.d.ts +116 -0
- package/dist/services/query.d.ts.map +1 -0
- package/dist/services/query.js +225 -0
- package/dist/services/query.js.map +1 -0
- package/dist/services/references.d.ts +52 -0
- package/dist/services/references.d.ts.map +1 -0
- package/dist/services/references.js +66 -0
- package/dist/services/references.js.map +1 -0
- package/dist/services/semantic-tokens.d.ts +54 -0
- package/dist/services/semantic-tokens.d.ts.map +1 -0
- package/dist/services/semantic-tokens.js +213 -0
- package/dist/services/semantic-tokens.js.map +1 -0
- package/dist/services/synthesis.d.ts +90 -0
- package/dist/services/synthesis.d.ts.map +1 -0
- package/dist/services/synthesis.js +113 -0
- package/dist/services/synthesis.js.map +1 -0
- package/dist/source-map.d.ts +42 -0
- package/dist/source-map.d.ts.map +1 -0
- package/dist/source-map.js +170 -0
- package/dist/source-map.js.map +1 -0
- package/package.json +128 -0
- package/tree-sitter-thalo.wasm +0 -0
- package/web-tree-sitter.wasm +0 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Entry, InstanceEntry, Location, SchemaEntry } from "../ast/ast-types.js";
|
|
2
|
+
import { Workspace } from "../model/workspace.js";
|
|
3
|
+
|
|
4
|
+
//#region src/services/entity-navigation.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Result of finding an entity definition (define-entity)
|
|
8
|
+
*/
|
|
9
|
+
interface EntityDefinitionResult {
|
|
10
|
+
/** The file containing the definition */
|
|
11
|
+
file: string;
|
|
12
|
+
/** Location of the definition */
|
|
13
|
+
location: Location;
|
|
14
|
+
/** The schema entry that defines this entity */
|
|
15
|
+
entry: SchemaEntry;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A reference to an entity (instance entry using that entity type)
|
|
19
|
+
*/
|
|
20
|
+
interface EntityReferenceLocation {
|
|
21
|
+
/** The file containing the reference */
|
|
22
|
+
file: string;
|
|
23
|
+
/** Location of the entry using this entity */
|
|
24
|
+
location: Location;
|
|
25
|
+
/** The instance entry using this entity */
|
|
26
|
+
entry: InstanceEntry | SchemaEntry;
|
|
27
|
+
/** Whether this is the definition (always false for entity refs) */
|
|
28
|
+
isDefinition: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of finding entity references
|
|
32
|
+
*/
|
|
33
|
+
interface EntityReferencesResult {
|
|
34
|
+
/** The entity name */
|
|
35
|
+
entityName: string;
|
|
36
|
+
/** The definition (if it exists) */
|
|
37
|
+
definition: EntityDefinitionResult | undefined;
|
|
38
|
+
/** All instance entries using this entity */
|
|
39
|
+
references: EntityReferenceLocation[];
|
|
40
|
+
/** All locations (definition + references if includeDefinition) */
|
|
41
|
+
locations: (EntityDefinitionResult | EntityReferenceLocation)[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Find the define-entity for an entity name
|
|
45
|
+
*
|
|
46
|
+
* @param workspace - The workspace to search in
|
|
47
|
+
* @param entityName - The entity name to find
|
|
48
|
+
* @returns The definition result, or undefined if not found
|
|
49
|
+
*/
|
|
50
|
+
declare function findEntityDefinition(workspace: Workspace, entityName: string): EntityDefinitionResult | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Find all references to an entity type
|
|
53
|
+
*
|
|
54
|
+
* @param workspace - The workspace to search in
|
|
55
|
+
* @param entityName - The entity name to find references for
|
|
56
|
+
* @param includeDefinition - Whether to include the definition in results
|
|
57
|
+
* @returns The references result
|
|
58
|
+
*/
|
|
59
|
+
declare function findEntityReferences(workspace: Workspace, entityName: string, includeDefinition?: boolean): EntityReferencesResult;
|
|
60
|
+
/**
|
|
61
|
+
* A reference to a tag (entry with that tag)
|
|
62
|
+
*/
|
|
63
|
+
interface TagReferenceLocation {
|
|
64
|
+
/** The file containing the reference */
|
|
65
|
+
file: string;
|
|
66
|
+
/** Location of the entry with this tag */
|
|
67
|
+
location: Location;
|
|
68
|
+
/** The entry with this tag */
|
|
69
|
+
entry: Entry;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Result of finding tag references
|
|
73
|
+
*/
|
|
74
|
+
interface TagReferencesResult {
|
|
75
|
+
/** The tag name (without # prefix) */
|
|
76
|
+
tagName: string;
|
|
77
|
+
/** All entries with this tag */
|
|
78
|
+
references: TagReferenceLocation[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Find all entries with a given tag
|
|
82
|
+
*
|
|
83
|
+
* @param workspace - The workspace to search in
|
|
84
|
+
* @param tagName - The tag name (without # prefix)
|
|
85
|
+
* @returns The references result
|
|
86
|
+
*/
|
|
87
|
+
declare function findTagReferences(workspace: Workspace, tagName: string): TagReferencesResult;
|
|
88
|
+
/**
|
|
89
|
+
* Result of finding a field definition
|
|
90
|
+
*/
|
|
91
|
+
interface FieldDefinitionResult {
|
|
92
|
+
/** The file containing the definition */
|
|
93
|
+
file: string;
|
|
94
|
+
/** Location of the field definition */
|
|
95
|
+
location: Location;
|
|
96
|
+
/** The entity name this field belongs to */
|
|
97
|
+
entityName: string;
|
|
98
|
+
/** The schema entry containing this field */
|
|
99
|
+
schemaEntry: SchemaEntry;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A reference to a field (instance entry using that metadata key)
|
|
103
|
+
*/
|
|
104
|
+
interface FieldReferenceLocation {
|
|
105
|
+
/** The file containing the reference */
|
|
106
|
+
file: string;
|
|
107
|
+
/** Location of the metadata line */
|
|
108
|
+
location: Location;
|
|
109
|
+
/** The instance entry using this field */
|
|
110
|
+
entry: InstanceEntry;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Result of finding field references
|
|
114
|
+
*/
|
|
115
|
+
interface FieldReferencesResult {
|
|
116
|
+
/** The field name */
|
|
117
|
+
fieldName: string;
|
|
118
|
+
/** The entity context (if known) */
|
|
119
|
+
entityName: string | undefined;
|
|
120
|
+
/** The definition (if it exists) */
|
|
121
|
+
definition: FieldDefinitionResult | undefined;
|
|
122
|
+
/** All instance entries using this field */
|
|
123
|
+
references: FieldReferenceLocation[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Find the field definition in a schema
|
|
127
|
+
*
|
|
128
|
+
* @param workspace - The workspace to search in
|
|
129
|
+
* @param fieldName - The field name to find
|
|
130
|
+
* @param entityName - Optional entity name to constrain the search
|
|
131
|
+
* @returns The definition result, or undefined if not found
|
|
132
|
+
*/
|
|
133
|
+
declare function findFieldDefinition(workspace: Workspace, fieldName: string, entityName?: string): FieldDefinitionResult | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Find all references to a field
|
|
136
|
+
*
|
|
137
|
+
* @param workspace - The workspace to search in
|
|
138
|
+
* @param fieldName - The field name to find references for
|
|
139
|
+
* @param entityName - Optional entity name to constrain the search
|
|
140
|
+
* @returns The references result
|
|
141
|
+
*/
|
|
142
|
+
declare function findFieldReferences(workspace: Workspace, fieldName: string, entityName?: string): FieldReferencesResult;
|
|
143
|
+
/**
|
|
144
|
+
* Result of finding a section definition
|
|
145
|
+
*/
|
|
146
|
+
interface SectionDefinitionResult {
|
|
147
|
+
/** The file containing the definition */
|
|
148
|
+
file: string;
|
|
149
|
+
/** Location of the section definition */
|
|
150
|
+
location: Location;
|
|
151
|
+
/** The entity name this section belongs to */
|
|
152
|
+
entityName: string;
|
|
153
|
+
/** The schema entry containing this section */
|
|
154
|
+
schemaEntry: SchemaEntry;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A reference to a section (instance entry with that section)
|
|
158
|
+
*/
|
|
159
|
+
interface SectionReferenceLocation {
|
|
160
|
+
/** The file containing the reference */
|
|
161
|
+
file: string;
|
|
162
|
+
/** Location of the entry with this section */
|
|
163
|
+
location: Location;
|
|
164
|
+
/** The instance entry with this section */
|
|
165
|
+
entry: InstanceEntry;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Result of finding section references
|
|
169
|
+
*/
|
|
170
|
+
interface SectionReferencesResult {
|
|
171
|
+
/** The section name */
|
|
172
|
+
sectionName: string;
|
|
173
|
+
/** The entity context (if known) */
|
|
174
|
+
entityName: string | undefined;
|
|
175
|
+
/** The definition (if it exists) */
|
|
176
|
+
definition: SectionDefinitionResult | undefined;
|
|
177
|
+
/** All instance entries with this section */
|
|
178
|
+
references: SectionReferenceLocation[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Find the section definition in a schema
|
|
182
|
+
*
|
|
183
|
+
* @param workspace - The workspace to search in
|
|
184
|
+
* @param sectionName - The section name to find
|
|
185
|
+
* @param entityName - Optional entity name to constrain the search
|
|
186
|
+
* @returns The definition result, or undefined if not found
|
|
187
|
+
*/
|
|
188
|
+
declare function findSectionDefinition(workspace: Workspace, sectionName: string, entityName?: string): SectionDefinitionResult | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Find all references to a section
|
|
191
|
+
*
|
|
192
|
+
* @param workspace - The workspace to search in
|
|
193
|
+
* @param sectionName - The section name to find references for
|
|
194
|
+
* @param entityName - Optional entity name to constrain the search
|
|
195
|
+
* @returns The references result
|
|
196
|
+
*/
|
|
197
|
+
declare function findSectionReferences(workspace: Workspace, sectionName: string, entityName?: string): SectionReferencesResult;
|
|
198
|
+
//#endregion
|
|
199
|
+
export { EntityDefinitionResult, EntityReferenceLocation, EntityReferencesResult, FieldDefinitionResult, FieldReferenceLocation, FieldReferencesResult, SectionDefinitionResult, SectionReferenceLocation, SectionReferencesResult, TagReferenceLocation, TagReferencesResult, findEntityDefinition, findEntityReferences, findFieldDefinition, findFieldReferences, findSectionDefinition, findSectionReferences, findTagReferences };
|
|
200
|
+
//# sourceMappingURL=entity-navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-navigation.d.ts","names":[],"sources":["../../src/services/entity-navigation.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;AAYiB,UAZA,sBAAA,CAYuB;EAI5B;EAEH,IAAA,EAAA,MAAA;EAAgB;EAAW,QAAA,EAdxB,QAcwB;EAQnB;EAIH,KAAA,EAxBL,WAwBK;;;;;AAcE,UAhCC,uBAAA,CAiCJ;EA6BG;EA0DC,IAAA,EAAA,MAAA;EAYA;EA+BD,QAAA,EA/JJ,QA+JI;EA4BC;EAcA,KAAA,EAvMR,aAuMQ,GAvMQ,WAuMc;EAYtB;EAmBD,YAAA,EAAA,OAAA;AAwDhB;AA8CA;AAcA;AAYA;AAmCgB,UAjYC,sBAAA,CAiYoB;EA0DrB;;;cAvbF;;cAEA;;cAEA,yBAAyB;;;;;;;;;iBAUvB,oBAAA,YACH,gCAEV;;;;;;;;;iBA2Ba,oBAAA,YACH,6DAGV;;;;UAsDc,oBAAA;;;;YAIL;;SAEH;;;;;UAMQ,mBAAA;;;;cAIH;;;;;;;;;iBA2BE,iBAAA,YAA6B,6BAA6B;;;;UA4BzD,qBAAA;;;;YAIL;;;;eAIG;;;;;UAME,sBAAA;;;;YAIL;;SAEH;;;;;UAMQ,qBAAA;;;;;;cAMH;;cAEA;;;;;;;;;;iBAWE,mBAAA,YACH,oDAGV;;;;;;;;;iBAoDa,mBAAA,YACH,oDAGV;;;;UA0Cc,uBAAA;;;;YAIL;;;;eAIG;;;;;UAME,wBAAA;;;;YAIL;;SAEH;;;;;UAMQ,uBAAA;;;;;;cAMH;;cAEA;;;;;;;;;;iBA2BE,qBAAA,YACH,sDAGV;;;;;;;;;iBAsDa,qBAAA,YACH,sDAGV"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
//#region src/services/entity-navigation.ts
|
|
2
|
+
/**
|
|
3
|
+
* Find the define-entity for an entity name
|
|
4
|
+
*
|
|
5
|
+
* @param workspace - The workspace to search in
|
|
6
|
+
* @param entityName - The entity name to find
|
|
7
|
+
* @returns The definition result, or undefined if not found
|
|
8
|
+
*/
|
|
9
|
+
function findEntityDefinition(workspace, entityName) {
|
|
10
|
+
for (const model of workspace.allModels()) for (const entry of model.ast.entries) if (entry.type === "schema_entry" && entry.header.directive === "define-entity" && entry.header.entityName.value === entityName) return {
|
|
11
|
+
file: model.file,
|
|
12
|
+
location: entry.location,
|
|
13
|
+
entry
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Find all references to an entity type
|
|
18
|
+
*
|
|
19
|
+
* @param workspace - The workspace to search in
|
|
20
|
+
* @param entityName - The entity name to find references for
|
|
21
|
+
* @param includeDefinition - Whether to include the definition in results
|
|
22
|
+
* @returns The references result
|
|
23
|
+
*/
|
|
24
|
+
function findEntityReferences(workspace, entityName, includeDefinition = true) {
|
|
25
|
+
const definition = findEntityDefinition(workspace, entityName);
|
|
26
|
+
const references = [];
|
|
27
|
+
for (const model of workspace.allModels()) for (const entry of model.ast.entries) {
|
|
28
|
+
if (entry.type === "instance_entry" && entry.header.entity === entityName) references.push({
|
|
29
|
+
file: model.file,
|
|
30
|
+
location: entry.location,
|
|
31
|
+
entry,
|
|
32
|
+
isDefinition: false
|
|
33
|
+
});
|
|
34
|
+
if (entry.type === "schema_entry" && entry.header.directive === "alter-entity" && entry.header.entityName.value === entityName) references.push({
|
|
35
|
+
file: model.file,
|
|
36
|
+
location: entry.location,
|
|
37
|
+
entry,
|
|
38
|
+
isDefinition: false
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const locations = [];
|
|
42
|
+
if (includeDefinition && definition) locations.push(definition);
|
|
43
|
+
locations.push(...references);
|
|
44
|
+
return {
|
|
45
|
+
entityName,
|
|
46
|
+
definition,
|
|
47
|
+
references,
|
|
48
|
+
locations
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get tags from an entry
|
|
53
|
+
*/
|
|
54
|
+
function getEntryTags(entry) {
|
|
55
|
+
switch (entry.type) {
|
|
56
|
+
case "instance_entry": return entry.header.tags.map((t) => t.name);
|
|
57
|
+
case "schema_entry": return entry.header.tags.map((t) => t.name);
|
|
58
|
+
case "synthesis_entry": return entry.header.tags.map((t) => t.name);
|
|
59
|
+
case "actualize_entry": return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Find all entries with a given tag
|
|
64
|
+
*
|
|
65
|
+
* @param workspace - The workspace to search in
|
|
66
|
+
* @param tagName - The tag name (without # prefix)
|
|
67
|
+
* @returns The references result
|
|
68
|
+
*/
|
|
69
|
+
function findTagReferences(workspace, tagName) {
|
|
70
|
+
const references = [];
|
|
71
|
+
for (const model of workspace.allModels()) for (const entry of model.ast.entries) if (getEntryTags(entry).includes(tagName)) references.push({
|
|
72
|
+
file: model.file,
|
|
73
|
+
location: entry.location,
|
|
74
|
+
entry
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
tagName,
|
|
78
|
+
references
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Find the field definition in a schema
|
|
83
|
+
*
|
|
84
|
+
* @param workspace - The workspace to search in
|
|
85
|
+
* @param fieldName - The field name to find
|
|
86
|
+
* @param entityName - Optional entity name to constrain the search
|
|
87
|
+
* @returns The definition result, or undefined if not found
|
|
88
|
+
*/
|
|
89
|
+
function findFieldDefinition(workspace, fieldName, entityName) {
|
|
90
|
+
if (entityName) {
|
|
91
|
+
const schema = workspace.schemaRegistry.get(entityName);
|
|
92
|
+
if (schema) {
|
|
93
|
+
if (schema.fields.get(fieldName)) for (const model of workspace.allModels()) for (const entry of model.ast.entries) {
|
|
94
|
+
if (entry.type !== "schema_entry") continue;
|
|
95
|
+
if (entry.header.entityName.value !== entityName) continue;
|
|
96
|
+
const fieldDef = entry.metadataBlock?.fields.find((f) => f.name.value === fieldName);
|
|
97
|
+
if (fieldDef) return {
|
|
98
|
+
file: model.file,
|
|
99
|
+
location: fieldDef.location,
|
|
100
|
+
entityName,
|
|
101
|
+
schemaEntry: entry
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
for (const schemaEntityName of workspace.schemaRegistry.entityNames()) {
|
|
108
|
+
const result = findFieldDefinition(workspace, fieldName, schemaEntityName);
|
|
109
|
+
if (result) return result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Find all references to a field
|
|
114
|
+
*
|
|
115
|
+
* @param workspace - The workspace to search in
|
|
116
|
+
* @param fieldName - The field name to find references for
|
|
117
|
+
* @param entityName - Optional entity name to constrain the search
|
|
118
|
+
* @returns The references result
|
|
119
|
+
*/
|
|
120
|
+
function findFieldReferences(workspace, fieldName, entityName) {
|
|
121
|
+
const definition = findFieldDefinition(workspace, fieldName, entityName);
|
|
122
|
+
const references = [];
|
|
123
|
+
for (const model of workspace.allModels()) for (const entry of model.ast.entries) {
|
|
124
|
+
if (entry.type !== "instance_entry") continue;
|
|
125
|
+
if (entityName && entry.header.entity !== entityName) continue;
|
|
126
|
+
const meta = entry.metadata.find((m) => m.key.value === fieldName);
|
|
127
|
+
if (meta) references.push({
|
|
128
|
+
file: model.file,
|
|
129
|
+
location: meta.location,
|
|
130
|
+
entry
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
fieldName,
|
|
135
|
+
entityName,
|
|
136
|
+
definition,
|
|
137
|
+
references
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get section names from an instance entry
|
|
142
|
+
*/
|
|
143
|
+
function getEntrySections(entry) {
|
|
144
|
+
if (!entry.content) return [];
|
|
145
|
+
return entry.content.children.filter((c) => c.type === "markdown_header").map((h) => {
|
|
146
|
+
const match = h.text.match(/^#+\s*(.+)$/);
|
|
147
|
+
return match ? match[1].trim() : h.text;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Find the section definition in a schema
|
|
152
|
+
*
|
|
153
|
+
* @param workspace - The workspace to search in
|
|
154
|
+
* @param sectionName - The section name to find
|
|
155
|
+
* @param entityName - Optional entity name to constrain the search
|
|
156
|
+
* @returns The definition result, or undefined if not found
|
|
157
|
+
*/
|
|
158
|
+
function findSectionDefinition(workspace, sectionName, entityName) {
|
|
159
|
+
if (entityName) {
|
|
160
|
+
const schema = workspace.schemaRegistry.get(entityName);
|
|
161
|
+
if (schema) {
|
|
162
|
+
if (schema.sections.get(sectionName)) for (const model of workspace.allModels()) for (const entry of model.ast.entries) {
|
|
163
|
+
if (entry.type !== "schema_entry") continue;
|
|
164
|
+
if (entry.header.entityName.value !== entityName) continue;
|
|
165
|
+
const sectionDef = entry.sectionsBlock?.sections.find((s) => s.name.value === sectionName);
|
|
166
|
+
if (sectionDef) return {
|
|
167
|
+
file: model.file,
|
|
168
|
+
location: sectionDef.location,
|
|
169
|
+
entityName,
|
|
170
|
+
schemaEntry: entry
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
for (const schemaEntityName of workspace.schemaRegistry.entityNames()) {
|
|
177
|
+
const result = findSectionDefinition(workspace, sectionName, schemaEntityName);
|
|
178
|
+
if (result) return result;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Find all references to a section
|
|
183
|
+
*
|
|
184
|
+
* @param workspace - The workspace to search in
|
|
185
|
+
* @param sectionName - The section name to find references for
|
|
186
|
+
* @param entityName - Optional entity name to constrain the search
|
|
187
|
+
* @returns The references result
|
|
188
|
+
*/
|
|
189
|
+
function findSectionReferences(workspace, sectionName, entityName) {
|
|
190
|
+
const definition = findSectionDefinition(workspace, sectionName, entityName);
|
|
191
|
+
const references = [];
|
|
192
|
+
for (const model of workspace.allModels()) for (const entry of model.ast.entries) {
|
|
193
|
+
if (entry.type !== "instance_entry") continue;
|
|
194
|
+
if (entityName && entry.header.entity !== entityName) continue;
|
|
195
|
+
if (getEntrySections(entry).includes(sectionName)) references.push({
|
|
196
|
+
file: model.file,
|
|
197
|
+
location: entry.location,
|
|
198
|
+
entry
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
sectionName,
|
|
203
|
+
entityName,
|
|
204
|
+
definition,
|
|
205
|
+
references
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
export { findEntityDefinition, findEntityReferences, findFieldDefinition, findFieldReferences, findSectionDefinition, findSectionReferences, findTagReferences };
|
|
211
|
+
//# sourceMappingURL=entity-navigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-navigation.js","names":["references: EntityReferenceLocation[]","locations: (EntityDefinitionResult | EntityReferenceLocation)[]","references: TagReferenceLocation[]","references: FieldReferenceLocation[]","references: SectionReferenceLocation[]"],"sources":["../../src/services/entity-navigation.ts"],"sourcesContent":["import type { Workspace } from \"../model/workspace.js\";\nimport type { Location, Entry, SchemaEntry, InstanceEntry } from \"../ast/ast-types.js\";\n\n// ===================\n// Entity Navigation\n// ===================\n\n/**\n * Result of finding an entity definition (define-entity)\n */\nexport interface EntityDefinitionResult {\n /** The file containing the definition */\n file: string;\n /** Location of the definition */\n location: Location;\n /** The schema entry that defines this entity */\n entry: SchemaEntry;\n}\n\n/**\n * A reference to an entity (instance entry using that entity type)\n */\nexport interface EntityReferenceLocation {\n /** The file containing the reference */\n file: string;\n /** Location of the entry using this entity */\n location: Location;\n /** The instance entry using this entity */\n entry: InstanceEntry | SchemaEntry;\n /** Whether this is the definition (always false for entity refs) */\n isDefinition: boolean;\n}\n\n/**\n * Result of finding entity references\n */\nexport interface EntityReferencesResult {\n /** The entity name */\n entityName: string;\n /** The definition (if it exists) */\n definition: EntityDefinitionResult | undefined;\n /** All instance entries using this entity */\n references: EntityReferenceLocation[];\n /** All locations (definition + references if includeDefinition) */\n locations: (EntityDefinitionResult | EntityReferenceLocation)[];\n}\n\n/**\n * Find the define-entity for an entity name\n *\n * @param workspace - The workspace to search in\n * @param entityName - The entity name to find\n * @returns The definition result, or undefined if not found\n */\nexport function findEntityDefinition(\n workspace: Workspace,\n entityName: string,\n): EntityDefinitionResult | undefined {\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (\n entry.type === \"schema_entry\" &&\n entry.header.directive === \"define-entity\" &&\n entry.header.entityName.value === entityName\n ) {\n return {\n file: model.file,\n location: entry.location,\n entry,\n };\n }\n }\n }\n return undefined;\n}\n\n/**\n * Find all references to an entity type\n *\n * @param workspace - The workspace to search in\n * @param entityName - The entity name to find references for\n * @param includeDefinition - Whether to include the definition in results\n * @returns The references result\n */\nexport function findEntityReferences(\n workspace: Workspace,\n entityName: string,\n includeDefinition = true,\n): EntityReferencesResult {\n const definition = findEntityDefinition(workspace, entityName);\n\n // Find all instance entries using this entity\n const references: EntityReferenceLocation[] = [];\n\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (entry.type === \"instance_entry\" && entry.header.entity === entityName) {\n references.push({\n file: model.file,\n location: entry.location,\n entry,\n isDefinition: false,\n });\n }\n\n // Also find alter-entity entries that reference this entity\n if (\n entry.type === \"schema_entry\" &&\n entry.header.directive === \"alter-entity\" &&\n entry.header.entityName.value === entityName\n ) {\n references.push({\n file: model.file,\n location: entry.location,\n entry,\n isDefinition: false,\n });\n }\n }\n }\n\n const locations: (EntityDefinitionResult | EntityReferenceLocation)[] = [];\n if (includeDefinition && definition) {\n locations.push(definition);\n }\n locations.push(...references);\n\n return {\n entityName,\n definition,\n references,\n locations,\n };\n}\n\n// ===================\n// Tag Navigation\n// ===================\n\n/**\n * A reference to a tag (entry with that tag)\n */\nexport interface TagReferenceLocation {\n /** The file containing the reference */\n file: string;\n /** Location of the entry with this tag */\n location: Location;\n /** The entry with this tag */\n entry: Entry;\n}\n\n/**\n * Result of finding tag references\n */\nexport interface TagReferencesResult {\n /** The tag name (without # prefix) */\n tagName: string;\n /** All entries with this tag */\n references: TagReferenceLocation[];\n}\n\n/**\n * Get tags from an entry\n */\nfunction getEntryTags(entry: Entry): string[] {\n switch (entry.type) {\n case \"instance_entry\":\n return entry.header.tags.map((t) => t.name);\n case \"schema_entry\":\n return entry.header.tags.map((t) => t.name);\n case \"synthesis_entry\":\n return entry.header.tags.map((t) => t.name);\n case \"actualize_entry\":\n // Actualize entries don't have tags\n return [];\n }\n}\n\n/**\n * Find all entries with a given tag\n *\n * @param workspace - The workspace to search in\n * @param tagName - The tag name (without # prefix)\n * @returns The references result\n */\nexport function findTagReferences(workspace: Workspace, tagName: string): TagReferencesResult {\n const references: TagReferenceLocation[] = [];\n\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (getEntryTags(entry).includes(tagName)) {\n references.push({\n file: model.file,\n location: entry.location,\n entry,\n });\n }\n }\n }\n\n return {\n tagName,\n references,\n };\n}\n\n// ===================\n// Metadata Field Navigation\n// ===================\n\n/**\n * Result of finding a field definition\n */\nexport interface FieldDefinitionResult {\n /** The file containing the definition */\n file: string;\n /** Location of the field definition */\n location: Location;\n /** The entity name this field belongs to */\n entityName: string;\n /** The schema entry containing this field */\n schemaEntry: SchemaEntry;\n}\n\n/**\n * A reference to a field (instance entry using that metadata key)\n */\nexport interface FieldReferenceLocation {\n /** The file containing the reference */\n file: string;\n /** Location of the metadata line */\n location: Location;\n /** The instance entry using this field */\n entry: InstanceEntry;\n}\n\n/**\n * Result of finding field references\n */\nexport interface FieldReferencesResult {\n /** The field name */\n fieldName: string;\n /** The entity context (if known) */\n entityName: string | undefined;\n /** The definition (if it exists) */\n definition: FieldDefinitionResult | undefined;\n /** All instance entries using this field */\n references: FieldReferenceLocation[];\n}\n\n/**\n * Find the field definition in a schema\n *\n * @param workspace - The workspace to search in\n * @param fieldName - The field name to find\n * @param entityName - Optional entity name to constrain the search\n * @returns The definition result, or undefined if not found\n */\nexport function findFieldDefinition(\n workspace: Workspace,\n fieldName: string,\n entityName?: string,\n): FieldDefinitionResult | undefined {\n // If entityName is provided, look in that entity's schema\n if (entityName) {\n const schema = workspace.schemaRegistry.get(entityName);\n if (schema) {\n const field = schema.fields.get(fieldName);\n if (field) {\n // Find the schema entry that defines this field\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (entry.type !== \"schema_entry\") {\n continue;\n }\n if (entry.header.entityName.value !== entityName) {\n continue;\n }\n\n const fieldDef = entry.metadataBlock?.fields.find((f) => f.name.value === fieldName);\n if (fieldDef) {\n return {\n file: model.file,\n location: fieldDef.location,\n entityName,\n schemaEntry: entry,\n };\n }\n }\n }\n }\n }\n return undefined;\n }\n\n // Without entityName, search all schemas\n for (const schemaEntityName of workspace.schemaRegistry.entityNames()) {\n const result = findFieldDefinition(workspace, fieldName, schemaEntityName);\n if (result) {\n return result;\n }\n }\n\n return undefined;\n}\n\n/**\n * Find all references to a field\n *\n * @param workspace - The workspace to search in\n * @param fieldName - The field name to find references for\n * @param entityName - Optional entity name to constrain the search\n * @returns The references result\n */\nexport function findFieldReferences(\n workspace: Workspace,\n fieldName: string,\n entityName?: string,\n): FieldReferencesResult {\n const definition = findFieldDefinition(workspace, fieldName, entityName);\n\n const references: FieldReferenceLocation[] = [];\n\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (entry.type !== \"instance_entry\") {\n continue;\n }\n\n // If entityName is specified, only look at entries of that entity type\n if (entityName && entry.header.entity !== entityName) {\n continue;\n }\n\n const meta = entry.metadata.find((m) => m.key.value === fieldName);\n if (meta) {\n references.push({\n file: model.file,\n location: meta.location,\n entry,\n });\n }\n }\n }\n\n return {\n fieldName,\n entityName,\n definition,\n references,\n };\n}\n\n// ===================\n// Section Navigation\n// ===================\n\n/**\n * Result of finding a section definition\n */\nexport interface SectionDefinitionResult {\n /** The file containing the definition */\n file: string;\n /** Location of the section definition */\n location: Location;\n /** The entity name this section belongs to */\n entityName: string;\n /** The schema entry containing this section */\n schemaEntry: SchemaEntry;\n}\n\n/**\n * A reference to a section (instance entry with that section)\n */\nexport interface SectionReferenceLocation {\n /** The file containing the reference */\n file: string;\n /** Location of the entry with this section */\n location: Location;\n /** The instance entry with this section */\n entry: InstanceEntry;\n}\n\n/**\n * Result of finding section references\n */\nexport interface SectionReferencesResult {\n /** The section name */\n sectionName: string;\n /** The entity context (if known) */\n entityName: string | undefined;\n /** The definition (if it exists) */\n definition: SectionDefinitionResult | undefined;\n /** All instance entries with this section */\n references: SectionReferenceLocation[];\n}\n\n/**\n * Get section names from an instance entry\n */\nfunction getEntrySections(entry: InstanceEntry): string[] {\n if (!entry.content) {\n return [];\n }\n return entry.content.children\n .filter((c) => c.type === \"markdown_header\")\n .map((h) => {\n // Extract section name from \"# SectionName\" format\n const match = h.text.match(/^#+\\s*(.+)$/);\n return match ? match[1].trim() : h.text;\n });\n}\n\n/**\n * Find the section definition in a schema\n *\n * @param workspace - The workspace to search in\n * @param sectionName - The section name to find\n * @param entityName - Optional entity name to constrain the search\n * @returns The definition result, or undefined if not found\n */\nexport function findSectionDefinition(\n workspace: Workspace,\n sectionName: string,\n entityName?: string,\n): SectionDefinitionResult | undefined {\n // If entityName is provided, look in that entity's schema\n if (entityName) {\n const schema = workspace.schemaRegistry.get(entityName);\n if (schema) {\n const section = schema.sections.get(sectionName);\n if (section) {\n // Find the schema entry that defines this section\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (entry.type !== \"schema_entry\") {\n continue;\n }\n if (entry.header.entityName.value !== entityName) {\n continue;\n }\n\n const sectionDef = entry.sectionsBlock?.sections.find(\n (s) => s.name.value === sectionName,\n );\n if (sectionDef) {\n return {\n file: model.file,\n location: sectionDef.location,\n entityName,\n schemaEntry: entry,\n };\n }\n }\n }\n }\n }\n return undefined;\n }\n\n // Without entityName, search all schemas\n for (const schemaEntityName of workspace.schemaRegistry.entityNames()) {\n const result = findSectionDefinition(workspace, sectionName, schemaEntityName);\n if (result) {\n return result;\n }\n }\n\n return undefined;\n}\n\n/**\n * Find all references to a section\n *\n * @param workspace - The workspace to search in\n * @param sectionName - The section name to find references for\n * @param entityName - Optional entity name to constrain the search\n * @returns The references result\n */\nexport function findSectionReferences(\n workspace: Workspace,\n sectionName: string,\n entityName?: string,\n): SectionReferencesResult {\n const definition = findSectionDefinition(workspace, sectionName, entityName);\n\n const references: SectionReferenceLocation[] = [];\n\n for (const model of workspace.allModels()) {\n for (const entry of model.ast.entries) {\n if (entry.type !== \"instance_entry\") {\n continue;\n }\n\n // If entityName is specified, only look at entries of that entity type\n if (entityName && entry.header.entity !== entityName) {\n continue;\n }\n\n if (getEntrySections(entry).includes(sectionName)) {\n references.push({\n file: model.file,\n location: entry.location,\n entry,\n });\n }\n }\n }\n\n return {\n sectionName,\n entityName,\n definition,\n references,\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ActualizeEntry, Entry, InstanceEntry, Location, SchemaEntry, SynthesisEntry } from "../ast/ast-types.js";
|
|
2
|
+
import { EntitySchema, FieldSchema, SectionSchema } from "../schema/registry.js";
|
|
3
|
+
import { Workspace } from "../model/workspace.js";
|
|
4
|
+
import { NodeContext } from "../ast/node-at-position.js";
|
|
5
|
+
|
|
6
|
+
//#region src/services/hover.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Result of a hover lookup
|
|
10
|
+
*/
|
|
11
|
+
interface HoverResult {
|
|
12
|
+
/** Markdown content to display */
|
|
13
|
+
content: string;
|
|
14
|
+
/** Optional range to highlight (file-absolute) */
|
|
15
|
+
range?: Location;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Format an entry for hover display
|
|
19
|
+
*/
|
|
20
|
+
declare function formatEntryHover(entry: Entry, file: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format an instance entry for hover
|
|
23
|
+
*/
|
|
24
|
+
declare function formatInstanceEntry(entry: InstanceEntry, file: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Format a schema entry for hover
|
|
27
|
+
*/
|
|
28
|
+
declare function formatSchemaEntry(entry: SchemaEntry, file: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Format a synthesis entry for hover
|
|
31
|
+
*/
|
|
32
|
+
declare function formatSynthesisEntry(entry: SynthesisEntry, file: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Format an actualize entry for hover
|
|
35
|
+
*/
|
|
36
|
+
declare function formatActualizeEntry(entry: ActualizeEntry, file: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get documentation for a directive
|
|
39
|
+
*/
|
|
40
|
+
declare function getDirectiveDocumentation(directive: string): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Format an entity schema for hover display
|
|
43
|
+
*/
|
|
44
|
+
declare function formatEntitySchema(schema: EntitySchema): string;
|
|
45
|
+
/**
|
|
46
|
+
* Format a field schema for hover display
|
|
47
|
+
*/
|
|
48
|
+
declare function formatFieldHover(field: FieldSchema, entityName: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Format a section schema for hover display
|
|
51
|
+
*/
|
|
52
|
+
declare function formatSectionHover(section: SectionSchema, entityName: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Get documentation for a primitive type
|
|
55
|
+
*/
|
|
56
|
+
declare function getPrimitiveTypeDocumentation(typeName: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Format tag hover information
|
|
59
|
+
*/
|
|
60
|
+
declare function formatTagHover(tag: string, entries: {
|
|
61
|
+
entry: Entry;
|
|
62
|
+
file: string;
|
|
63
|
+
}[]): string;
|
|
64
|
+
/**
|
|
65
|
+
* Format timestamp hover
|
|
66
|
+
*/
|
|
67
|
+
declare function formatTimestampHover(timestamp: string, entry: Entry | undefined, _file?: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get hover information for a node context.
|
|
70
|
+
*
|
|
71
|
+
* This function takes a semantic node context (from findNodeAtPosition) and
|
|
72
|
+
* returns hover information including markdown content and an optional range.
|
|
73
|
+
*
|
|
74
|
+
* @param workspace - The workspace to look up entries, schemas, etc.
|
|
75
|
+
* @param context - The node context from findNodeAtPosition
|
|
76
|
+
* @returns Hover result with markdown content, or null if no hover info
|
|
77
|
+
*/
|
|
78
|
+
declare function getHoverInfo(workspace: Workspace, context: NodeContext): HoverResult | null;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { HoverResult, formatActualizeEntry, formatEntitySchema, formatEntryHover, formatFieldHover, formatInstanceEntry, formatSchemaEntry, formatSectionHover, formatSynthesisEntry, formatTagHover, formatTimestampHover, getDirectiveDocumentation, getHoverInfo, getPrimitiveTypeDocumentation };
|
|
81
|
+
//# sourceMappingURL=hover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover.d.ts","names":[],"sources":["../../src/services/hover.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAuBA;AA+BgB,UA/BC,WAAA,CA+Be;EAgBhB;EAkDA,OAAA,EAAA,MAAA;EA2CA;EAmCA,KAAA,CAAA,EA3KN,QA2KM;AA+BhB;AAgJA;AA8CA;AA6BA;AA2BgB,iBAraA,gBAAA,CAqa6B,KAAA,EAraL,KAqaK,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AA6F7C;AAiDA;AA+DA;AAAwC,iBAlmBxB,mBAAA,CAkmBwB,KAAA,EAlmBG,aAkmBH,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;iBAhjBxB,iBAAA,QAAyB;;;;iBA2CzB,oBAAA,QAA4B;;;;iBAmC5B,oBAAA,QAA4B;;;;iBA+B5B,yBAAA;;;;iBAgJA,kBAAA,SAA2B;;;;iBA8C3B,gBAAA,QAAwB;;;;iBA6BxB,kBAAA,UAA4B;;;;iBA2B5B,6BAAA;;;;iBA6FA,cAAA;SAA8C;;;;;;iBAiD9C,oBAAA,2BAEP;;;;;;;;;;;iBA6DO,YAAA,YAAwB,oBAAoB,cAAc"}
|