Skip to content

Commit

Permalink
Merge pull request #102 from jecisc/93-Remove-nil-assignment-can-fail…
Browse files Browse the repository at this point in the history
…-in-case-of-assignment-in-an-assignment

93-Remove-nil-assignment-can-fail-in-case-of-assignment-in-an-assignment
  • Loading branch information
jecisc committed May 10, 2020
2 parents 23282e1 + a92f907 commit 1472ea8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,20 @@ ChanelNilAssignationInInitializeCleanerTest >> testRemoveNilAssigmentsAroundReal
super initialize.
notTest := 1'
]

{ #category : #tests }
ChanelNilAssignationInInitializeCleanerTest >> testRemoveNilChainedAssigments [
class
compile:
'initialize
super initialize.
test := test2 := test3 := test4 := nil'.

self runCleaner.

self
assert: (class >> #initialize) sourceCode
equals:
'initialize
super initialize'
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ ChanelNilAssignationInInitializeCleaner >> clean [
self configuration localMethods iterator
| [ :method | method selector = #initialize ] selectIt
| [ :method | method ast nilAssignmentNodes isNotEmpty ] selectIt
| [ :method | method ast nilAssignmentNodes do: #removeFromTree ] doIt
| [ :method | method ast nilAssignmentNodes do: #removeAssignations ] doIt
> #installAST doIt
]
9 changes: 9 additions & 0 deletions src/Chanel/RBAssignmentNode.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ Extension { #name : #RBAssignmentNode }
RBAssignmentNode >> canHaveUselessChildren [
^ false
]

{ #category : #'*Chanel' }
RBAssignmentNode >> removeAssignations [
"In case the assignation is in an assignation, we want to remove the parent aswel."

self parent isAssignment
ifTrue: [ self parent removeAssignations ]
ifFalse: [ self removeFromTree ]
]

0 comments on commit 1472ea8

Please sign in to comment.