(packet: FactPacket, rank: number)
| 452 | } |
| 453 | |
| 454 | function compareDrafts(packet: FactPacket, rank: number): Draft[] { |
| 455 | const other = packet.compareWith; |
| 456 | if (other === undefined) { |
| 457 | return []; |
| 458 | } |
| 459 | const ir = other.ir; |
| 460 | if (ir === undefined) { |
| 461 | return [{ |
| 462 | kind: 'compare', |
| 463 | lines: [`${other.symbol.name} is in the index, but its facts could not be read.`], |
| 464 | source: { name: other.symbol.name, filePath: workspacePathOf(other.symbol.uri) }, |
| 465 | rank, |
| 466 | }]; |
| 467 | } |
| 468 | const source = sourceOfIr(ir); |
| 469 | const calls = ir.steps.value.map((call) => { |
| 470 | const line = call.line === undefined ? '' : ` [line ${call.line}]`; |
| 471 | return `${call.targetName}${line}`; |
| 472 | }); |
| 473 | return [{ |
| 474 | kind: 'compare', |
| 475 | lines: [ |
| 476 | `${whereOf(source)} is a ${ir.symbol.kind}; it is called by ` |
| 477 | + `${ir.calledBy.value.length} symbol(s).`, |
| 478 | calls.length === 0 |
| 479 | ? `${ir.symbol.name} makes no call the index recorded.` |
| 480 | : `${ir.symbol.name} calls ${listOf(calls)}.`, |
| 481 | ir.throws.value.length === 0 |
| 482 | ? `${ir.symbol.name} raises no error type the index recorded.` |
| 483 | : `${ir.symbol.name} can raise ` |
| 484 | + `${listOf(raisedNames(ir))}.`, |
| 485 | ], |
| 486 | source, |
| 487 | rank, |
| 488 | }]; |
| 489 | } |
| 490 | |
| 491 | function raisedNames(ir: SemanticIR): string[] { |
| 492 | const seen = new Set<string>(); |
no test coverage detected