eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ParseTreeRewriter':

Home

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

Class: ParseTreeRewriter


Inheritance:

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

Package:
stx:goodies/refactoryBrowser/parser
Category:
Refactory-ParseTree Matching
Version:
rev: 1.38 date: 2023/04/13 09:19:02
user: cg
file: ParseTreeRewriter.st directory: goodies/refactoryBrowser/parser
module: stx stc-classLibrary: parser

Description:


ParseTreeRewriter walks over and transforms its BRProgramNode (tree). If the tree is modified, then answer is set to true, and the modified tree can be retrieved by the #tree method.

Instance Variables:
	tree    <BRProgramNode> the parse tree we're transforming


Class protocol:

accessing
o  replace: code with: newCode in: aParseTree

o  replace: code with: newCode in: aParseTree onInterval: anInterval

o  replaceStatements: code with: newCode in: aParseTree onInterval: anInterval

instance creation
o  classVariable: aVarName getter: getMethod setter: setMethod

o  new
A small hack to use ParseTreeSourceRewriter if all refactorings. should not harm...

Usage example(s):

        ParseTreeRewriter new.
        UserPreferences current at: #useParseTreeSourceRewriterForAllRewrites put: false.
        UserPreferences current at: #useParseTreeSourceRewriterForAllRewrites put: true

o  removeTemporaryNamed: aName

o  rename: varName to: newVarName

o  rename: varName to: newVarName handler: aBlock
A rewriter to rename varName to newVarName, evaluating aBlock if there is a
temporary variable with the same name as newVarName.
aBlock may be a zero-arg block, or one accepting the matching node as arg.
This does not change temporary variables with varName.

o  replace: code with: newCode method: aBoolean

o  replaceLiteral: literal with: newLiteral
duplicate code.

o  valueHolderForVariable: aVarName holderMethod: aSelector

o  variable: aVarName getter: getMethod setter: setMethod

o  variable: aVarName getter: getMethod setter: setMethod receiver: aString

private
o  replaceLiteral: literal with: newLiteral inToken: literalToken
if literalToken's value is literal, replace it by newLiteral and return true.
otherwise, return false


Instance protocol:

accessing
o  executeTree: aParseTree
(comment from inherited method)
Save our current context, in case someone is performing another search inside a match.
Notice: kept for backward compatibility;
cannot forward this to executeTree:in: here, because not everyone (SmallLint and others)
are guaranteed to implement it (but instead redefine executeTree:).

o  executeTree: aParseTree in: optionalClassBeingProcessed
(comment from inherited method)
Save our current context, in case someone is performing another search inside a match.

o  forgetReplacements
Nothing to do here, to be polymorph with ParseTreeSourceRewriter

o  replacements
Nothing returned here, to be polymorph with ParseTreeSourceRewriter

o  tree

converting
o  asSearcher

obsolete
o  buildMethodParseTreeRuleFor: aReplaceCondition

o  buildParseTreeRuleFor: aReplaceCondition

private
o  foundMatch

o  lookForMoreMatchesInContext: oldContext

queries
o  isRewritingOriginalSource

replacing
o  replace: searchString with: replaceString

o  replace: searchString with: replaceString keepComments: keepComments
if keepComments is true, comments in the replaceString will be handled

o  replace: searchString with: replaceString thenDo: actionOnReplacedNode

o  replace: searchString with: replaceString when: aBlock

o  replace: searchString withValueFrom: replaceBlock

o  replace: searchString withValueFrom: replaceBlock when: conditionBlock

o  replaceArgument: searchString with: replaceString

o  replaceArgument: searchString with: replaceString when: aBlock

o  replaceArgument: searchString withValueFrom: replaceBlock

o  replaceArgument: searchString withValueFrom: replaceBlock when: conditionBlock

o  replaceLiteral: literal with: newLiteral

o  replaceMethod: searchString with: replaceString

o  replaceMethod: searchString with: replaceString when: aBlock

o  replaceMethod: searchString withValueFrom: replaceBlock

o  replaceMethod: searchString withValueFrom: replaceBlock when: conditionBlock

o  replaceTree: searchTree withTree: replaceTree

o  replaceTree: searchTree withTree: replaceTree when: aBlock

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

visiting
o  visitArguments: aNodeCollection
(comment from inherited method)
returns aNodeCollection (actually: whatever its do: method returns)
(not sure if it must do so, or if it is sloppy programming)

visitor-double dispatching
o  acceptAssignmentNode: anAssignmentNode

o  acceptBlockNode: aBlockNode

o  acceptCascadeNode: aCascadeNode

o  acceptMessageNode: aMessageNode

o  acceptMethodNode: aMethodNode

o  acceptOptimizedNode: anOptimizedNode

o  acceptReturnNode: aReturnNode

o  acceptSequenceNode: aSequenceNode



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Tue, 03 Dec 2024 17:18:34 GMT