@@ -90,6 +90,9 @@ class _TreeNodeValueBase {
90
90
return this . _type === TreeNodeType . static
91
91
}
92
92
93
+ isGroup ( ) : this is TreeNodeValueGroup {
94
+ return this . _type === TreeNodeType . group
95
+ }
93
96
get overrides ( ) {
94
97
return [ ...this . _overrides . entries ( ) ]
95
98
. sort ( ( [ nameA ] , [ nameB ] ) =>
@@ -201,7 +204,27 @@ export class TreeNodeValueParam extends _TreeNodeValueBase {
201
204
}
202
205
}
203
206
204
- export type TreeNodeValue = TreeNodeValueStatic | TreeNodeValueParam
207
+ export class TreeNodeValueGroup extends _TreeNodeValueBase {
208
+ override _type : TreeNodeType . group = TreeNodeType . group
209
+
210
+ constructor (
211
+ rawSegment : string ,
212
+ parent : TreeNodeValue | undefined ,
213
+ pathSegment : string = rawSegment ,
214
+ subSegments : SubSegment [ ] = [ pathSegment ]
215
+ ) {
216
+ // Sanitize both rawSegment and pathSegment
217
+ const sanitizedRawSegment = rawSegment . replace ( / \( .* ?\) / g, '' )
218
+ const sanitizedPathSegment = pathSegment . replace ( / \( .* ?\) / g, '' )
219
+
220
+ super ( sanitizedRawSegment , parent , sanitizedPathSegment , subSegments )
221
+ }
222
+ }
223
+
224
+ export type TreeNodeValue =
225
+ | TreeNodeValueStatic
226
+ | TreeNodeValueParam
227
+ | TreeNodeValueGroup
205
228
206
229
export interface TreeNodeValueOptions extends ParseSegmentOptions {
207
230
/**
@@ -226,6 +249,10 @@ export function createTreeNodeValue(
226
249
parent ?: TreeNodeValue ,
227
250
options : TreeNodeValueOptions = { }
228
251
) : TreeNodeValue {
252
+ // Check if the segment represents a group file (contains `()`)
253
+ if ( segment . includes ( '(' ) && segment . includes ( ')' ) ) {
254
+ return new TreeNodeValueGroup ( segment , parent )
255
+ }
229
256
if ( ! segment || segment === 'index' ) {
230
257
return new TreeNodeValueStatic ( segment , parent , '' )
231
258
}
0 commit comments