(value: unknown)
| 418 | } |
| 419 | |
| 420 | export function readCodeSnippet(value: unknown): CodeSnippetResult { |
| 421 | const raw = record(value); |
| 422 | const result: CodeSnippetResult = { |
| 423 | name: toText(raw['name']), |
| 424 | qualified_name: toText(raw['qualified_name']), |
| 425 | label: toText(raw['label']), |
| 426 | file_path: toText(raw['file_path']), |
| 427 | start_line: toOptionalNumber(raw['start_line']), |
| 428 | end_line: toOptionalNumber(raw['end_line']), |
| 429 | source: typeof raw['source'] === 'string' ? (raw['source'] as string) : '', |
| 430 | }; |
| 431 | // Nur uebernehmen, wenn der Server es sagt. `false` waere hier die Aussage |
| 432 | // "nicht gekappt", und die hat ein Server, der das Feld gar nicht kennt, |
| 433 | // nicht gemacht. |
| 434 | if (raw['source_clipped'] !== undefined) { |
| 435 | result.source_clipped = toBoolean(raw['source_clipped']); |
| 436 | } |
| 437 | const clippedAt = toOptionalNumber(raw['clipped_at_lines']); |
| 438 | if (clippedAt !== undefined) { |
| 439 | result.clipped_at_lines = clippedAt; |
| 440 | } |
| 441 | /* The lean output contract (#1597) pages source: `next_start_line` names |
| 442 | * the next page, `original_end_line` the file's real last line, and |
| 443 | * `source_mode` says whether source or an outline came back. */ |
| 444 | if (typeof raw['source_mode'] === 'string') { |
| 445 | result.source_mode = raw['source_mode'] as string; |
| 446 | } |
| 447 | if (raw['source_truncated'] !== undefined) { |
| 448 | result.source_truncated = toBoolean(raw['source_truncated']); |
| 449 | } |
| 450 | const nextStart = toOptionalNumber(raw['next_start_line']); |
| 451 | if (nextStart !== undefined) { |
| 452 | result.next_start_line = nextStart; |
| 453 | } |
| 454 | const originalEnd = toOptionalNumber(raw['original_end_line']); |
| 455 | if (originalEnd !== undefined) { |
| 456 | result.original_end_line = originalEnd; |
| 457 | } |
| 458 | return result; |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Die Pfadantwort, beide Formen. |
no test coverage detected