Skip to content

Commit

Permalink
simple formating.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse authored and balsa-sarenac committed Apr 26, 2024
1 parent 63eea48 commit 1b9f11c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/AST-Core/RBParseTreeSearcher.class.st
Expand Up @@ -145,7 +145,7 @@ RBParseTreeSearcher class >> setterMethod: aVarName [

{ #category : 'accessing' }
RBParseTreeSearcher class >> treeMatching: aString in: aParseTree [
(self new)
self new
matches: aString do: [:aNode :answer | ^aNode];
executeTree: aParseTree.
^nil
Expand Down
Expand Up @@ -165,10 +165,9 @@ RBExtractMethodTransformation >> calculateArguments [
"returns a collection of variables that should be passed as arguments"

| allVariables accesses assigned |

subtree ifNil: [ ^ nil ].

allVariables := parseTree allDefinedVariables difference: subtree allDefinedVariables.
allVariables := self sourceMethodTree allDefinedVariables difference: subtree allDefinedVariables.

accesses := allVariables select: [ :each | subtree references: each ].
assigned := allVariables select: [ :each | subtree assigns: each ].
Expand All @@ -188,7 +187,7 @@ RBExtractMethodTransformation >> calculateAssignments [

^ assignments ifNil: [
| sequenceNode whoDefinesTemp |
sequenceNode := (parseTree allChildren select: [ :each | each isSequence ]) last.
sequenceNode := (self sourceMethodTree allChildren select: [ :each | each isSequence ]) last.

assignments := temporaries select: [ :temp |
whoDefinesTemp := (sequenceNode whoDefines: temp).
Expand Down Expand Up @@ -229,7 +228,7 @@ RBExtractMethodTransformation >> calculateNewArgumentsIn: aMethodName [
RBExtractMethodTransformation >> calculateSubtree [

^ subtree ifNil: [
subtree := self sourceMethodTree ifNotNil: [ parseTree extractSubtreeWith: sourceCode ] ]
subtree := self sourceMethodTree ifNotNil: [ :t | t extractSubtreeWith: sourceCode ] ]
]

{ #category : 'querying' }
Expand All @@ -246,7 +245,7 @@ RBExtractMethodTransformation >> calculateTemporaries [

^ temporaries ifNil: [
| allVariables accesses |
allVariables := parseTree allDefinedVariables difference: subtree allDefinedVariables.
allVariables := self sourceMethodTree allDefinedVariables difference: subtree allDefinedVariables.
accesses := allVariables select: [ :each | subtree references: each ].

temporaries := accesses select: [ :each | subtree assigns: each ] ]
Expand All @@ -270,21 +269,11 @@ RBExtractMethodTransformation >> extract: aString from: aSelector in: aClass [

{ #category : 'api' }
RBExtractMethodTransformation >> extract: aString from: aSelector to: aNewSelector in: aClassName [

class := self model classNamed: aClassName.
selector := aSelector.
newSelector := aNewSelector.
sourceCode := aString
]

{ #category : 'api' }
RBExtractMethodTransformation >> extractSource: aString fromMethodSource: source to: aNewSelector in: aClassName [

class := self model classNamed: aClassName.
parseTree := RBParser parseMethod: source.
selector := parseTree selector.
"partial instantiation."

self extract: aString from: aSelector in: aClassName.
newSelector := aNewSelector.
sourceCode := aString

]

{ #category : 'preconditions' }
Expand Down Expand Up @@ -490,7 +479,7 @@ RBExtractMethodTransformation >> preconditionOneAssignmentMaximum [
RBExtractMethodTransformation >> preconditionParsableSubtree [

^ RBCondition
withBlock: [ parseTree isNotNil & subtree isNotNil ]
withBlock: [ self sourceMethodTree isNotNil & subtree isNotNil ]
errorString: 'Cannot extract selected code, it is not a valid subtree.'
]

Expand Down

0 comments on commit 1b9f11c

Please sign in to comment.