eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ParseTreeSourceRewriter':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ParseTreeSourceRewriter


Inheritance:

   Object
   |
   +--RBProgramNodeVisitor
      |
      +--ParseTreeSearcher
         |
         +--ParseTreeRewriter
            |
            +--ParseTreeSourceRewriter

Package:
stx:goodies/refactoryBrowser/parser
Category:
Refactory-ParseTree Matching
Version:
rev: 1.20 date: 2019/02/15 15:59:08
user: cg
file: ParseTreeSourceRewriter.st directory: goodies/refactoryBrowser/parser
module: stx stc-classLibrary: parser
Author:
Claus Gittinger

Description:


This is a parse tree rewriter which does NOT generate new code from scratch
(i.e. it does not generate its source by recursively walking along the formattedCode methods),
but instead inserts the new nodes code right into the original source code.
This has two advantages:
    it does not destroy the user's formatting, indentation etc.
    it does not forget comments.
I added this, because I constantly got mad at the rewriter reformatting my code for every tiny
little variable rewrite operation.

Caveats: 
    needs more intelligence when rewriting non-trivial code, such as keyword message sends.
    For now, it seems to only behave reasonable for very simple stuff, such as replacing a variable
    by another or by a simple unary send.


Related information:

    ParseTreeRewriter

Instance protocol:

accessing
o  addReplacement: aReplacement

o  alwaysPerformAllSearches
please read the comment in the inherited alwaysPerformAllSearches

o  alwaysPerformAllSearches: aBoolean
please read the comment in the inherited alwaysPerformAllSearches

o  executeTree: aParseTree
Performs rewrites on given tree

o  forgetReplacements

o  replacements

queries
o  isRewritingOriginalSource

replacing
o  executeReplacementsInSource: aSourceString
execute all replacements in a sourceString.
Invoked after we have collected all replacements.

o  replaceLiteral: oldLiteral with: newLiteral

o  replaceLiteral: oldLiteral with: newLiteral when: condition

o  replaceVariable: variable with: newVariable
Transcript showCR:'replacing variable ',variable,' by ',newVariable.


Private classes:

    NodesOverlapError


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Sat, 20 Apr 2024 04:20:33 GMT