@@ -7,15 +7,15 @@ use djls_templates::Node;
77use super :: grammar:: CloseValidation ;
88use super :: grammar:: TagClass ;
99use super :: grammar:: TagIndex ;
10- use super :: nodes:: BlockId ;
11- use super :: nodes:: BlockNode ;
12- use super :: nodes:: BranchKind ;
10+ use super :: tree:: BlockId ;
11+ use super :: tree:: BlockNode ;
1312use super :: tree:: BlockTree ;
13+ use super :: tree:: BranchKind ;
1414use crate :: traits:: SemanticModel ;
1515use crate :: Db ;
1616
1717#[ derive( Debug , Clone ) ]
18- enum BlockSemantics {
18+ enum BlockSemanticOp {
1919 AddRoot {
2020 id : BlockId ,
2121 } ,
@@ -51,7 +51,7 @@ pub struct BlockTreeBuilder<'db> {
5151 index : & ' db TagIndex ,
5252 stack : Vec < TreeFrame < ' db > > ,
5353 block_allocs : Vec < ( Span , Option < BlockId > ) > ,
54- semantic_ops : Vec < BlockSemantics > ,
54+ semantic_ops : Vec < BlockSemanticOp > ,
5555}
5656
5757impl < ' db > BlockTreeBuilder < ' db > {
@@ -88,10 +88,10 @@ impl<'db> BlockTreeBuilder<'db> {
8888
8989 for op in self . semantic_ops {
9090 match op {
91- BlockSemantics :: AddRoot { id } => {
91+ BlockSemanticOp :: AddRoot { id } => {
9292 tree. roots_mut ( ) . push ( id) ;
9393 }
94- BlockSemantics :: AddBranchNode {
94+ BlockSemanticOp :: AddBranchNode {
9595 target,
9696 tag,
9797 marker_span,
@@ -108,26 +108,26 @@ impl<'db> BlockTreeBuilder<'db> {
108108 } ,
109109 ) ;
110110 }
111- BlockSemantics :: AddLeafNode {
111+ BlockSemanticOp :: AddLeafNode {
112112 target,
113113 label,
114114 span,
115115 } => {
116116 tree. blocks_mut ( )
117117 . push_node ( target, BlockNode :: Leaf { label, span } ) ;
118118 }
119- BlockSemantics :: AddErrorNode {
119+ BlockSemanticOp :: AddErrorNode {
120120 target,
121121 message,
122122 span,
123123 } => {
124124 tree. blocks_mut ( )
125125 . push_node ( target, BlockNode :: Error { message, span } ) ;
126126 }
127- BlockSemantics :: ExtendBlockSpan { id, span } => {
127+ BlockSemanticOp :: ExtendBlockSpan { id, span } => {
128128 tree. blocks_mut ( ) . extend_block ( id, span) ;
129129 }
130- BlockSemantics :: FinalizeSpanTo { id, end } => {
130+ BlockSemanticOp :: FinalizeSpanTo { id, end } => {
131131 tree. blocks_mut ( ) . finalize_block_span ( id, end) ;
132132 }
133133 }
@@ -150,14 +150,14 @@ impl<'db> BlockTreeBuilder<'db> {
150150
151151 if let Some ( parent_id) = parent {
152152 // Nested block
153- self . semantic_ops . push ( BlockSemantics :: AddBranchNode {
153+ self . semantic_ops . push ( BlockSemanticOp :: AddBranchNode {
154154 target : parent_id,
155155 tag : tag_name. clone ( ) ,
156156 marker_span : span,
157157 body : container,
158158 kind : BranchKind :: Opener ,
159159 } ) ;
160- self . semantic_ops . push ( BlockSemantics :: AddBranchNode {
160+ self . semantic_ops . push ( BlockSemanticOp :: AddBranchNode {
161161 target : container,
162162 tag : tag_name. clone ( ) ,
163163 marker_span : span,
@@ -167,8 +167,8 @@ impl<'db> BlockTreeBuilder<'db> {
167167 } else {
168168 // Root block
169169 self . semantic_ops
170- . push ( BlockSemantics :: AddRoot { id : container } ) ;
171- self . semantic_ops . push ( BlockSemantics :: AddBranchNode {
170+ . push ( BlockSemanticOp :: AddRoot { id : container } ) ;
171+ self . semantic_ops . push ( BlockSemanticOp :: AddBranchNode {
172172 target : container,
173173 tag : tag_name. clone ( ) ,
174174 marker_span : span,
@@ -194,7 +194,7 @@ impl<'db> BlockTreeBuilder<'db> {
194194 }
195195 TagClass :: Unknown => {
196196 if let Some ( segment) = get_active_segment ( & self . stack ) {
197- self . semantic_ops . push ( BlockSemantics :: AddLeafNode {
197+ self . semantic_ops . push ( BlockSemanticOp :: AddLeafNode {
198198 target : segment,
199199 label : tag_name,
200200 span,
@@ -210,7 +210,7 @@ impl<'db> BlockTreeBuilder<'db> {
210210 while self . stack . len ( ) > frame_idx + 1 {
211211 if let Some ( unclosed) = self . stack . pop ( ) {
212212 if let Some ( parent) = unclosed. parent_body {
213- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
213+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
214214 target : parent,
215215 message : format ! ( "Unclosed block '{}'" , unclosed. opener_name) ,
216216 span : unclosed. opener_span ,
@@ -229,18 +229,18 @@ impl<'db> BlockTreeBuilder<'db> {
229229 CloseValidation :: Valid => {
230230 // Finalize the last segment body to end just before the closer marker
231231 let content_end = span. start ( ) . saturating_sub ( TagDelimiter :: LENGTH_U32 ) ;
232- self . semantic_ops . push ( BlockSemantics :: FinalizeSpanTo {
232+ self . semantic_ops . push ( BlockSemanticOp :: FinalizeSpanTo {
233233 id : frame. segment_body ,
234234 end : content_end,
235235 } ) ;
236236 // Extend to include closer
237- self . semantic_ops . push ( BlockSemantics :: ExtendBlockSpan {
237+ self . semantic_ops . push ( BlockSemanticOp :: ExtendBlockSpan {
238238 id : frame. container_body ,
239239 span,
240240 } ) ;
241241 }
242242 CloseValidation :: ArgumentMismatch { arg, expected, got } => {
243- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
243+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
244244 target : frame. segment_body ,
245245 message : format ! (
246246 "Argument '{arg}' mismatch: expected '{expected}', got '{got}'"
@@ -250,7 +250,7 @@ impl<'db> BlockTreeBuilder<'db> {
250250 self . stack . push ( frame) ; // Restore frame
251251 }
252252 CloseValidation :: MissingRequiredArg { arg, expected } => {
253- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
253+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
254254 target : frame. segment_body ,
255255 message : format ! (
256256 "Missing required argument '{arg}': expected '{expected}'"
@@ -260,7 +260,7 @@ impl<'db> BlockTreeBuilder<'db> {
260260 self . stack . push ( frame) ;
261261 }
262262 CloseValidation :: UnexpectedArg { arg, got } => {
263- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
263+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
264264 target : frame. segment_body ,
265265 message : format ! ( "Unexpected argument '{arg}' with value '{got}'" ) ,
266266 span,
@@ -270,7 +270,7 @@ impl<'db> BlockTreeBuilder<'db> {
270270 CloseValidation :: NotABlock => {
271271 // Should not happen as we already classified it
272272 if let Some ( segment) = get_active_segment ( & self . stack ) {
273- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
273+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
274274 target : segment,
275275 message : format ! ( "Internal error: {opener_name} is not a block" ) ,
276276 span,
@@ -279,7 +279,7 @@ impl<'db> BlockTreeBuilder<'db> {
279279 }
280280 }
281281 } else if let Some ( segment) = get_active_segment ( & self . stack ) {
282- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
282+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
283283 target : segment,
284284 message : format ! ( "Unexpected closing tag '{opener_name}'" ) ,
285285 span,
@@ -295,7 +295,7 @@ impl<'db> BlockTreeBuilder<'db> {
295295 let segment_to_finalize = frame. segment_body ;
296296 let container = frame. container_body ;
297297
298- self . semantic_ops . push ( BlockSemantics :: FinalizeSpanTo {
298+ self . semantic_ops . push ( BlockSemanticOp :: FinalizeSpanTo {
299299 id : segment_to_finalize,
300300 end : content_end,
301301 } ) ;
@@ -304,7 +304,7 @@ impl<'db> BlockTreeBuilder<'db> {
304304 let new_segment_id = self . alloc_block_id ( Span :: new ( body_start, 0 ) , Some ( container) ) ;
305305
306306 // Add the branch node for the new segment
307- self . semantic_ops . push ( BlockSemantics :: AddBranchNode {
307+ self . semantic_ops . push ( BlockSemanticOp :: AddBranchNode {
308308 target : container,
309309 tag : tag_name. to_string ( ) ,
310310 marker_span : span,
@@ -317,7 +317,7 @@ impl<'db> BlockTreeBuilder<'db> {
317317 let segment = frame. segment_body ;
318318 let opener_name = frame. opener_name . clone ( ) ;
319319
320- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
320+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
321321 target : segment,
322322 message : format ! ( "'{tag_name}' is not valid in '{opener_name}'" ) ,
323323 span,
@@ -334,12 +334,12 @@ impl<'db> BlockTreeBuilder<'db> {
334334 if self . index . is_end_optional ( & frame. opener_name ) {
335335 // No explicit closer: finalize last segment to end of input (best-effort)
336336 // We do not know the real end; leave as-is and extend container by opener span only.
337- self . semantic_ops . push ( BlockSemantics :: ExtendBlockSpan {
337+ self . semantic_ops . push ( BlockSemanticOp :: ExtendBlockSpan {
338338 id : frame. container_body ,
339339 span : frame. opener_span ,
340340 } ) ;
341341 } else if let Some ( parent) = frame. parent_body {
342- self . semantic_ops . push ( BlockSemantics :: AddErrorNode {
342+ self . semantic_ops . push ( BlockSemanticOp :: AddErrorNode {
343343 target : parent,
344344 message : format ! ( "Unclosed block '{}'" , frame. opener_name) ,
345345 span : frame. opener_span ,
@@ -380,7 +380,7 @@ impl<'db> SemanticModel<'db> for BlockTreeBuilder<'db> {
380380 }
381381 Node :: Comment { span, .. } => {
382382 if let Some ( parent) = get_active_segment ( & self . stack ) {
383- self . semantic_ops . push ( BlockSemantics :: AddLeafNode {
383+ self . semantic_ops . push ( BlockSemanticOp :: AddLeafNode {
384384 target : parent,
385385 label : "<comment>" . into ( ) ,
386386 span,
@@ -389,7 +389,7 @@ impl<'db> SemanticModel<'db> for BlockTreeBuilder<'db> {
389389 }
390390 Node :: Variable { span, .. } => {
391391 if let Some ( parent) = get_active_segment ( & self . stack ) {
392- self . semantic_ops . push ( BlockSemantics :: AddLeafNode {
392+ self . semantic_ops . push ( BlockSemanticOp :: AddLeafNode {
393393 target : parent,
394394 label : "<var>" . into ( ) ,
395395 span,
@@ -400,7 +400,7 @@ impl<'db> SemanticModel<'db> for BlockTreeBuilder<'db> {
400400 full_span, error, ..
401401 } => {
402402 if let Some ( parent) = get_active_segment ( & self . stack ) {
403- self . semantic_ops . push ( BlockSemantics :: AddLeafNode {
403+ self . semantic_ops . push ( BlockSemanticOp :: AddLeafNode {
404404 target : parent,
405405 label : error. to_string ( ) ,
406406 span : full_span,
0 commit comments