herb 0.6.1-x86-linux-musl → 0.7.0-x86-linux-musl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/ext/herb/nodes.c +6 -4
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/ast/helpers.rb +26 -0
- data/lib/herb/ast/nodes.rb +7 -3
- data/lib/herb/cli.rb +158 -1
- data/lib/herb/engine/compiler.rb +399 -0
- data/lib/herb/engine/debug_visitor.rb +321 -0
- data/lib/herb/engine/error_formatter.rb +420 -0
- data/lib/herb/engine/parser_error_overlay.rb +767 -0
- data/lib/herb/engine/validation_error_overlay.rb +182 -0
- data/lib/herb/engine/validation_errors.rb +65 -0
- data/lib/herb/engine/validator.rb +75 -0
- data/lib/herb/engine/validators/accessibility_validator.rb +31 -0
- data/lib/herb/engine/validators/nesting_validator.rb +95 -0
- data/lib/herb/engine/validators/security_validator.rb +71 -0
- data/lib/herb/engine.rb +366 -0
- data/lib/herb/project.rb +3 -3
- data/lib/herb/version.rb +1 -1
- data/lib/herb/visitor.rb +2 -0
- data/lib/herb.rb +2 -0
- data/sig/herb/ast/helpers.rbs +16 -0
- data/sig/herb/ast/nodes.rbs +4 -2
- data/sig/herb/engine/compiler.rbs +109 -0
- data/sig/herb/engine/debug.rbs +38 -0
- data/sig/herb/engine/debug_visitor.rbs +70 -0
- data/sig/herb/engine/error_formatter.rbs +47 -0
- data/sig/herb/engine/parser_error_overlay.rbs +41 -0
- data/sig/herb/engine/validation_error_overlay.rbs +35 -0
- data/sig/herb/engine/validation_errors.rbs +45 -0
- data/sig/herb/engine/validator.rbs +37 -0
- data/sig/herb/engine/validators/accessibility_validator.rbs +19 -0
- data/sig/herb/engine/validators/nesting_validator.rbs +25 -0
- data/sig/herb/engine/validators/security_validator.rbs +23 -0
- data/sig/herb/engine.rbs +72 -0
- data/sig/herb/visitor.rbs +2 -0
- data/sig/herb_c_extension.rbs +7 -0
- data/sig/serialized_ast_nodes.rbs +1 -0
- data/src/ast_nodes.c +2 -1
- data/src/ast_pretty_print.c +2 -1
- data/src/element_source.c +11 -0
- data/src/include/ast_nodes.h +3 -1
- data/src/include/element_source.h +13 -0
- data/src/include/version.h +1 -1
- data/src/parser.c +3 -0
- data/src/parser_helpers.c +1 -0
- metadata +30 -2
data/lib/herb/engine.rb
ADDED
@@ -0,0 +1,366 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "time"
|
5
|
+
require "pathname"
|
6
|
+
|
7
|
+
require_relative "engine/debug_visitor"
|
8
|
+
require_relative "engine/compiler"
|
9
|
+
require_relative "engine/error_formatter"
|
10
|
+
require_relative "engine/validation_errors"
|
11
|
+
require_relative "engine/parser_error_overlay"
|
12
|
+
require_relative "engine/validation_error_overlay"
|
13
|
+
require_relative "engine/validators/security_validator"
|
14
|
+
require_relative "engine/validators/nesting_validator"
|
15
|
+
require_relative "engine/validators/accessibility_validator"
|
16
|
+
|
17
|
+
module Herb
|
18
|
+
class Engine
|
19
|
+
attr_reader :src, :filename, :project_path, :relative_file_path, :bufvar, :debug, :content_for_head,
|
20
|
+
:validation_error_template
|
21
|
+
|
22
|
+
ESCAPE_TABLE = {
|
23
|
+
"&" => "&",
|
24
|
+
"<" => "<",
|
25
|
+
">" => ">",
|
26
|
+
'"' => """,
|
27
|
+
"'" => "'",
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
class CompilationError < StandardError
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(input, properties = {})
|
34
|
+
@filename = properties[:filename] ? ::Pathname.new(properties[:filename]) : nil
|
35
|
+
@project_path = ::Pathname.new(properties[:project_path] || Dir.pwd)
|
36
|
+
|
37
|
+
if @filename
|
38
|
+
absolute_filename = @filename.absolute? ? @filename : @project_path + @filename
|
39
|
+
@relative_file_path = absolute_filename.relative_path_from(@project_path).to_s
|
40
|
+
else
|
41
|
+
@relative_file_path = "unknown"
|
42
|
+
end
|
43
|
+
|
44
|
+
@bufvar = properties[:bufvar] || properties[:outvar] || "_buf"
|
45
|
+
@escape = properties.fetch(:escape) { properties.fetch(:escape_html, false) }
|
46
|
+
@escapefunc = properties[:escapefunc]
|
47
|
+
@src = properties[:src] || String.new
|
48
|
+
@chain_appends = properties[:chain_appends]
|
49
|
+
@buffer_on_stack = false
|
50
|
+
@debug = properties.fetch(:debug, false)
|
51
|
+
@content_for_head = properties[:content_for_head]
|
52
|
+
@validation_error_template = nil
|
53
|
+
@validation_mode = properties.fetch(:validation_mode, :raise)
|
54
|
+
|
55
|
+
unless [:raise, :overlay, :none].include?(@validation_mode)
|
56
|
+
raise ArgumentError,
|
57
|
+
"validation_mode must be one of :raise, :overlay, or :none, got #{@validation_mode.inspect}"
|
58
|
+
end
|
59
|
+
|
60
|
+
@escapefunc ||= if @escape
|
61
|
+
"__herb.h"
|
62
|
+
else
|
63
|
+
"::Herb::Engine.h"
|
64
|
+
end
|
65
|
+
|
66
|
+
@freeze = properties[:freeze]
|
67
|
+
@freeze_template_literals = properties.fetch(:freeze_template_literals, true)
|
68
|
+
@text_end = @freeze_template_literals ? "'.freeze" : "'"
|
69
|
+
|
70
|
+
bufval = properties[:bufval] || "::String.new"
|
71
|
+
preamble = properties[:preamble] || "#{@bufvar} = #{bufval};"
|
72
|
+
postamble = properties[:postamble] || "#{@bufvar}.to_s\n"
|
73
|
+
|
74
|
+
@src << "# frozen_string_literal: true\n" if @freeze
|
75
|
+
|
76
|
+
if properties[:ensure]
|
77
|
+
@src << "begin; __original_outvar = #{@bufvar}"
|
78
|
+
@src << if /\A@[^@]/ =~ @bufvar
|
79
|
+
"; "
|
80
|
+
else
|
81
|
+
" if defined?(#{@bufvar}); "
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
@src << "__herb = ::Herb::Engine; " if @escape && @escapefunc == "__herb.h"
|
86
|
+
|
87
|
+
@src << preamble
|
88
|
+
@src << "\n" unless preamble.end_with?("\n")
|
89
|
+
|
90
|
+
parse_result = ::Herb.parse(input)
|
91
|
+
ast = parse_result.value
|
92
|
+
parser_errors = parse_result.errors
|
93
|
+
|
94
|
+
if parser_errors.any?
|
95
|
+
case @validation_mode
|
96
|
+
when :raise
|
97
|
+
handle_parser_errors(parser_errors, input, ast)
|
98
|
+
return
|
99
|
+
when :overlay
|
100
|
+
add_parser_error_overlay(parser_errors, input)
|
101
|
+
when :none
|
102
|
+
# Skip both errors and compilation, but still need minimal Ruby code
|
103
|
+
end
|
104
|
+
else
|
105
|
+
validation_errors = run_validation(ast) unless @validation_mode == :none
|
106
|
+
all_errors = parser_errors + (validation_errors || [])
|
107
|
+
|
108
|
+
handle_validation_errors(all_errors, input) if @validation_mode == :raise && all_errors.any?
|
109
|
+
|
110
|
+
add_validation_overlay(validation_errors, input) if @validation_mode == :overlay && validation_errors&.any?
|
111
|
+
|
112
|
+
if @debug
|
113
|
+
debug_visitor = DebugVisitor.new(self)
|
114
|
+
ast.accept(debug_visitor)
|
115
|
+
end
|
116
|
+
|
117
|
+
compiler = Compiler.new(self, properties)
|
118
|
+
ast.accept(compiler)
|
119
|
+
|
120
|
+
compiler.generate_output
|
121
|
+
end
|
122
|
+
|
123
|
+
if @validation_error_template
|
124
|
+
escaped_html = @validation_error_template.gsub("'", "\\\\'")
|
125
|
+
@src << " #{@bufvar} << ('#{escaped_html}'.html_safe).to_s;"
|
126
|
+
end
|
127
|
+
|
128
|
+
@src << "\n" unless @src.end_with?("\n")
|
129
|
+
send(:add_postamble, postamble)
|
130
|
+
|
131
|
+
@src << "; ensure\n #{@bufvar} = __original_outvar\nend\n" if properties[:ensure]
|
132
|
+
|
133
|
+
@src.freeze
|
134
|
+
freeze
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.h(value)
|
138
|
+
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.attr(value)
|
142
|
+
value.to_s
|
143
|
+
.gsub("&", "&")
|
144
|
+
.gsub('"', """)
|
145
|
+
.gsub("'", "'")
|
146
|
+
.gsub("<", "<")
|
147
|
+
.gsub(">", ">")
|
148
|
+
.gsub("\n", " ")
|
149
|
+
.gsub("\r", " ")
|
150
|
+
.gsub("\t", "	")
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.js(value)
|
154
|
+
value.to_s.gsub(/[\\'"<>&\n\r\t\f\b]/) do |char|
|
155
|
+
case char
|
156
|
+
when "\n" then "\\n"
|
157
|
+
when "\r" then "\\r"
|
158
|
+
when "\t" then "\\t"
|
159
|
+
when "\f" then "\\f"
|
160
|
+
when "\b" then "\\b"
|
161
|
+
else
|
162
|
+
"\\x#{char.ord.to_s(16).rjust(2, "0")}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.css(value)
|
168
|
+
value.to_s.gsub(/[^\w-]/) do |char|
|
169
|
+
"\\#{char.ord.to_s(16).rjust(6, "0")}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
protected
|
174
|
+
|
175
|
+
def add_text(text)
|
176
|
+
return if text.empty?
|
177
|
+
|
178
|
+
text = text.gsub(/['\\]/, '\\\\\&')
|
179
|
+
|
180
|
+
with_buffer { @src << " << '" << text << @text_end }
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_code(code)
|
184
|
+
terminate_expression
|
185
|
+
|
186
|
+
@src << " " << code
|
187
|
+
@src << ";" unless code[-1] == "\n"
|
188
|
+
@buffer_on_stack = false
|
189
|
+
end
|
190
|
+
|
191
|
+
def add_expression(indicator, code)
|
192
|
+
if (indicator == "=") ^ @escape
|
193
|
+
add_expression_result(code)
|
194
|
+
else
|
195
|
+
add_expression_result_escaped(code)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def add_expression_result(code)
|
200
|
+
with_buffer { @src << " << (" << code << ").to_s" }
|
201
|
+
end
|
202
|
+
|
203
|
+
def add_expression_result_escaped(code)
|
204
|
+
with_buffer { @src << " << " << @escapefunc << "((" << code << "))" }
|
205
|
+
end
|
206
|
+
|
207
|
+
def add_expression_block(indicator, code)
|
208
|
+
if (indicator == "=") ^ @escape
|
209
|
+
add_expression_block_result(code)
|
210
|
+
else
|
211
|
+
add_expression_block_result_escaped(code)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def add_expression_block_result(code)
|
216
|
+
with_buffer { @src << " << " << code }
|
217
|
+
end
|
218
|
+
|
219
|
+
def add_expression_block_result_escaped(code)
|
220
|
+
with_buffer { @src << " << " << @escapefunc << "(" << code << ")" }
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_postamble(postamble)
|
224
|
+
terminate_expression
|
225
|
+
@src << postamble
|
226
|
+
end
|
227
|
+
|
228
|
+
def with_buffer(&_block)
|
229
|
+
if @chain_appends
|
230
|
+
@src << "; " << @bufvar unless @buffer_on_stack
|
231
|
+
yield
|
232
|
+
@buffer_on_stack = true
|
233
|
+
else
|
234
|
+
@src << " " << @bufvar
|
235
|
+
yield
|
236
|
+
@src << ";"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def terminate_expression
|
241
|
+
@src << "; " if @chain_appends && @buffer_on_stack
|
242
|
+
end
|
243
|
+
|
244
|
+
private
|
245
|
+
|
246
|
+
def run_validation(ast)
|
247
|
+
validators = [
|
248
|
+
Validators::SecurityValidator.new,
|
249
|
+
Validators::NestingValidator.new,
|
250
|
+
Validators::AccessibilityValidator.new
|
251
|
+
]
|
252
|
+
|
253
|
+
errors = [] #: Array[untyped]
|
254
|
+
|
255
|
+
validators.each do |validator|
|
256
|
+
ast.accept(validator)
|
257
|
+
errors.concat(validator.errors)
|
258
|
+
end
|
259
|
+
|
260
|
+
errors
|
261
|
+
end
|
262
|
+
|
263
|
+
def handle_parser_errors(parser_errors, input, _ast)
|
264
|
+
case @validation_mode
|
265
|
+
when :raise
|
266
|
+
formatter = ErrorFormatter.new(input, parser_errors, filename: @filename)
|
267
|
+
message = formatter.format_all
|
268
|
+
|
269
|
+
raise CompilationError, "\n#{message}"
|
270
|
+
when :overlay
|
271
|
+
add_parser_error_overlay(parser_errors, input)
|
272
|
+
@src << "\n" unless @src.end_with?("\n")
|
273
|
+
send(:add_postamble, "#{@bufvar}.to_s\n")
|
274
|
+
when :none
|
275
|
+
@src << "\n" unless @src.end_with?("\n")
|
276
|
+
send(:add_postamble, "#{@bufvar}.to_s\n")
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def handle_validation_errors(errors, input)
|
281
|
+
return unless errors.any?
|
282
|
+
|
283
|
+
security_error = errors.find { |error|
|
284
|
+
error.is_a?(Hash) && error[:source] == "SecurityValidator"
|
285
|
+
}
|
286
|
+
|
287
|
+
if security_error
|
288
|
+
line = security_error[:location]&.start&.line
|
289
|
+
column = security_error[:location]&.start&.column
|
290
|
+
suggestion = security_error[:suggestion]
|
291
|
+
|
292
|
+
raise SecurityError.new(
|
293
|
+
security_error[:message],
|
294
|
+
line: line,
|
295
|
+
column: column,
|
296
|
+
filename: @filename,
|
297
|
+
suggestion: suggestion
|
298
|
+
)
|
299
|
+
end
|
300
|
+
|
301
|
+
formatter = ErrorFormatter.new(input, errors, filename: @filename)
|
302
|
+
message = formatter.format_all
|
303
|
+
raise CompilationError, "\n#{message}"
|
304
|
+
end
|
305
|
+
|
306
|
+
def add_validation_overlay(errors, input = nil)
|
307
|
+
return unless errors.any?
|
308
|
+
|
309
|
+
templates = errors.map { |error|
|
310
|
+
location = error[:location]
|
311
|
+
line = location&.start&.line || 0
|
312
|
+
column = location&.start&.column || 0
|
313
|
+
|
314
|
+
source = input || @src
|
315
|
+
overlay_generator = ValidationErrorOverlay.new(source, error, filename: @relative_file_path)
|
316
|
+
html_fragment = overlay_generator.generate_fragment
|
317
|
+
|
318
|
+
escaped_message = escape_attr(error[:message])
|
319
|
+
escaped_suggestion = error[:suggestion] ? escape_attr(error[:suggestion]) : ""
|
320
|
+
|
321
|
+
<<~TEMPLATE
|
322
|
+
<template
|
323
|
+
data-herb-validation-error
|
324
|
+
data-severity="#{error[:severity]}"
|
325
|
+
data-source="#{error[:source]}"
|
326
|
+
data-code="#{error[:code]}"
|
327
|
+
data-line="#{line}"
|
328
|
+
data-column="#{column}"
|
329
|
+
data-filename="#{escape_attr(@relative_file_path)}"
|
330
|
+
data-message="#{escaped_message}"
|
331
|
+
#{"data-suggestion=\"#{escaped_suggestion}\"" if error[:suggestion]}
|
332
|
+
data-timestamp="#{Time.now.iso8601}"
|
333
|
+
>#{html_fragment}</template>
|
334
|
+
TEMPLATE
|
335
|
+
}.join
|
336
|
+
|
337
|
+
@validation_error_template = templates
|
338
|
+
end
|
339
|
+
|
340
|
+
def escape_attr(text)
|
341
|
+
text.to_s
|
342
|
+
.gsub("&", "&")
|
343
|
+
.gsub('"', """)
|
344
|
+
.gsub("'", "'")
|
345
|
+
.gsub("<", "<")
|
346
|
+
.gsub(">", ">")
|
347
|
+
.gsub("\n", " ")
|
348
|
+
.gsub("\r", " ")
|
349
|
+
.gsub("\t", "	")
|
350
|
+
end
|
351
|
+
|
352
|
+
def add_parser_error_overlay(parser_errors, input)
|
353
|
+
return unless parser_errors.any?
|
354
|
+
|
355
|
+
overlay_generator = ParserErrorOverlay.new(
|
356
|
+
input,
|
357
|
+
parser_errors,
|
358
|
+
filename: @relative_file_path
|
359
|
+
)
|
360
|
+
|
361
|
+
error_html = overlay_generator.generate_html
|
362
|
+
escaped_html = error_html.gsub("'", "\\'")
|
363
|
+
@validation_error_template = "<template data-herb-parser-error>#{escaped_html}</template>"
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
data/lib/herb/project.rb
CHANGED
@@ -12,7 +12,7 @@ require "stringio"
|
|
12
12
|
|
13
13
|
module Herb
|
14
14
|
class Project
|
15
|
-
attr_accessor :project_path, :output_file, :no_interactive, :no_log_file, :no_timing
|
15
|
+
attr_accessor :project_path, :output_file, :no_interactive, :no_log_file, :no_timing, :silent
|
16
16
|
|
17
17
|
def interactive?
|
18
18
|
return false if no_interactive
|
@@ -106,7 +106,7 @@ module Herb
|
|
106
106
|
else
|
107
107
|
relative_path = file_path.sub("#{project_path}/", "")
|
108
108
|
end
|
109
|
-
puts "Processing [#{index + 1}/#{files.count}]: #{relative_path}"
|
109
|
+
puts "Processing [#{index + 1}/#{files.count}]: #{relative_path}" unless silent
|
110
110
|
|
111
111
|
if interactive?
|
112
112
|
if failed_files.any?
|
@@ -240,7 +240,7 @@ module Herb
|
|
240
240
|
puts "Completed processing all files."
|
241
241
|
print "\e[H\e[2J"
|
242
242
|
else
|
243
|
-
puts "Completed processing all files."
|
243
|
+
puts "Completed processing all files." unless silent
|
244
244
|
end
|
245
245
|
|
246
246
|
log.puts ""
|
data/lib/herb/version.rb
CHANGED
data/lib/herb/visitor.rb
CHANGED
data/lib/herb.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative "herb/parse_result"
|
|
15
15
|
require_relative "herb/ast"
|
16
16
|
require_relative "herb/ast/node"
|
17
17
|
require_relative "herb/ast/nodes"
|
18
|
+
require_relative "herb/ast/helpers"
|
18
19
|
|
19
20
|
require_relative "herb/errors"
|
20
21
|
require_relative "herb/warnings"
|
@@ -25,6 +26,7 @@ require_relative "herb/project"
|
|
25
26
|
require_relative "herb/version"
|
26
27
|
|
27
28
|
require_relative "herb/visitor"
|
29
|
+
require_relative "herb/engine"
|
28
30
|
|
29
31
|
begin
|
30
32
|
major, minor, _patch = RUBY_VERSION.split(".") #: [String, String, String]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Generated from lib/herb/ast/helpers.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Herb
|
4
|
+
module AST
|
5
|
+
module Helpers
|
6
|
+
# : (Herb::AST::Node) -> bool
|
7
|
+
def erb_outputs?: (Herb::AST::Node) -> bool
|
8
|
+
|
9
|
+
# : (String) -> bool
|
10
|
+
def erb_comment?: (String) -> bool
|
11
|
+
|
12
|
+
# : (String) -> bool
|
13
|
+
def erb_output?: (String) -> bool
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/sig/herb/ast/nodes.rbs
CHANGED
@@ -127,8 +127,10 @@ module Herb
|
|
127
127
|
|
128
128
|
attr_reader is_void: bool
|
129
129
|
|
130
|
-
|
131
|
-
|
130
|
+
attr_reader source: String
|
131
|
+
|
132
|
+
# : (String, Location, Array[Herb::Errors::Error], Herb::AST::HTMLOpenTagNode, Herb::Token, Array[Herb::AST::Node], Herb::AST::HTMLCloseTagNode, bool, String) -> void
|
133
|
+
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::AST::HTMLOpenTagNode, Herb::Token, Array[Herb::AST::Node], Herb::AST::HTMLCloseTagNode, bool, String) -> void
|
132
134
|
|
133
135
|
# : () -> serialized_html_element_node
|
134
136
|
def to_hash: () -> serialized_html_element_node
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Generated from lib/herb/engine/compiler.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Herb
|
4
|
+
class Engine
|
5
|
+
class Compiler < ::Herb::Visitor
|
6
|
+
attr_reader tokens: untyped
|
7
|
+
|
8
|
+
def initialize: (untyped engine, ?untyped options) -> untyped
|
9
|
+
|
10
|
+
def generate_output: () -> untyped
|
11
|
+
|
12
|
+
def visit_document_node: (untyped node) -> untyped
|
13
|
+
|
14
|
+
def visit_html_element_node: (untyped node) -> untyped
|
15
|
+
|
16
|
+
def visit_html_open_tag_node: (untyped node) -> untyped
|
17
|
+
|
18
|
+
def visit_html_attribute_node: (untyped node) -> untyped
|
19
|
+
|
20
|
+
def visit_html_attribute_name_node: (untyped node) -> untyped
|
21
|
+
|
22
|
+
def visit_html_attribute_value_node: (untyped node) -> untyped
|
23
|
+
|
24
|
+
def visit_html_close_tag_node: (untyped node) -> untyped
|
25
|
+
|
26
|
+
def visit_html_text_node: (untyped node) -> untyped
|
27
|
+
|
28
|
+
def visit_literal_node: (untyped node) -> untyped
|
29
|
+
|
30
|
+
def visit_whitespace_node: (untyped node) -> untyped
|
31
|
+
|
32
|
+
def visit_html_comment_node: (untyped node) -> untyped
|
33
|
+
|
34
|
+
def visit_html_doctype_node: (untyped node) -> untyped
|
35
|
+
|
36
|
+
def visit_xml_declaration_node: (untyped node) -> untyped
|
37
|
+
|
38
|
+
def visit_cdata_node: (untyped node) -> untyped
|
39
|
+
|
40
|
+
def visit_erb_content_node: (untyped node) -> untyped
|
41
|
+
|
42
|
+
def visit_erb_control_node: (untyped node) ?{ (?) -> untyped } -> untyped
|
43
|
+
|
44
|
+
def visit_erb_if_node: (untyped node) -> untyped
|
45
|
+
|
46
|
+
def visit_erb_else_node: (untyped node) -> untyped
|
47
|
+
|
48
|
+
def visit_erb_unless_node: (untyped node) -> untyped
|
49
|
+
|
50
|
+
def visit_erb_case_node: (untyped node) -> untyped
|
51
|
+
|
52
|
+
def visit_erb_when_node: (untyped node) -> untyped
|
53
|
+
|
54
|
+
def visit_erb_for_node: (untyped node) -> untyped
|
55
|
+
|
56
|
+
def visit_erb_while_node: (untyped node) -> untyped
|
57
|
+
|
58
|
+
def visit_erb_until_node: (untyped node) -> untyped
|
59
|
+
|
60
|
+
def visit_erb_begin_node: (untyped node) -> untyped
|
61
|
+
|
62
|
+
def visit_erb_rescue_node: (untyped node) -> untyped
|
63
|
+
|
64
|
+
def visit_erb_ensure_node: (untyped node) -> untyped
|
65
|
+
|
66
|
+
def visit_erb_end_node: (untyped node) -> untyped
|
67
|
+
|
68
|
+
def visit_erb_case_match_node: (untyped node) -> untyped
|
69
|
+
|
70
|
+
def visit_erb_in_node: (untyped node) -> untyped
|
71
|
+
|
72
|
+
def visit_erb_yield_node: (untyped node) -> untyped
|
73
|
+
|
74
|
+
def visit_erb_block_node: (untyped node) -> untyped
|
75
|
+
|
76
|
+
def visit_erb_control_with_parts: (untyped node, *untyped parts) -> untyped
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def current_context: () -> untyped
|
81
|
+
|
82
|
+
def push_context: (untyped context) -> untyped
|
83
|
+
|
84
|
+
def pop_context: () -> untyped
|
85
|
+
|
86
|
+
def add_context_aware_expression: (untyped code, untyped context) -> untyped
|
87
|
+
|
88
|
+
def process_erb_tag: (untyped node, ?skip_comment_check: untyped) -> untyped
|
89
|
+
|
90
|
+
def add_text: (untyped text) -> untyped
|
91
|
+
|
92
|
+
def add_code: (untyped code) -> untyped
|
93
|
+
|
94
|
+
def add_expression: (untyped code) -> untyped
|
95
|
+
|
96
|
+
def add_expression_escaped: (untyped code) -> untyped
|
97
|
+
|
98
|
+
def optimize_tokens: (untyped tokens) -> untyped
|
99
|
+
|
100
|
+
def process_erb_output: (untyped opening, untyped code) -> untyped
|
101
|
+
|
102
|
+
def should_escape_output?: (untyped opening) -> untyped
|
103
|
+
|
104
|
+
def add_expression_with_escaping: (untyped code, untyped should_escape) -> untyped
|
105
|
+
|
106
|
+
def handle_whitespace_trimming: (untyped node) -> untyped
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Generated from lib/herb/engine/debug.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Herb
|
4
|
+
class Engine
|
5
|
+
module Debug
|
6
|
+
private
|
7
|
+
|
8
|
+
def debug?: () -> untyped
|
9
|
+
|
10
|
+
def process_debuggable_expression: (untyped node, untyped opening, untyped code, untyped should_escape) -> untyped
|
11
|
+
|
12
|
+
def add_debug_expr_start: (untyped erb_code, untyped output_content, untyped node) -> untyped
|
13
|
+
|
14
|
+
def add_debug_expr_end: () -> untyped
|
15
|
+
|
16
|
+
def should_debug_expression?: (untyped node) -> untyped
|
17
|
+
|
18
|
+
def find_top_level_elements: (untyped document_node) -> untyped
|
19
|
+
|
20
|
+
def should_add_debug_attributes_to_element?: (untyped open_tag_node) -> untyped
|
21
|
+
|
22
|
+
def find_parent_element_for_open_tag: (untyped open_tag_node) -> untyped
|
23
|
+
|
24
|
+
def add_debug_attributes_to_element: (untyped open_tag_node) -> untyped
|
25
|
+
|
26
|
+
def determine_view_type: () -> untyped
|
27
|
+
|
28
|
+
def partial?: () -> untyped
|
29
|
+
|
30
|
+
def component?: () -> untyped
|
31
|
+
|
32
|
+
def in_head_context?: () -> untyped
|
33
|
+
|
34
|
+
# TODO: convert this to analyze the Prism nodes once available
|
35
|
+
def complex_rails_helper?: (untyped code) -> untyped
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated from lib/herb/engine/debug_visitor.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Herb
|
4
|
+
class Engine
|
5
|
+
class DebugVisitor < Herb::Visitor
|
6
|
+
def initialize: (untyped engine) -> untyped
|
7
|
+
|
8
|
+
def debug_enabled?: () -> untyped
|
9
|
+
|
10
|
+
def visit_document_node: (untyped node) -> untyped
|
11
|
+
|
12
|
+
def visit_html_element_node: (untyped node) -> untyped
|
13
|
+
|
14
|
+
def visit_html_attribute_node: (untyped node) -> untyped
|
15
|
+
|
16
|
+
def visit_html_comment_node: (untyped node) -> untyped
|
17
|
+
|
18
|
+
def visit_html_doctype_node: (untyped node) -> untyped
|
19
|
+
|
20
|
+
def visit_erb_content_node: (untyped node) -> untyped
|
21
|
+
|
22
|
+
def visit_erb_yield_node: (untyped _node) -> untyped
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def wrap_all_erb_nodes: (untyped node) -> untyped
|
27
|
+
|
28
|
+
# Creates a dummy location for AST nodes that don't need real location info
|
29
|
+
# : () -> Herb::Location
|
30
|
+
def dummy_location: () -> Herb::Location
|
31
|
+
|
32
|
+
# Creates a dummy range for tokens that don't need real range info
|
33
|
+
# : () -> Herb::Range
|
34
|
+
def dummy_range: () -> Herb::Range
|
35
|
+
|
36
|
+
def replace_erb_nodes_recursive: (untyped node) -> untyped
|
37
|
+
|
38
|
+
def find_top_level_elements: (untyped document_node) -> untyped
|
39
|
+
|
40
|
+
def should_add_debug_attributes_to_element?: (untyped open_tag_node) -> untyped
|
41
|
+
|
42
|
+
def find_parent_element_for_open_tag: (untyped open_tag_node) -> untyped
|
43
|
+
|
44
|
+
def add_debug_attributes_to_element: (untyped open_tag_node) -> untyped
|
45
|
+
|
46
|
+
def create_debug_attribute: (untyped name, untyped value) -> untyped
|
47
|
+
|
48
|
+
def create_token: (untyped type, untyped value) -> untyped
|
49
|
+
|
50
|
+
def create_debug_span_for_erb: (untyped erb_node) -> untyped
|
51
|
+
|
52
|
+
def determine_view_type: () -> untyped
|
53
|
+
|
54
|
+
def partial?: () -> untyped
|
55
|
+
|
56
|
+
def component?: () -> untyped
|
57
|
+
|
58
|
+
def in_head_context?: () -> untyped
|
59
|
+
|
60
|
+
def in_script_or_style_context?: () -> untyped
|
61
|
+
|
62
|
+
def in_excluded_context?: () -> untyped
|
63
|
+
|
64
|
+
def erb_output?: (untyped opening) -> untyped
|
65
|
+
|
66
|
+
# TODO: Rewrite using Prism Nodes once available
|
67
|
+
def complex_rails_helper?: (untyped code) -> untyped
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|