|
| 1 | +/** |
| 2 | + * @file Fixtures - postorder |
| 3 | + * @module fixtures/postorder |
| 4 | + */ |
| 5 | + |
| 6 | +import type { VisitedType } from '#tests/types' |
| 7 | +import type { EmptyArray } from '@flex-development/tutils' |
| 8 | + |
| 9 | +/** |
| 10 | + * Object containing node types visited during postorder traversal. |
| 11 | + */ |
| 12 | +type Postorder = { |
| 13 | + /** |
| 14 | + * Ancestor node types visited during postorder traversal. |
| 15 | + * |
| 16 | + * @see {@linkcode VisitedType} |
| 17 | + */ |
| 18 | + ancestors: [...VisitedType[][], EmptyArray] |
| 19 | + |
| 20 | + /** |
| 21 | + * Parent node types visited during postorder traversal. |
| 22 | + */ |
| 23 | + parents: [...VisitedType[], undefined] |
| 24 | + |
| 25 | + /** |
| 26 | + * All node types visited during postorder traversal. |
| 27 | + * |
| 28 | + * @see {@linkcode VisitedType} |
| 29 | + */ |
| 30 | + types: [...Exclude<VisitedType, 'root'>[], 'root'] |
| 31 | + |
| 32 | + /** |
| 33 | + * All node types visited during reverse postorder traversal. |
| 34 | + * |
| 35 | + * @see {@linkcode VisitedType} |
| 36 | + */ |
| 37 | + typesReversed: [...Exclude<VisitedType, 'root'>[], 'root'] |
| 38 | +} |
| 39 | + |
| 40 | +/** |
| 41 | + * All node types visited during postorder traversal. |
| 42 | + * |
| 43 | + * @const {Postorder['types']} types |
| 44 | + */ |
| 45 | +const types: Postorder['types'] = [ |
| 46 | + 'text', |
| 47 | + 'blockTag', |
| 48 | + 'text', |
| 49 | + 'blockTag', |
| 50 | + 'text', |
| 51 | + 'blockTag', |
| 52 | + 'comment', |
| 53 | + 'text', // siblings skipped |
| 54 | + 'inlineCode', |
| 55 | + 'text', |
| 56 | + 'inlineCode', |
| 57 | + 'text', |
| 58 | + 'paragraph', |
| 59 | + 'description', |
| 60 | + 'code', |
| 61 | + 'blockTag', |
| 62 | + 'code', |
| 63 | + 'blockTag', |
| 64 | + 'typeExpression', |
| 65 | + 'text', |
| 66 | + 'blockTag', |
| 67 | + 'typeExpression', |
| 68 | + 'text', |
| 69 | + 'inlineCode', |
| 70 | + 'text', |
| 71 | + 'blockTag', |
| 72 | + 'comment', |
| 73 | + 'text', |
| 74 | + 'inlineTag', |
| 75 | + 'text', |
| 76 | + 'paragraph', |
| 77 | + 'description', |
| 78 | + 'typeExpression', |
| 79 | + 'text', |
| 80 | + 'blockTag', |
| 81 | + 'comment', |
| 82 | + 'root' |
| 83 | +] |
| 84 | + |
| 85 | +/** |
| 86 | + * All node types visited during reverse postorder traversal. |
| 87 | + * |
| 88 | + * @const {Postorder['typesReversed']} typesReversed |
| 89 | + */ |
| 90 | +const typesReversed: Postorder['typesReversed'] = [ |
| 91 | + 'text', |
| 92 | + 'typeExpression', |
| 93 | + 'blockTag', |
| 94 | + 'text', |
| 95 | + 'inlineTag', |
| 96 | + 'text', |
| 97 | + 'paragraph', |
| 98 | + 'description', |
| 99 | + 'comment', |
| 100 | + 'text', |
| 101 | + 'inlineCode', |
| 102 | + 'text', |
| 103 | + 'typeExpression', |
| 104 | + 'blockTag', |
| 105 | + 'text', |
| 106 | + 'typeExpression', |
| 107 | + 'blockTag', |
| 108 | + 'code', |
| 109 | + 'blockTag', |
| 110 | + 'code', |
| 111 | + 'blockTag', |
| 112 | + 'text', |
| 113 | + 'inlineCode', |
| 114 | + 'text', |
| 115 | + 'inlineCode', |
| 116 | + 'text', |
| 117 | + 'paragraph', |
| 118 | + 'description', |
| 119 | + 'comment', |
| 120 | + 'text', |
| 121 | + 'blockTag', |
| 122 | + 'text', |
| 123 | + 'blockTag', |
| 124 | + 'text', |
| 125 | + 'blockTag', |
| 126 | + 'comment', |
| 127 | + 'root' |
| 128 | +] |
| 129 | + |
| 130 | +/** |
| 131 | + * Parent node types visited during postorder traversal. |
| 132 | + * |
| 133 | + * @const {Postorder['parents']} parents |
| 134 | + */ |
| 135 | +const parents: Postorder['parents'] = [ |
| 136 | + 'blockTag', |
| 137 | + 'comment', |
| 138 | + 'blockTag', |
| 139 | + 'comment', |
| 140 | + 'blockTag', |
| 141 | + 'comment', |
| 142 | + 'root', |
| 143 | + 'paragraph', |
| 144 | + 'paragraph', |
| 145 | + 'paragraph', |
| 146 | + 'paragraph', |
| 147 | + 'paragraph', |
| 148 | + 'description', |
| 149 | + 'comment', |
| 150 | + 'blockTag', |
| 151 | + 'comment', |
| 152 | + 'blockTag', |
| 153 | + 'comment', |
| 154 | + 'blockTag', |
| 155 | + 'blockTag', |
| 156 | + 'comment', |
| 157 | + 'blockTag', |
| 158 | + 'blockTag', |
| 159 | + 'blockTag', |
| 160 | + 'blockTag', |
| 161 | + 'comment', |
| 162 | + 'root', |
| 163 | + 'paragraph', |
| 164 | + 'paragraph', |
| 165 | + 'paragraph', |
| 166 | + 'description', |
| 167 | + 'comment', |
| 168 | + 'blockTag', |
| 169 | + 'blockTag', |
| 170 | + 'comment', |
| 171 | + 'root', |
| 172 | + undefined |
| 173 | +] |
| 174 | + |
| 175 | +/** |
| 176 | + * Ancestor node types visited during postorder traversal. |
| 177 | + * |
| 178 | + * @const {Postorder['ancestors']} ancestors |
| 179 | + */ |
| 180 | +const ancestors: Postorder['ancestors'] = [ |
| 181 | + ['root', 'comment'], |
| 182 | + ['root'], |
| 183 | + ['root', 'comment'], |
| 184 | + ['root'], |
| 185 | + ['root', 'comment'], |
| 186 | + ['root'], |
| 187 | + [], |
| 188 | + ['root', 'comment', 'description'], |
| 189 | + ['root', 'comment', 'description'], |
| 190 | + ['root', 'comment', 'description'], |
| 191 | + ['root', 'comment', 'description'], |
| 192 | + ['root', 'comment', 'description'], |
| 193 | + ['root', 'comment'], |
| 194 | + ['root'], |
| 195 | + ['root', 'comment'], |
| 196 | + ['root'], |
| 197 | + ['root', 'comment'], |
| 198 | + ['root'], |
| 199 | + ['root', 'comment'], |
| 200 | + ['root', 'comment'], |
| 201 | + ['root'], |
| 202 | + ['root', 'comment'], |
| 203 | + ['root', 'comment'], |
| 204 | + ['root', 'comment'], |
| 205 | + ['root', 'comment'], |
| 206 | + ['root'], |
| 207 | + [], |
| 208 | + ['root', 'comment', 'description'], |
| 209 | + ['root', 'comment', 'description'], |
| 210 | + ['root', 'comment', 'description'], |
| 211 | + ['root', 'comment'], |
| 212 | + ['root'], |
| 213 | + ['root', 'comment'], |
| 214 | + ['root', 'comment'], |
| 215 | + ['root'], |
| 216 | + [], |
| 217 | + [] |
| 218 | +] |
| 219 | + |
| 220 | +/** |
| 221 | + * Nodes visited during postorder traversal. |
| 222 | + * |
| 223 | + * @const {Readonly<Postorder>} postorder |
| 224 | + */ |
| 225 | +const postorder: Readonly<Postorder> = Object.freeze({ |
| 226 | + ancestors, |
| 227 | + parents, |
| 228 | + types, |
| 229 | + typesReversed |
| 230 | +}) |
| 231 | + |
| 232 | +export default postorder |
0 commit comments