The Inbox: System-ct.1132.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: System-ct.1132.mcz

commits-2
Christoph Thiede uploaded a new version of System to project The Inbox:
http://source.squeak.org/inbox/System-ct.1132.mcz

==================== Summary ====================

Name: System-ct.1132
Author: ct
Time: 18 January 2020, 3:57:40.447813 pm
UUID: 252e88e7-b8dc-7048-9fb7-78bf5dc98138
Ancestors: System-cmm.1129

Fix & refactor ChangeSet >> #scanVersionsOf:class:meta:category:selector:

Bug was:
(Context changeRecordsAt: #methodClass) collect: #category as: Array
Output before: #(accessing accessing accessing)
Output after: #('accessing' 'debugger access' 'debugger access')

=============== Diff against System-cmm.1129 ===============

Item was changed:
  ----- Method: ChangeSet class>>scanVersionsOf:class:meta:category:selector: (in category 'scanning') -----
+ scanVersionsOf: method class: class meta: meta category: category selector: selector
+
+ | changeList cat position sourceFilesCopy file |
- scanVersionsOf: method class: class meta: meta category: cat selector: selector
- | position prevPos prevFileIndex preamble tokens sourceFilesCopy stamp changeList file |
  changeList := OrderedCollection new.
+ cat := category ifNil: [''].
  position := method filePosition.
+ sourceFilesCopy := SourceFiles collect: [:x |
+ x ifNotNil: [x readOnlyCopy]].
+ method fileIndex isZero ifTrue: [^ nil].
- sourceFilesCopy := SourceFiles collect:[:x | x ifNotNil:[x readOnlyCopy]].
- method fileIndex = 0 ifTrue: [^ nil].
  file := sourceFilesCopy at: method fileIndex.
+ [position notNil and: [file notNil]] whileTrue: [
+ | preamble prevFileIndex prevPos stamp tokens |
- [position notNil & file notNil] whileTrue:[
  preamble := method getPreambleFrom: file at: (0 max: position - 3).
+ "Preamble is likely a linked method preamble, if we're in a changes file (not the sources file).
+ Try to parse it for prior source position and file index."
- "Preamble is likely a linked method preamble, if we're in
- a changes file (not the sources file).  Try to parse it
- for prior source position and file index"
  prevPos := nil.
  stamp := ''.
+ tokens := (preamble findString: 'methodsFor:' startingAt: 1) > 0
+ ifTrue: [[Scanner new scanTokens: preamble] ifError: [#()]]
+ ifFalse: [#() "ie cant be back ref"].
- (preamble findString: 'methodsFor:' startingAt: 1) > 0
- ifTrue: [tokens := [Scanner new scanTokens: preamble] on: Error do:[#()]]
- ifFalse: [tokens := Array new  "ie cant be back ref"].
  ((tokens size between: 7 and: 8)
+ and: [(tokens at: tokens size - 5) = #methodsFor:])
+ ifTrue: [
+ (tokens at: tokens size - 3) = #stamp:
+ ifTrue: [ "New format gives change stamp and unified prior pointer"
+ stamp := tokens at: tokens size - 2.
+ prevPos := tokens last.
+ prevFileIndex := sourceFilesCopy fileIndexFromSourcePointer: prevPos.
+ prevPos := sourceFilesCopy filePositionFromSourcePointer: prevPos]
+ ifFalse: [ "Old format gives no stamp; prior pointer in two parts"
+ prevPos := tokens at: tokens size - 2.
+ prevFileIndex := tokens last].
+ cat := tokens at: tokens size - 4.
+ (prevPos = 0 or: [prevFileIndex = 0]) ifTrue: [prevPos := nil]].
- and: [(tokens at: tokens size-5) = #methodsFor:]) ifTrue:[
- (tokens at: tokens size-3) = #stamp: ifTrue:[
- "New format gives change stamp and unified prior pointer"
- stamp := tokens at: tokens size-2.
- prevPos := tokens last.
- prevFileIndex := sourceFilesCopy fileIndexFromSourcePointer: prevPos.
- prevPos := sourceFilesCopy filePositionFromSourcePointer: prevPos.
- ] ifFalse: ["Old format gives no stamp; prior pointer in two parts"
- prevPos := tokens at: tokens size-2.
- prevFileIndex := tokens last.
- ].
- (prevPos = 0 or: [prevFileIndex = 0]) ifTrue: [prevPos := nil]
- ].
  ((tokens size between: 5 and: 6)
+ and: [(tokens at: tokens size - 3) = #methodsFor:])
+ ifTrue: [
+ (tokens at: tokens size - 1) = #stamp:
+ ifTrue: [ "New format gives change stamp and unified prior pointer"
+ stamp := tokens at: tokens size].
+ cat := tokens at: tokens size - 2].
+   changeList add: (ChangeRecord new
+ file: file position: position type: #method
+ class: class name category: cat meta: meta stamp: stamp).
- and: [(tokens at: tokens size-3) = #methodsFor:]) ifTrue:[
- (tokens at: tokens size-1) = #stamp: ifTrue: [
- "New format gives change stamp and unified prior pointer"
- stamp := tokens at: tokens size.
- ]
- ].
-   changeList add: (ChangeRecord new file: file position: position type: #method
- class: class name category: cat meta: meta stamp: stamp).
  position := prevPos.
+ prevPos ifNotNil: [file := sourceFilesCopy at: prevFileIndex]].
+ sourceFilesCopy do: [:x | x ifNotNil: [x close]]. self flag: #ct "ensure?".
+ ^ changeList!
- prevPos notNil ifTrue:[file := sourceFilesCopy at: prevFileIndex].
- ].
- sourceFilesCopy do: [:x | x ifNotNil:[x close]].
- ^changeList!