(sl: Sourcelike)
| 70 | export interface SourcelikeArray extends Array<Sourcelike> {} |
| 71 | |
| 72 | export function sourcelikeToSource(sl: Sourcelike): Source { |
| 73 | if (sl instanceof Array) { |
| 74 | return { |
| 75 | kind: "sequence", |
| 76 | sequence: List(sl.map(sourcelikeToSource)) |
| 77 | }; |
| 78 | } |
| 79 | if (typeof sl === "string") { |
| 80 | const lines = sl.split("\n"); |
| 81 | if (lines.length === 1) { |
| 82 | return { kind: "text", text: sl }; |
| 83 | } |
| 84 | return { |
| 85 | kind: "sequence", |
| 86 | sequence: intercalate( |
| 87 | newline(), |
| 88 | List(lines).map((l: string) => ({ kind: "text", text: l } as Source)) |
| 89 | ).toList() |
| 90 | }; |
| 91 | } |
| 92 | if (sl instanceof Name) { |
| 93 | return { kind: "name", named: sl }; |
| 94 | } |
| 95 | return sl; |
| 96 | } |
| 97 | |
| 98 | export function annotated(annotation: AnnotationData, sl: Sourcelike): Source { |
| 99 | return { |
no test coverage detected
searching dependent graphs…