Grafoscopio/src/Grafoscopio/GrafoscopioPillarRuns.class.st

81 lines
2.0 KiB
Smalltalk

Class {
#name : #GrafoscopioPillarRuns,
#superclass : #Object,
#instVars : [
'ast',
'lastBranch',
'lastAttributes',
'visitor'
],
#category : #'Grafoscopio-Pillar-Style'
}
{ #category : #accessing }
GrafoscopioPillarRuns >> ast: anAst [
ast := anAst.
visitor := GrafoscopioAttributeBranchVisitor new.
visitor text: ast
]
{ #category : #'basic api' }
GrafoscopioPillarRuns >> at: anIndex [
| newBranch |
anIndex > ast size
ifTrue: [ ^ Array empty ].
newBranch := ast detectFullBranchFor: anIndex.
newBranch = lastBranch
ifTrue: [ ^ lastAttributes ].
lastAttributes := self
calculateAttributesForBranch: newBranch
at: anIndex.
lastBranch := (newBranch
anySatisfy: [ :n | n isMemberOf: PRCodeblock ])
ifTrue: [ nil ]
ifFalse: [ newBranch ].
^ lastAttributes
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarRuns >> calculateAttributesForBranch: aCollection at: anIndex [
^ visitor analyzeBranch: aCollection at: anIndex.
]
{ #category : #'basic api' }
GrafoscopioPillarRuns >> isEmpty [
^ ast isNil or: [ ast isEmpty ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarRuns >> rangeOf: aTextURL startingAt: anInteger [
self assert: (aTextURL isKindOf: TextAction).
((self at: anInteger) contains: [ : a | (a isKindOf: TextAction)]) ifTrue: [
(ast extractStringFrom: anInteger to: (ast detectAstNodeFor: anInteger ) textStop) traceCr.
^ anInteger to: (ast detectAstNodeFor: anInteger ) textStop
].
^ 0 to: 0
]
{ #category : #'basic api' }
GrafoscopioPillarRuns >> reset [
lastAttributes := nil.
lastBranch := nil.
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarRuns >> runLengthFor: anInteger [
| node |
anInteger > ast size
ifTrue: [ ^ 0 ].
node := ast detectAstNodeFor: anInteger.
^ (node isKindOf: PRCodeblock)
ifTrue: [ 1 ]
ifFalse: [ node textStop - anInteger ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarRuns >> withStartStopAndValueDo: aBlockClosure [
thisContext sender asString traceCr.
'Should implement' traceCr.
]