87 lines
2.2 KiB
Smalltalk
87 lines
2.2 KiB
Smalltalk
Class {
|
|
#name : #GrafoscopioPillarTextAnnotator,
|
|
#superclass : #PRVisitor,
|
|
#instVars : [
|
|
'texts',
|
|
'lastStop',
|
|
'stack'
|
|
],
|
|
#category : #'Grafoscopio-Pillar'
|
|
}
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> initialize [
|
|
super initialize.
|
|
texts := OrderedCollection new
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> populateParentsOf: aSetOfParents [
|
|
|
|
| parents |
|
|
parents := Set new.
|
|
aSetOfParents do: [ : n |
|
|
parents add: n parent.
|
|
n parent propertyAt: #textStart ifAbsent: [
|
|
n parent propertyAt: #textStart put: (n parent children first propertyAt: #textStart).
|
|
n parent propertyAt: #textStop put: (n parent children last propertyAt: #textStop).
|
|
]
|
|
].
|
|
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitCodeblock: aTextObject [
|
|
self visitText: aTextObject
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitCommentedLine: aTextObject [
|
|
self visitText: aTextObject
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitDocument: aDoc [
|
|
lastStop := 1 .
|
|
super visitDocument: aDoc.
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitDocumentGroup: aGroup [
|
|
super visitDocumentGroup: aGroup.
|
|
"aGroup
|
|
propertyAt: #textStart
|
|
ifAbsent: [
|
|
aGroup hasChildren
|
|
ifTrue: [ aGroup
|
|
propertyAt: #textStart
|
|
put: (aGroup children first propertyAt: #textStart).
|
|
aGroup
|
|
propertyAt: #textStop
|
|
put: (aGroup children last propertyAt: #textStop) ]
|
|
ifFalse: [
|
|
aGroup propertyAt: #textStart put: 0 .
|
|
aGroup propertyAt: #textStop put: 0
|
|
]
|
|
]"
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitLineBreak: anObject [
|
|
^ self visitText: anObject
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitRaw: aTextObject [
|
|
self visitText: aTextObject
|
|
]
|
|
|
|
{ #category : #'visiting-document' }
|
|
GrafoscopioPillarTextAnnotator >> visitText: aTextObject [
|
|
texts add: aTextObject.
|
|
aTextObject propertyAt: #textStart put: lastStop.
|
|
aTextObject propertyAt: #textStop put: lastStop + aTextObject text size - 1.
|
|
lastStop := lastStop + aTextObject text size.
|
|
|
|
]
|