(
event: AgentEvent,
kind: WorkKind,
index: PlacementIndex,
)
| 191 | |
| 192 | /** Wo dieses Ereignis liegt. */ |
| 193 | export function placeEvent( |
| 194 | event: AgentEvent, |
| 195 | kind: WorkKind, |
| 196 | index: PlacementIndex, |
| 197 | ): Placement { |
| 198 | const empty = { ghostIds: [] as number[] }; |
| 199 | const path = normalizePath(event.path); |
| 200 | |
| 201 | if (kind === 'test') { |
| 202 | const tested = testedPathOf(event.detail, index); |
| 203 | if (tested.length > 0) { |
| 204 | const node = fileNodeOf(index.byPath.get(tested) ?? []); |
| 205 | if (node !== undefined) { |
| 206 | return { |
| 207 | kind: 'file', |
| 208 | nodeId: node.id, |
| 209 | name: displayNameOf(node), |
| 210 | qualifiedName: node.qualified_name ?? '', |
| 211 | uncertain: node.end_line === undefined, |
| 212 | why: '', |
| 213 | ghostIds: [], |
| 214 | testedNodeId: node.id, |
| 215 | }; |
| 216 | } |
| 217 | } |
| 218 | if (path.length === 0) { |
| 219 | return { |
| 220 | kind: 'none', |
| 221 | name: '', |
| 222 | qualifiedName: '', |
| 223 | uncertain: false, |
| 224 | why: 'the command names no file this index knows', |
| 225 | ...empty, |
| 226 | }; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | if (path.length === 0) { |
| 231 | return { |
| 232 | kind: 'none', |
| 233 | name: '', |
| 234 | qualifiedName: '', |
| 235 | uncertain: false, |
| 236 | why: 'the event names no path', |
| 237 | ...empty, |
| 238 | }; |
| 239 | } |
| 240 | |
| 241 | const nodes = index.byPath.get(path); |
| 242 | if (nodes === undefined || nodes.length === 0) { |
| 243 | return { |
| 244 | kind: 'none', |
| 245 | name: '', |
| 246 | qualifiedName: '', |
| 247 | uncertain: false, |
| 248 | why: 'the index has no node for this path', |
| 249 | ...empty, |
| 250 | }; |
no test coverage detected