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.19 date: 2018/04/16 11:25:58
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.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 12 Dec 2018 22:02:04 GMT