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
Formatter #371
Merged
Merged
Formatter #371
Conversation
This file contains 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
hyperfine --warmup 1 "cargo run --release --manifest-path=compiler/cli/Cargo.toml -- run packages/examples/fibonacci.candy" Before: Time (mean ± σ): 1.180 s ± 0.045 s [User: 1.115 s, System: 0.067 s] Range (min … max): 1.092 s … 1.241 s 10 runs After: Time (mean ± σ): 1.096 s ± 0.059 s [User: 1.037 s, System: 0.061 s] Range (min … max): 0.981 s … 1.201 s 10 runs
MarcelGarus
requested changes
Mar 25, 2023
Co-authored-by: Marcel Garus <marcel.garus@gmail.com>
MarcelGarus
approved these changes
Mar 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
P: Compiler: CLI
Package: Candy's command-line interface
P: Compiler: Frontend
Package: The compiler frontend
P: Compiler: Fuzzer
Package: Candy's built-in fuzzer fuzzing Candy code
P: Compiler: Language Server
Package: The Candy Language Server
P: Compiler: VM
Package: The VM executing Candy byte code (LIR)
P: Compiler: VS Code Extension
Package: The Candy VS Code Extension
P: Core
Package: Candy's standard library
T: Feature
Type: New Features
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.
Changes in this PR:
This is only a draft PR since I still have to add support for trailing sandwich-likes. But I wanted to give you a chance to catch up since this PR is leaning slightly towards the larger end.
After that, we only have to add support for formatting text (once we update the parser to the new text formatting) and integrate it in our language server and CLI.
I switched from producing a new CST and diffing that against the old one to computing and collecting text edits directly (in
TextEdits
) since it seemed simpler. (I don't have the full comparison since I didn't implement diffing, but at least the formatting code inExistingWhitespace
got simpler.) I also added a bit of documentation and there are many tests for the formatter (src/format.rs
) as well as some forExistingWhitespace
.Checklist