Class: Parser::Source::Rewriter Deprecated
- Extended by:
 - Deprecation
 
- Defined in:
 - sorbet/rbi/parser@3.3.8.0.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_posof the given range forinsert_before, and thebegin_posforinsert_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
      6285  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6285 def initialize(source_buffer); end  | 
  
Instance Method Details
#diagnostics ⇒ Diagnostic::Engine
source://parser//lib/parser/source/rewriter.rb#33
      6291  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6291 def diagnostics; end  | 
  
#insert_after(range, content) ⇒ Rewriter
Inserts new code after the given source range.
source://parser//lib/parser/source/rewriter.rb#131
      6303  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6303 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
      6323  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6323 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
      6335  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6335 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
      6355  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6355 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
      6365  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6365 def process; end  | 
  
#remove(range) ⇒ Rewriter
Removes the source range.
source://parser//lib/parser/source/rewriter.rb#67
      6376  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6376 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
      6388  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6388 def replace(range, content); end  | 
  
#source_buffer ⇒ Source::Buffer
source://parser//lib/parser/source/rewriter.rb#32
      6394  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6394 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
      6414  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6414 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
      6427  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 6427 def wrap(range, before, after); end  |