Skip to content

Commit ca0eb72

Browse files
mickeytglmarcoroth
authored andcommitted
Update dynamic values
1 parent 2190b44 commit ca0eb72

File tree

17 files changed

+93
-36
lines changed

17 files changed

+93
-36
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959
- name: RBS Inline
6060
run: bundle exec rake rbs_inline
6161

62-
# - name: Sorbet
63-
# run: bundle exec srb tc
62+
- name: Sorbet
63+
run: bundle exec srb tc
6464

6565
- name: clang-tidy version
6666
run: clang-tidy-21 --version

lib/herb/ast/helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
module Herb
55
module AST
66
module Helpers
7-
#: (Herb::AST::Node) -> bool
7+
#: (Herb::AST::Node?) -> bool
88
def erb_outputs?(node)
99
return false unless node.is_a?(Herb::AST::ERBContentNode)
1010

11-
opening = node.tag_opening&.value
12-
opening&.include?("=") && !opening&.start_with?("<%#")
11+
opening = node.tag_opening&.value || ""
12+
opening.include?("=") && !opening.start_with?("<%#")
1313
end
1414

1515
#: (String) -> bool

lib/herb/ast/node.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_node = {
6+
#| type: String,
7+
#| location: serialized_location?,
8+
#| errors: Array[serialized_error]
9+
#| }
510
module AST
611
class Node
7-
attr_reader :type #: String
8-
attr_reader :location #: Location
9-
attr_reader :errors #: Array[Herb::Errors::Error]
10-
11-
#: (String, Location, Array[Herb::Errors::Error]) -> void
12+
#: String
13+
attr_reader :type
14+
#: Location
15+
attr_reader :location
16+
#: Array[Herb::Errors::Error]
17+
attr_reader :errors
18+
19+
#: (String, Location, ?Array[Herb::Errors::Error]) -> void
1220
def initialize(type, location, errors = [])
1321
@type = type
1422
@location = location
@@ -19,7 +27,7 @@ def initialize(type, location, errors = [])
1927
def to_hash
2028
{
2129
type: type,
22-
location: location&.to_hash,
30+
location: location.to_hash,
2331
errors: errors.map(&:to_hash),
2432
}
2533
end

lib/herb/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
# typed: false
23

34
require "json"
45
require "time"

lib/herb/engine/debug_visitor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
# typed: false
23

34
module Herb
45
class Engine
@@ -31,6 +32,7 @@ def initialize(file_path: nil, project_path: nil)
3132
@in_html_comment = false
3233
@in_html_doctype = false
3334
@erb_nodes_to_wrap = [] #: Array[Herb::AST::ERBContentNode]
35+
@top_level_elements = [] #: Array[Herb::AST::HTMLElementNode]
3436
end
3537

3638
def visit_document_node(node)
@@ -149,8 +151,6 @@ def replace_erb_nodes_recursive(node)
149151
end
150152

151153
def find_top_level_elements(document_node)
152-
@top_level_elements = [] #: Array[Herb::AST::HTMLElementNode]
153-
154154
document_node.children.each do |child|
155155
@top_level_elements << child if child.is_a?(Herb::AST::HTMLElementNode)
156156
end

lib/herb/lex_result.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
2+
# typed: true
23

34
module Herb
45
class LexResult < Result
5-
attr_reader :value #: TokenList
6+
#: TokenList
7+
attr_reader :value
68

79
#: (Array[Herb::Token], String, Array[Herb::Warnings::Warning], Array[Herb::Errors::Error]) -> void
810
def initialize(value, source, warnings, errors)

lib/herb/location.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_location = {
6+
#| start: serialized_position,
7+
#| end: serialized_position
8+
#| }
59
class Location
6-
attr_reader :start #: Position
7-
attr_reader :end #: Position
10+
#: Position
11+
attr_reader :start
12+
#: Position
13+
attr_reader :end
814

915
#: (Position, Position) -> void
1016
def initialize(start_position, end_position)
@@ -28,9 +34,9 @@ def self.[](start_line, start_column, end_line, end_column)
2834
#: () -> serialized_location
2935
def to_hash
3036
{
31-
start: start,
32-
end: self.end,
33-
} #: Herb::serialized_location
37+
start: start.to_hash,
38+
end: self.end.to_hash,
39+
}
3440
end
3541

3642
#: (?untyped) -> String

lib/herb/parse_result.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
# typed: true
23

34
require "json"
45

lib/herb/result.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
module Herb
55
class Result
6-
attr_reader :source #: String
7-
attr_reader :warnings #: Array[Herb::Warnings::Warning]
8-
attr_reader :errors #: Array[Herb::Errors::Error]
6+
#: String
7+
attr_reader :source
8+
#: Array[Herb::Warnings::Warning]
9+
attr_reader :warnings
10+
#: Array[Herb::Errors::Error]
11+
attr_reader :errors
912

1013
#: (String, Array[Herb::Warnings::Warning], Array[Herb::Errors::Error]) -> void
1114
def initialize(source, warnings, errors)

lib/herb/token.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_token = {
6+
#| value: String,
7+
#| range: serialized_range?,
8+
#| location: serialized_location?,
9+
#| type: String
10+
#| }
511
class Token
612
include Colors
713

@@ -25,7 +31,7 @@ def to_hash
2531
range: range&.to_a,
2632
location: location&.to_hash,
2733
type: type,
28-
} #: Herb::serialized_token
34+
}
2935
end
3036

3137
#: (?untyped) -> String

0 commit comments

Comments
 (0)