Skip to content

Commit cb99597

Browse files
Refactor register_canvas_schemas by extracting helper functions
The register_canvas_schemas function was overly long. This commit refactors it into three smaller helper functions based on domain grouping: - register_canvas_shape_schemas (for visual/shape elements) - register_canvas_text_schemas (for textual elements) - register_canvas_misc_schemas (for miscallaneous and animations) Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>
1 parent 4c273b1 commit cb99597

1 file changed

Lines changed: 43 additions & 33 deletions

File tree

‎compiler/semantic/src/dsl_schema.rs‎

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ fn register_web_schemas(reg: &mut HashMap<String, DSLSchema>) {
298298
);
299299
}
300300

301-
fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
302-
// Canvas module schemas ──────────────────────────────────────────
301+
fn register_canvas_shape_schemas(reg: &mut HashMap<String, DSLSchema>) {
303302
reg.insert(
304303
"logo".to_string(),
305304
DSLSchema::new(
@@ -318,22 +317,6 @@ fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
318317
),
319318
);
320319

321-
reg.insert(
322-
"rings".to_string(),
323-
DSLSchema::new(
324-
vec![
325-
"count".into(),
326-
"color".into(),
327-
"size".into(),
328-
"thickness".into(),
329-
"spacing".into(),
330-
"rotation".into(),
331-
],
332-
vec![],
333-
vec![],
334-
),
335-
);
336-
337320
reg.insert(
338321
"emblem".to_string(),
339322
DSLSchema::new(
@@ -365,7 +348,9 @@ fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
365348
vec![],
366349
),
367350
);
351+
}
368352

353+
fn register_canvas_text_schemas(reg: &mut HashMap<String, DSLSchema>) {
369354
reg.insert(
370355
"letter".to_string(),
371356
DSLSchema::new(
@@ -383,21 +368,6 @@ fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
383368
),
384369
);
385370

386-
reg.insert(
387-
"circuits".to_string(),
388-
DSLSchema::new(
389-
vec![
390-
"color".into(),
391-
"density".into(),
392-
"width".into(),
393-
"animated".into(),
394-
"complexity".into(),
395-
],
396-
vec![],
397-
vec![],
398-
),
399-
);
400-
401371
reg.insert(
402372
"title".to_string(),
403373
DSLSchema::new(
@@ -437,6 +407,39 @@ fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
437407
vec![],
438408
),
439409
);
410+
}
411+
412+
fn register_canvas_misc_schemas(reg: &mut HashMap<String, DSLSchema>) {
413+
reg.insert(
414+
"rings".to_string(),
415+
DSLSchema::new(
416+
vec![
417+
"count".into(),
418+
"color".into(),
419+
"size".into(),
420+
"thickness".into(),
421+
"spacing".into(),
422+
"rotation".into(),
423+
],
424+
vec![],
425+
vec![],
426+
),
427+
);
428+
429+
reg.insert(
430+
"circuits".to_string(),
431+
DSLSchema::new(
432+
vec![
433+
"color".into(),
434+
"density".into(),
435+
"width".into(),
436+
"animated".into(),
437+
"complexity".into(),
438+
],
439+
vec![],
440+
vec![],
441+
),
442+
);
440443

441444
reg.insert(
442445
"theme".to_string(),
@@ -487,6 +490,13 @@ fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
487490
);
488491
}
489492

493+
fn register_canvas_schemas(reg: &mut HashMap<String, DSLSchema>) {
494+
// Canvas module schemas ──────────────────────────────────────────
495+
register_canvas_shape_schemas(reg);
496+
register_canvas_text_schemas(reg);
497+
register_canvas_misc_schemas(reg);
498+
}
499+
490500
fn register_generic_schemas(reg: &mut HashMap<String, DSLSchema>) {
491501
// Generic DSL blocks ────────────────────────────────────────────
492502
reg.insert(

0 commit comments

Comments
 (0)