|
Class: ParseTreeRewriter
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
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
accessing
-
replace: code with: newCode in: aParseTree
-
-
replace: code with: newCode in: aParseTree onInterval: anInterval
-
-
replaceStatements: code with: newCode in: aParseTree onInterval: anInterval
-
instance creation
-
classVariable: aVarName getter: getMethod setter: setMethod
-
-
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
|
-
removeTemporaryNamed: aName
-
-
rename: varName to: newVarName
-
-
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.
-
replace: code with: newCode method: aBoolean
-
-
replaceLiteral: literal with: newLiteral
-
duplicate code.
-
valueHolderForVariable: aVarName holderMethod: aSelector
-
-
variable: aVarName getter: getMethod setter: setMethod
-
-
variable: aVarName getter: getMethod setter: setMethod receiver: aString
-
private
-
replaceLiteral: literal with: newLiteral inToken: literalToken
-
if literalToken's value is literal, replace it by newLiteral and return true.
otherwise, return false
accessing
-
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:).
-
executeTree: aParseTree in: optionalClassBeingProcessed
-
(comment from inherited method)
Save our current context, in case someone is performing another search inside a match.
-
forgetReplacements
-
Nothing to do here, to be polymorph with ParseTreeSourceRewriter
-
replacements
-
Nothing returned here, to be polymorph with ParseTreeSourceRewriter
-
tree
-
converting
-
asSearcher
-
obsolete
-
buildMethodParseTreeRuleFor: aReplaceCondition
-
-
buildParseTreeRuleFor: aReplaceCondition
-
private
-
foundMatch
-
-
lookForMoreMatchesInContext: oldContext
-
queries
-
isRewritingOriginalSource
-
replacing
-
replace: searchString with: replaceString
-
-
replace: searchString with: replaceString keepComments: keepComments
-
if keepComments is true, comments in the replaceString will be handled
-
replace: searchString with: replaceString thenDo: actionOnReplacedNode
-
-
replace: searchString with: replaceString when: aBlock
-
-
replace: searchString withValueFrom: replaceBlock
-
-
replace: searchString withValueFrom: replaceBlock when: conditionBlock
-
-
replaceArgument: searchString with: replaceString
-
-
replaceArgument: searchString with: replaceString when: aBlock
-
-
replaceArgument: searchString withValueFrom: replaceBlock
-
-
replaceArgument: searchString withValueFrom: replaceBlock when: conditionBlock
-
-
replaceLiteral: literal with: newLiteral
-
-
replaceMethod: searchString with: replaceString
-
-
replaceMethod: searchString with: replaceString when: aBlock
-
-
replaceMethod: searchString withValueFrom: replaceBlock
-
-
replaceMethod: searchString withValueFrom: replaceBlock when: conditionBlock
-
-
replaceTree: searchTree withTree: replaceTree
-
-
replaceTree: searchTree withTree: replaceTree when: aBlock
-
-
replaceVariable: variable with: newVariable
-
Transcript showCR:'replacing variable ',variable,' by ',newVariable.
visiting
-
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
-
acceptAssignmentNode: anAssignmentNode
-
-
acceptBlockNode: aBlockNode
-
-
acceptCascadeNode: aCascadeNode
-
-
acceptMessageNode: aMessageNode
-
-
acceptMethodNode: aMethodNode
-
-
acceptOptimizedNode: anOptimizedNode
-
-
acceptReturnNode: aReturnNode
-
-
acceptSequenceNode: aSequenceNode
-
|