Repository navigation
Index each schema's lines once - #594
Merged
Merged
Conversation
The tokenizer, parser, schema loader, and validator each built their own index of a schema's lines. Now the schema loader builds it once and passes it to the tokenizer and parser, and it returns it along with each schema's path and contents in a `LoadedSchema`, which the validator reads it from. `LoadedSchema` also replaces the tuple which held the path and contents, so its parts have names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tokenizer, parser, schema loader, and validator each built their own
LineIndexof a schema, so a schema's lines could be indexed up to four times. Nowload_schemasbuilds it once per schema and passes it totokenizeandparse.load_schemasnow returns aBTreeMap<schema::Namespace, LoadedSchema>, whereLoadedSchemaholds a schema along with the file it was loaded from (its path, contents, and line index). This replaces the(schema::Schema, PathBuf, String)tuple, so its parts have names, and the validator reads each schema's line index from it. The syntax tree inschema::Schemais unchanged, since the code generators also build schemas which weren't loaded from a file.When an import can't be loaded, the error points into the importing schema, so the importing schema's line index is now carried along with the import, like its path and contents already were.
Most of the diff is in tests, which now build a
LineIndexfor each source they tokenize or parse. Tests which passed a string literal directly totokenizenow name itsourcefirst, so the literal isn't repeated.Status: Ready
Fixes: N/A