Skip to content

Commit 8a6242d

Browse files
committed
Parser: Rename source to element_source for HTMLElementNode
1 parent 9adb339 commit 8a6242d

File tree

543 files changed

+908
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

543 files changed

+908
-888
lines changed

β€Žconfig.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ nodes:
450450
- name: is_void
451451
type: boolean
452452
453-
- name: source
453+
- name: element_source
454454
type: element_source
455455
456456
- name: HTMLConditionalElementNode

β€Žjava/snapshots/snapshot_tests/testParse.txtβ€Ž

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/herb/ast/node.rbβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ class Node
1212
attr_reader :type #: String
1313
attr_reader :location #: Location
1414
attr_reader :errors #: Array[Herb::Errors::Error]
15+
attr_reader :source #: String?
1516

1617
#: (String, Location, ?Array[Herb::Errors::Error]) -> void
1718
def initialize(type, location, errors = [])
1819
@type = type
1920
@location = location
2021
@errors = errors
22+
@source = nil
23+
end
24+
25+
#: (String?) -> void
26+
def source=(source)
27+
@source = source
28+
compact_child_nodes.each { |child| child.source = source }
2129
end
2230

2331
#: () -> serialized_node

β€Žlib/herb/parse_result.rbβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def initialize(value, source, warnings, errors, options)
1313
@value = value
1414
@options = options
1515
super(source, warnings, errors)
16+
value.source = source
1617
end
1718

1819
#: () -> Array[Herb::Errors::Error]

β€Žsig/herb/ast/node.rbsβ€Ž

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsig/herb/ast/nodes.rbsβ€Ž

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtemplates/javascript/packages/core/src/nodes.ts.erbβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export abstract class Node implements BaseNodeProps {
2424
readonly type: NodeType
2525
readonly location: Location
2626
readonly errors: HerbError[]
27+
source: string | null = null
2728

2829
static from(node: SerializedNode): Node {
2930
return fromSerializedNode(node)
@@ -39,6 +40,11 @@ export abstract class Node implements BaseNodeProps {
3940
this.errors = errors
4041
}
4142

43+
setSource(source: string): void {
44+
this.source = source
45+
this.compactChildNodes().forEach(child => child.setSource(source))
46+
}
47+
4248
toJSON(): SerializedNode {
4349
return {
4450
type: this.type,

β€Žtest/parser/parser_test.rbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ParserTest < Minitest::Spec
5050
β”‚ └── tag_closing: ">" (location: (1:27)-(1:28))
5151
β”‚
5252
β”œβ”€β”€ is_void: false
53-
└── source: "HTML"
53+
└── element_source: "HTML"
5454
SNAPSHOT
5555

5656
file.unlink

β€Žtest/snapshots/analyze/begin_test/test_0003_begin_statement_wrapped_in_element_90dff6e715c904a974e86da2330e3795.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/snapshots/analyze/block_test/test_0004_block_wrapped_in_element_39a5ad73c7d101fb93261a1168948d5b.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)