| 467 | * Aufrufer haette ihn sonst nicht mehr. |
| 468 | */ |
| 469 | export function readPathResult(value: unknown): PathResult { |
| 470 | const raw = record(value); |
| 471 | if (raw['status'] === 'ambiguous') { |
| 472 | const suggestions: PathSuggestion[] = []; |
| 473 | for (const entry of tableRows(raw['suggestions'])) { |
| 474 | const qualifiedName = qualifiedNameOf(entry); |
| 475 | const name = toText(entry['name']); |
| 476 | if (qualifiedName === undefined || name === undefined) { |
| 477 | continue; |
| 478 | } |
| 479 | suggestions.push({ |
| 480 | qualified_name: qualifiedName, |
| 481 | name, |
| 482 | label: toText(entry['label']), |
| 483 | file_path: toText(entry['file_path']), |
| 484 | }); |
| 485 | } |
| 486 | return { status: 'ambiguous', message: toText(raw['message']), suggestions }; |
| 487 | } |
| 488 | |
| 489 | const hopsOf = (key: string): PathHop[] | undefined => { |
| 490 | if (raw[key] === undefined) { |
| 491 | return undefined; |
| 492 | } |
| 493 | const hops: PathHop[] = []; |
| 494 | for (const entry of tableRows(raw[key])) { |
| 495 | const name = toText(entry['name']); |
| 496 | if (name === undefined) { |
| 497 | continue; |
| 498 | } |
| 499 | hops.push({ |
| 500 | name, |
| 501 | qualified_name: qualifiedNameOf(entry), |
| 502 | hop: toOptionalNumber(entry['hop']), |
| 503 | }); |
| 504 | } |
| 505 | return hops; |
| 506 | }; |
| 507 | |
| 508 | const walk: PathWalk = { function: toText(raw['function']) ?? '', direction: toText(raw['direction']) }; |
| 509 | const callees = hopsOf('callees'); |
| 510 | const callers = hopsOf('callers'); |
| 511 | if (callees !== undefined) { |
| 512 | walk.callees = callees; |
| 513 | } |
| 514 | if (callers !== undefined) { |
| 515 | walk.callers = callers; |
| 516 | } |
| 517 | return walk; |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Die Suchantwort. |