Document confusing code

This commit is contained in:
Simon Binder 2021-02-14 16:50:21 +01:00
parent 968af8f56e
commit 535425e34f
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 6 additions and 10 deletions

View File

@ -41,7 +41,7 @@ dependencies:
dev_dependencies:
test: ^1.6.0
build_runner: ^1.6.7
build_test: ^1.3.4
build_test: ^1.3.6
json_serializable: ^4.0.0-nullsafety
executables:

View File

@ -24,25 +24,21 @@ class AstPreparingVisitor extends RecursiveVisitor<void, void> {
final scope = e.scope = e.scope.createChild();
final registeredTable = scope.resolve(e.tableName) as Table?;
// This is used so that tables can refer to their own columns. Code using
// tables would first register the table and then run analysis again.
if (registeredTable != null) {
scope.availableColumns = registeredTable.resolvedColumns;
for (final column in registeredTable.resolvedColumns) {
scope.register(column.name, column);
}
}
visitChildren(e, arg);
}
@override
void visitCreateViewStatement(CreateViewStatement e, void arg) {
final scope = e.scope = e.scope.createChild();
final registeredView = scope.resolve(e.viewName) as View?;
if (registeredView != null) {
scope.availableColumns = registeredView.resolvedColumns;
for (final column in registeredView.resolvedColumns) {
scope.register(column.name, column);
}
}
e.scope = e.scope.createChild();
visitChildren(e, arg);
}