pharo
pharo copied to clipboard
Handle invlid interval case in extract method
This method can fail when extractionInterval is invalid:
ReCompositeExtractMethodRefactoring >> getExtractedSource
| source |
source := class sourceCodeFor: selector.
source ifNil: [ self refactoringError: 'Invalid source' ].
((extractionInterval first between: 1 and: (self startLimit: source size))
and: [extractionInterval last between: 1 and: source size])
ifFalse: [self refactoringError: 'Invalid interval'].
^source copyFrom: extractionInterval first to: extractionInterval last
fix:
ReCompositeExtractMethodRefactoring >> getExtractedSource
| source |
source := class sourceCodeFor: selector.
source ifNil: [ self refactoringError: 'Invalid source' ].
((extractionInterval first between: 1 and: (self startLimit: source size))
and: [extractionInterval last between: 1 and: source size])
ifFalse: [self refactoringError: 'Invalid interval'].
(extractionInterval first > extractionInterval last)
ifTrue: [ self refactoringError: 'Invalid interval' ].
^source copyFrom: extractionInterval first to: extractionInterval last
Tx balsa.