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

Use a single Vec<Context> in SyntaxSet after linking #187

Merged
merged 0 commits into from
Jul 5, 2018

Conversation

robinst
Copy link
Collaborator

@robinst robinst commented Jul 3, 2018

This means resolving a ContextId is now a single lookup.

Having the SyntaxSetBuilder (introduced in a previous commit) helped make this change.

This is a separate PR to hopefully make it easier to review, but it's part of the larger work in #182.

@robinst robinst mentioned this pull request Jul 3, 2018
9 tasks
builder.load_syntaxes(folder, !no_newlines).unwrap();
ss = builder.build();
// TODO: no way to go back to builder anymore :/
//let mut builder = ss.builder();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can bring this back by recreating all the SyntaxDefinitions from the SyntaxReferences and their contexts, but haven't looked into this yet.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm that may be an issue, as I mentioned in the other PR, it would be nice for editors to be able to load new syntaxes on the fly. Mostly thinking of Xi.

Three options:

  • Just make editors reload everything on adding a new syntax, which may be fine because they might want to create their own dumps for fast startup, and reloading shouldn't be that slow.
  • Maybe have the builder also have context/references Vecs that are only used when creating from an existing set. This might be pretty easy.
  • What you said, recreate the original structures.

@robinst
Copy link
Collaborator Author

robinst commented Jul 3, 2018

@trishume This is not yet the end state you had in mind, but just a step in that direction. A further step would be to get rid of SyntaxDefinition::load_from_str and a separate SyntaxDefinition type and instead directly load into a SyntaxSetBuilder.

The reason I left it is because it was easier to do this step, and because I'm wondering if it would be useful to keep both types in the API (SyntaxReference and SyntaxDefinition)?

Copy link
Owner

@trishume trishume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Since this is a PR to another PR of yours I'll leave it up to you how/when you want to do merging/branching from here. I won't hit the button and you can or you can keep branching further, either works.

builder.load_syntaxes(folder, !no_newlines).unwrap();
ss = builder.build();
// TODO: no way to go back to builder anymore :/
//let mut builder = ss.builder();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm that may be an issue, as I mentioned in the other PR, it would be nice for editors to be able to load new syntaxes on the fly. Mostly thinking of Xi.

Three options:

  • Just make editors reload everything on adding a new syntax, which may be fine because they might want to create their own dumps for fast startup, and reloading shouldn't be that slow.
  • Maybe have the builder also have context/references Vecs that are only used when creating from an existing set. This might be pretty easy.
  • What you said, recreate the original structures.


let context_map = ContextMap::new(scopes, syntax_names, context_names);

// 2 loops necessary to satisfy borrow checker :-(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

@robinst robinst force-pushed the use-arena-for-contexts-flat branch from b3a51e8 to 822c472 Compare July 5, 2018 07:16
@robinst robinst merged commit 822c472 into use-arena-for-contexts Jul 5, 2018
@robinst robinst force-pushed the use-arena-for-contexts branch from 85ce859 to 822c472 Compare July 5, 2018 07:18
@robinst
Copy link
Collaborator Author

robinst commented Jul 5, 2018

Rebased both branches and incorporated this into the other PR.

@robinst robinst deleted the use-arena-for-contexts-flat branch July 5, 2018 07:18
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