93 lines
1.7 KiB
Smalltalk
93 lines
1.7 KiB
Smalltalk
Class {
|
|
#name : 'PPCMDelegateNode',
|
|
#superclass : 'PPCMNode',
|
|
#instVars : [
|
|
'children'
|
|
],
|
|
#category : 'PetitMarkdown-AST'
|
|
}
|
|
|
|
{ #category : 'visiting' }
|
|
PPCMDelegateNode >> accept: visitor [
|
|
^ visitor visitDelegate: self
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> addChild: node [
|
|
self assert: node isCommonMarkNode.
|
|
|
|
self children add: node.
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> addChildFirst: node [
|
|
self assert: node isCommonMarkNode.
|
|
|
|
self children addFirst: node.
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> addChildren: nodes [
|
|
nodes do: [ :node | self addChild: node ]
|
|
]
|
|
|
|
{ #category : 'enumerating' }
|
|
PPCMDelegateNode >> allChildren [
|
|
| retval |
|
|
retval := OrderedCollection new.
|
|
self children do: [ :child | retval addAll: child allChildren ].
|
|
^ retval
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> child [
|
|
self assert: children size = 1.
|
|
^ children first
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> child: whatever [
|
|
children at: 1 put: whatever
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> children [
|
|
^ children
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> children: whatever [
|
|
children := whatever
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> firstChild [
|
|
^ children at: 1
|
|
]
|
|
|
|
{ #category : 'initialization' }
|
|
PPCMDelegateNode >> initialize [
|
|
children := OrderedCollection new
|
|
]
|
|
|
|
{ #category : 'replacing' }
|
|
PPCMDelegateNode >> replace: child with: anotherChild [
|
|
children doWithIndex: [ :ch :index |
|
|
(ch == child) ifTrue: [
|
|
children at: index put: anotherChild .
|
|
^ true
|
|
]
|
|
].
|
|
^ false
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> secondChild [
|
|
^ children at: 2
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCMDelegateNode >> thirdChild [
|
|
^ children at: 3
|
|
]
|