Class: Parser::Source::Rewriter Deprecated
- Extended by:
- Deprecation
- Defined in:
- sorbet/rbi/parser@3.3.7.4.rbi
Overview
Use TreeRewriter
Rewriter is deprecated. Use TreeRewriter instead.
TreeRewriter has simplified semantics, and customizable policies with regards to clobbering. Please read the documentation.
Keep in mind:
- Rewriter was discarding the
end_pos
of the given range forinsert_before
, and thebegin_pos
forinsert_after
. These are meaningful in TreeRewriter. - TreeRewriter's wrap/insert_before/insert_after are multiple by default, while Rewriter would raise clobbering errors if the non '_multi' version was called.
- The TreeRewriter policy closest to Rewriter's behavior is: different_replacements: :raise, swallowed_insertions: :raise, crossing_deletions: :accept
source://parser//lib/parser/source/rewriter.rb#31
Defined Under Namespace
Classes: Action
Constant Summary collapse
- DEPRECATION_WARNING =
source://parser//lib/parser/source/rewriter.rb#504
T.let(T.unsafe(nil), String)
Instance Method Summary collapse
-
#diagnostics ⇒ Diagnostic::Engine
source://parser//lib/parser/source/rewriter.rb#33.
-
#initialize(source_buffer) ⇒ Rewriter
constructor
deprecated
Deprecated.
Use TreeRewriter
- #insert_after(range, content) ⇒ Rewriter deprecated Deprecated.
- #insert_after_multi(range, content) ⇒ Rewriter deprecated Deprecated.
- #insert_before(range, content) ⇒ Rewriter deprecated Deprecated.
- #insert_before_multi(range, content) ⇒ Rewriter deprecated Deprecated.
- #process ⇒ String deprecated Deprecated.
- #remove(range) ⇒ Rewriter deprecated Deprecated.
- #replace(range, content) ⇒ Rewriter deprecated Deprecated.
-
#source_buffer ⇒ Source::Buffer
source://parser//lib/parser/source/rewriter.rb#32.
- #transaction ⇒ Object deprecated Deprecated.
- #wrap(range, before, after) ⇒ Rewriter deprecated Deprecated.
Methods included from Deprecation
warn_of_deprecation, warned_of_deprecation=
Constructor Details
#initialize(source_buffer) ⇒ Rewriter
Use TreeRewriter
source://parser//lib/parser/source/rewriter.rb#39
6279 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6279 def initialize(source_buffer); end |
Instance Method Details
#diagnostics ⇒ Diagnostic::Engine
source://parser//lib/parser/source/rewriter.rb#33
6285 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6285 def diagnostics; end |
#insert_after(range, content) ⇒ Rewriter
Inserts new code after the given source range.
source://parser//lib/parser/source/rewriter.rb#131
6297 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6297 def insert_after(range, content); end |
#insert_after_multi(range, content) ⇒ Rewriter
Inserts new code after the given source range by allowing other insertions at the same position. Note that an insertion with latter invocation comes after earlier insertion at the same position in the rewritten source.
source://parser//lib/parser/source/rewriter.rb#153
6317 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6317 def insert_after_multi(range, content); end |
#insert_before(range, content) ⇒ Rewriter
Inserts new code before the given source range.
source://parser//lib/parser/source/rewriter.rb#80
6329 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6329 def insert_before(range, content); end |
#insert_before_multi(range, content) ⇒ Rewriter
Inserts new code before the given source range by allowing other insertions at the same position. Note that an insertion with latter invocation comes before earlier insertion at the same position in the rewritten source.
source://parser//lib/parser/source/rewriter.rb#117
6349 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6349 def insert_before_multi(range, content); end |
#process ⇒ String
Applies all scheduled changes to the source_buffer
and returns
modified source as a new string.
source://parser//lib/parser/source/rewriter.rb#178
6359 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6359 def process; end |
#remove(range) ⇒ Rewriter
Removes the source range.
source://parser//lib/parser/source/rewriter.rb#67
6370 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6370 def remove(range); end |
#replace(range, content) ⇒ Rewriter
Replaces the code of the source range range
with content
.
source://parser//lib/parser/source/rewriter.rb#167
6382 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6382 def replace(range, content); end |
#source_buffer ⇒ Source::Buffer
source://parser//lib/parser/source/rewriter.rb#32
6388 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6388 def source_buffer; end |
#transaction ⇒ Object
Provides a protected block where a sequence of multiple rewrite actions are handled atomically. If any of the actions failed by clobbering, all the actions are rolled back.
source://parser//lib/parser/source/rewriter.rb#216
6408 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6408 def transaction; end |
#wrap(range, before, after) ⇒ Rewriter
Inserts new code before and after the given source range.
source://parser//lib/parser/source/rewriter.rb#94
6421 |
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6421 def wrap(range, before, after); end |