Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
- name: Steep
run: bundle exec steep check

- name: Sorbet
run: bundle exec srb tc

- name: RBS Inline
run: bundle exec rake rbs_inline

# - name: Sorbet
# run: bundle exec srb tc

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

Expand Down
6 changes: 3 additions & 3 deletions lib/herb/ast/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
module Herb
module AST
module Helpers
#: (Herb::AST::Node) -> bool
#: (Herb::AST::Node?) -> bool
def erb_outputs?(node)
return false unless node.is_a?(Herb::AST::ERBContentNode)

opening = node.tag_opening&.value
opening&.include?("=") && !opening&.start_with?("<%#")
opening = node.tag_opening&.value || ""
opening.include?("=") && !opening.start_with?("<%#")
end

#: (String) -> bool
Expand Down
9 changes: 7 additions & 2 deletions lib/herb/ast/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
# typed: true

module Herb
#: type serialized_node = {
#| type: String,
#| location: serialized_location?,
#| errors: Array[serialized_error]
#| }
module AST
class Node
attr_reader :type #: String
attr_reader :location #: Location
attr_reader :errors #: Array[Herb::Errors::Error]

#: (String, Location, Array[Herb::Errors::Error]) -> void
#: (String, Location, ?Array[Herb::Errors::Error]) -> void
def initialize(type, location, errors = [])
@type = type
@location = location
Expand All @@ -19,7 +24,7 @@ def initialize(type, location, errors = [])
def to_hash
{
type: type,
location: location&.to_hash,
location: location.to_hash,
errors: errors.map(&:to_hash),
}
end
Expand Down
1 change: 1 addition & 0 deletions lib/herb/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
# typed: false

require "json"
require "time"
Expand Down
4 changes: 2 additions & 2 deletions lib/herb/engine/debug_visitor.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
# typed: false

module Herb
class Engine
Expand Down Expand Up @@ -31,6 +32,7 @@ def initialize(file_path: nil, project_path: nil)
@in_html_comment = false
@in_html_doctype = false
@erb_nodes_to_wrap = [] #: Array[Herb::AST::ERBContentNode]
@top_level_elements = [] #: Array[Herb::AST::HTMLElementNode]
end

def visit_document_node(node)
Expand Down Expand Up @@ -149,8 +151,6 @@ def replace_erb_nodes_recursive(node)
end

def find_top_level_elements(document_node)
@top_level_elements = [] #: Array[Herb::AST::HTMLElementNode]

document_node.children.each do |child|
@top_level_elements << child if child.is_a?(Herb::AST::HTMLElementNode)
end
Expand Down
1 change: 1 addition & 0 deletions lib/herb/lex_result.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
# typed: true

module Herb
class LexResult < Result
Expand Down
10 changes: 7 additions & 3 deletions lib/herb/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# typed: true

module Herb
#: type serialized_location = {
#| start: serialized_position,
#| end: serialized_position
#| }
class Location
attr_reader :start #: Position
attr_reader :end #: Position
Expand All @@ -28,9 +32,9 @@ def self.[](start_line, start_column, end_line, end_column)
#: () -> serialized_location
def to_hash
{
start: start,
end: self.end,
} #: Herb::serialized_location
start: start.to_hash,
end: self.end.to_hash,
}
end

#: (?untyped) -> String
Expand Down
1 change: 1 addition & 0 deletions lib/herb/parse_result.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
# typed: true

require "json"

Expand Down
1 change: 1 addition & 0 deletions lib/herb/position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# typed: true

module Herb
#: type serialized_position = { line: Integer, column: Integer }
class Position
attr_reader :line #: Integer
attr_reader :column #: Integer
Expand Down
1 change: 1 addition & 0 deletions lib/herb/range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# typed: true

module Herb
#: type serialized_range = [Integer, Integer]
class Range
attr_reader :from #: Integer
attr_reader :to #: Integer
Expand Down
8 changes: 7 additions & 1 deletion lib/herb/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# typed: true

module Herb
#: type serialized_token = {
#| value: String,
#| range: serialized_range?,
#| location: serialized_location?,
#| type: String
#| }
class Token
include Colors

Expand All @@ -25,7 +31,7 @@ def to_hash
range: range&.to_a,
location: location&.to_hash,
type: type,
} #: Herb::serialized_token
}
end

#: (?untyped) -> String
Expand Down
7 changes: 6 additions & 1 deletion lib/herb/warnings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@

module Herb
module Warnings
#: type serialized_warning = {
#| type: String,
#| location: serialized_location?,
#| message: String
#| }
class Warning
attr_reader :type #: String
attr_reader :location #: Location
attr_reader :location #: Location?
attr_reader :message #: String

#: (String, Location, String) -> void
Expand Down
4 changes: 2 additions & 2 deletions sig/herb/ast/helpers.rbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions sig/herb/ast/node.rbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading