There are three main phases in the algorithm:
Sanitize/format input source
Search for invalid blocks
Format invalid blocks into something meaninful
The Code frontier is a critical part of the second step
## Knowing where we’ve been
Once a code block is generated it is added onto the frontier. Then it will be sorted by indentation and frontier can be filtered. Large blocks that fully enclose a smaller block will cause the smaller block to be evicted.
CodeFrontier#<<(block) # Adds block to frontier CodeFrontier#pop # Removes block from frontier
## Knowing where we can go
Internally the frontier keeps track of “unvisited” lines which are exposed via ‘next_indent_line` when called, this method returns, a line of code with the highest indentation.
The returned line of code can be used to build a CodeBlock
and then that code block is added back to the frontier. Then, the lines are removed from the “unvisited” so we don’t double-create the same block.
CodeFrontier#next_indent_line # Shows next line CodeFrontier#register_indent_block(block) # Removes lines from unvisited
## Knowing when to stop
The frontier knows how to check the entire document for a syntax error. When blocks are added onto the frontier, they’re removed from the document. When all code containing syntax errors has been added to the frontier, the document will be parsable without a syntax error and the search can stop.
CodeFrontier#holds_all_syntax_errors? # Returns true when frontier holds all syntax errors
## Filtering false positives
Once the search is completed, the frontier may have multiple blocks that do not contain the syntax error. To limit the result to the smallest subset of “invalid blocks” call:
CodeFrontier#detect_invalid_blocks
Mixin module providing HTML generation methods.
For example,
cgi.a("http://www.example.com") { "Example" } # => "<A HREF=\"http://www.example.com\">Example</A>"
Modules Html3, Html4, etc., contain more basic HTML-generation methods (#title
, #h1
, etc.).
See class CGI
for a detailed example.
Flags for regular expression and match last line nodes.
Enumerator::Product
generates a Cartesian product of any number of enumerable objects. Iterating over the product of enumerable objects is roughly equivalent to nested each_entry loops where the loop for the rightmost object is put innermost.
innings = Enumerator::Product.new(1..9, ['top', 'bottom']) innings.each do |i, h| p [i, h] end # [1, "top"] # [1, "bottom"] # [2, "top"] # [2, "bottom"] # [3, "top"] # [3, "bottom"] # ... # [9, "top"] # [9, "bottom"]
The method used against each enumerable object is ‘each_entry` instead of `each` so that the product of N enumerable objects yields an array of exactly N elements in each iteration.
When no enumerator is given, it calls a given block once yielding an empty argument list.
This type of objects can be created by Enumerator.product
.
Response class for Multiple Choices
responses (status code 300).
The Multiple Choices
response indicates that the server offers multiple options for the resource from which the client may choose.
References:
Response class for Multiple Choices
responses (status code 300).
The Multiple Choices
response indicates that the server offers multiple options for the resource from which the client may choose.
References:
Represents the use of the ‘&&=` operator for assignment to an instance variable.
@target &&= value ^^^^^^^^^^^^^^^^^
Represents the use of the ‘||=` operator for assignment to an instance variable.
@target ||= value ^^^^^^^^^^^^^^^^^
Represents assigning to an instance variable using an operator that isn’t ‘=`.
@target += value ^^^^^^^^^^^^^^^^
Represents writing to an instance variable in a context that doesn’t have an explicit value.
@foo, @bar = baz ^^^^ ^^^^
Represents a write to a multi-target expression.
a, b, c = 1, 2, 3 ^^^^^^^^^^^^^^^^^
This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
# shareable_constant_value: literal C = { a: 1 } ^^^^^^^^^^^^
Represents the use of the ‘__ENCODING__` keyword.
__ENCODING__ ^^^^^^^^^^^^
Represents the use of the ‘unless` keyword, either in the block form or the modifier form.
bar unless foo ^^^^^^^^^^^^^^ unless foo then bar end ^^^^^^^^^^^^^^^^^^^^^^^
Find
mis-matched syntax based on lexical count
Used for detecting missing pairs of elements each keyword needs an end, each ‘{’ needs a ‘}’ etc.
Example:
left_right = LeftRightLexCount.new left_right.count_kw left_right.missing.first # => "end" left_right = LeftRightLexCount.new source = "{ a: b, c: d" # Note missing '}' LexAll.new(source: source).each do |lex| left_right.count_lex(lex) end left_right.missing.first # => "}"
Flags for shareable constant nodes.
Configuration options for dumping YAML
.
An optional node field represents a single child node in the syntax tree that may or may not be present. It resolves to either a Prism::Node
or nil in Ruby.
An InstalledSpecification
represents a gem that is already installed locally.
Cleared reference exception