(sourceFile: SourceFile)
| 36 | } |
| 37 | |
| 38 | export function parseSourceFile(sourceFile: SourceFile) { |
| 39 | debugFile(`Start parsing file ${sourceFile.filePath}`) |
| 40 | const { queries, tableSchemas } = parseSourceFileUsingBabel(sourceFile) |
| 41 | |
| 42 | debugFile(`Parsed file ${sourceFile.filePath}:`) |
| 43 | |
| 44 | for (const invocation of queries) { |
| 45 | const query = invocation.query |
| 46 | debugQueries( |
| 47 | ` Query: ${query.query.trim()}\n` + |
| 48 | ` Result columns: ${formatColumnRefs(query.returnedColumns)}\n` + |
| 49 | ` Referenced columns: ${formatColumnRefs(query.referencedColumns)}` |
| 50 | ) |
| 51 | |
| 52 | for (const subquery of getAllSubqueries(query)) { |
| 53 | const returningStatus = subquery.returnsIntoParentQuery ? " (into parent query)" : "" |
| 54 | debugSubqueries( |
| 55 | ` Subquery type: ${subquery.path.type}\n` + |
| 56 | ` Result columns: ${formatColumnRefs( |
| 57 | subquery.returnedColumns |
| 58 | )}${returningStatus}\n` + |
| 59 | ` Referenced columns: ${formatColumnRefs(subquery.referencedColumns)}` |
| 60 | ) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | for (const table of tableSchemas) { |
| 65 | debugTables(` Table: ${table.tableName}`) |
| 66 | for (const columnName of table.columnNames) { |
| 67 | const columnType = stringifyColumnType(table.columnDescriptors[columnName]) |
| 68 | debugTables(` Column "${columnName}": ${columnType}`) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return { queries, tableSchemas } |
| 73 | } |
no test coverage detected