--- a/Parser.st Mon Aug 04 21:31:07 2003 +0200
+++ b/Parser.st Wed Aug 13 14:24:15 2003 +0200
@@ -2432,7 +2432,7 @@
return #Error if there was no correction;
nil if there was one."
- |deleteSize localDefsStart localDefsStop|
+ |deleteSize localDefsStart localDefsStop newPos|
"
tell requestor (i.e. CodeView) about the change
@@ -2446,9 +2446,22 @@
which is needed, when we eventually install the new method
"
correctedSource := requestor currentSourceCode.
+
"/ update the current source position
- source := (ReadStream on:correctedSource)
- position1Based:(source position1Based - deleteSize).
+ source atEnd ifTrue:[
+ newPos := correctedSource size.
+ ] ifFalse:[
+ source position1Based >= stop ifTrue:[
+ newPos := source position1Based - deleteSize
+ ] ifFalse:[
+ source position1Based < start ifTrue:[
+ newPos := source position1Based
+ ] ifFalse:[
+ newPos := start
+ ].
+ ]
+ ].
+ source := (ReadStream on:correctedSource) position1Based:newPos.
localDefsStart := localVarDefPosition at:1.
localDefsStop := localVarDefPosition at:2.
@@ -2456,6 +2469,11 @@
localDefsStop <= start ifTrue:[^ self].
localDefsStart >= stop ifTrue:[^ self].
+ (localDefsStart >= start and:[localDefsStop <= stop]) ifTrue:[
+ localVarDefPosition := nil.
+ ^ self
+ ].
+
"/ must update
(start > localDefsStart and:[stop < localDefsStop]) ifTrue:[
localVarDefPosition at:2 put:(localDefsStop - (stop-start+1)).
@@ -2590,7 +2608,7 @@
trying to remove the whiteSpace around the removed variable also.
However, this seems to not always work correctly"
- |source startSearch pos pos2 nextChar varSlot|
+ |source startSearch pos pos2 nextChar varSlot p p2|
varSlot := methodVars detect:[:var | var name = varName].
methodVars removeIdentical:varSlot.
@@ -2673,6 +2691,28 @@
].
].
+ "/ if this was the last, remove empty var-declaration completely
+ ((source at:pos-1) == $|
+ and:[ (source at:pos2+1) == $| ]) ifTrue:[
+ pos := pos - 1.
+ pos2 := pos2 + 1.
+ "/ see if that gives us an empty line
+ p := pos.
+ p2 := pos2.
+
+ [(source at:p-1) == Character space] whileTrue:[ p := p - 1 ].
+ [(source at:p2+1) == Character space] whileTrue:[ p2 := p2 + 1 ].
+ ((source at:p-1) == Character cr and:[ (source at:p2+1) == Character cr]) ifTrue:[
+ pos := p-1.
+ pos2 := p2.
+ (((source at:pos-1) == Character cr) and:[((source at:pos-2) == Character cr)])
+ ifTrue:[ pos := pos - 1 ]
+ ifFalse:[
+ (((source at:pos2+1) == Character cr) and:[((source at:pos2+2) == Character cr)]) ifTrue:[
+ pos2 := pos2 + 1 ]].
+ ].
+ ].
+
self correctSourceByDeletingFrom:pos to:pos2.
^ self.
].
@@ -7444,7 +7484,7 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.403 2003-07-17 11:37:56 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.404 2003-08-13 12:24:15 cg Exp $'
! !
Parser initialize!