Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track dependents for each syntax #1858

Merged
merged 3 commits into from
Sep 22, 2021

Conversation

Enselic
Copy link
Collaborator

@Enselic Enselic commented Sep 20, 2021

Progress on #951 continues, and I now have work-in-progress code where syntaxes.bin has been removed, and every syntax is present in minimal_syntaxes.bin. Notably, without duplicates, so the size of minimal_syntaxes.bin is the same as syntaxes.bin, differing only by some tens of kbs. See Enselic#38.

While there still are problems to solve, I am confident in some parts of the code, and will start continue to create separate PRs to take the code base in that direction. (Actually, #1856 is also this kind of PR.)

This PR consists of three commits. The first commit just renames stuff in preparation for the third commit. The second commits just moves code around a bit to fit better with the third commit. The "real" code is in the third commit. It adds code to add information about what dependents a syntax has. For example, the Rust syntax is a dependent for the Markdown syntax, because Markdown depends on Rust via embed: scope:source.rust.

Knowing the dependents of a syntax is useful when constructing SyntaxSets without duplicate SyntaxReferences (and is used in Enselic#38).

While this code adds info about syntax dependents, there is a temporary env var flag that makes it not used yet when building assets. The env var will be removed later, and the dependents info will start being used when building assets.

So that we later can use it for not only information about dependencies, but
also for information about dependents.
It makes more sense structurally when we later introduce SyntaxToDependents.
src/assets/build_assets.rs Outdated Show resolved Hide resolved
src/assets/build_assets.rs Outdated Show resolved Hide resolved
@Enselic
Copy link
Collaborator Author

Enselic commented Sep 22, 2021

Thanks for review!

(I will do a force-push to restore original commit structure before I merge)

This information is useful when you want to build several SyntaxSets, but
without having to duplicate SyntaxDefinitions. For example:

"Rust" has no dependencies. But "Markdown" depends on "Rust". With the data
structures this code adds, we know that "Rust" is a dependent syntax for
"Markdown", and can construct a SyntaxSet that takes that into account.

Note that code has a temporary environment flag to ignore any information about
dependents when constructing SyntaxSets. Code that makes use of the new data
structure will be added later.
@Enselic Enselic force-pushed the track-syntax-dependents branch from 4d9c396 to f77ff1c Compare September 22, 2021 06:41
@Enselic Enselic merged commit 5143f3a into sharkdp:master Sep 22, 2021
@Enselic Enselic deleted the track-syntax-dependents branch September 22, 2021 07:14
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.

2 participants