Skip to content

Index each schema's lines once - #594

Merged
stepchowfun merged 1 commit into
mainfrom
loaded-schema
Oct 4, 2026
Merged

stepchowfun merged 1 commit into
mainfrom
loaded-schema

Conversation

@stepchowfun

Copy link
Copy Markdown
Owner

The tokenizer, parser, schema loader, and validator each built their own LineIndex of a schema, so a schema's lines could be indexed up to four times. Now load_schemas builds it once per schema and passes it to tokenize and parse.

load_schemas now returns a BTreeMap<schema::Namespace, LoadedSchema>, where LoadedSchema holds 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 in schema::Schema is 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 LineIndex for each source they tokenize or parse. Tests which passed a string literal directly to tokenize now name it source first, so the literal isn't repeated.

Status: Ready

Fixes: N/A

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.
@stepchowfun
stepchowfun merged commit a42514d into main Oct 4, 2026
6 checks passed
@stepchowfun
stepchowfun deleted the loaded-schema branch October 4, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant