liveview-native / live_view_native_stylesheet

MIT License
10 stars 4 forks source link

Fix the line number for rules produced inside a `sigil_SHEET` #77

Closed NduatiK closed 1 month ago

NduatiK commented 1 month ago

Required to fix bug in https://github.com/liveview-native/liveview-client-swiftui/pull/1402.


Currently, the sigil_SHEET parses blocks and hands the block contents to a sigil_RULES. We don't pass down any line information to the sigil_RULES. The parser used by the sigil_RULES will not receive information about the location of the block contents it is parsing.

In the sheet below, the rules parser will treat rule-blue and rule-yellow as though they are at the same location. Both are assumed to be on line 3 (1 (Location of sheet parser) + 1 (location of block in sheet) + 1 (location of rule in block)).

1 | ~SHEET"""
2 | "color-blue" do
3 |   rule-blue
4 | end
5 | 
6 | "color-yellow" do
7 |   rule-yellow
8 | end
9 | """

This PR passes block line information from the sheet parser down to the rules parser which allows for more correct errors and warnings. In the example above, rule-blue will be on line 3 and rule-yellow on line 7.

bcardarella commented 1 month ago

I like it!