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

Basic Q# Formatter #1172

Merged
merged 78 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
9dfb97e
basic spike with dummy format rule
ScottCarda-MS Jan 18, 2024
b368196
expose raw tokens to the formatter
ScottCarda-MS Jan 30, 2024
bf48ea3
Remove Trailing Whitespace
ScottCarda-MS Jan 31, 2024
0ba17c2
small change
ScottCarda-MS Feb 1, 2024
97b333b
Improved to support comments
ScottCarda-MS Feb 1, 2024
c6902b2
rules are convolution over token stream
ScottCarda-MS Feb 5, 2024
e31e583
added concrete tokens
ScottCarda-MS Feb 7, 2024
ae3954c
Merge branch 'main' into sccarda/Formatter
ScottCarda-MS Feb 16, 2024
33e74ce
.
ScottCarda-MS Feb 16, 2024
94e30b7
remove stuff that doesn't build
ScottCarda-MS Feb 16, 2024
e7467e1
fix things not being visible
ScottCarda-MS Feb 16, 2024
2204a99
got some basic rules working
ScottCarda-MS Feb 21, 2024
6adc019
changed data struct to have kind easier to get at.
ScottCarda-MS Feb 21, 2024
31bb282
rule for closing out empty delimiters
ScottCarda-MS Feb 21, 2024
9897873
little bit of clean up
ScottCarda-MS Feb 21, 2024
f9c96b2
cleanup and more small rules
ScottCarda-MS Feb 21, 2024
0e033a0
I think I finished indentation?
ScottCarda-MS Feb 21, 2024
a67043d
remove commented out code
ScottCarda-MS Feb 22, 2024
c432b9e
WIP of tests
ScottCarda-MS Feb 23, 2024
0623d8e
added more tests
ScottCarda-MS Feb 23, 2024
5cf1a96
correct_empty_delimiters
ScottCarda-MS Feb 23, 2024
a0a9088
.
ScottCarda-MS Feb 23, 2024
a2c4024
aliased ConcreteTokenKind for readability
ScottCarda-MS Feb 26, 2024
3b4fbcc
match restructuring
ScottCarda-MS Feb 26, 2024
51e118f
rename Cooked to Syntax
ScottCarda-MS Feb 27, 2024
ae19554
deal with todo's
ScottCarda-MS Feb 27, 2024
d79ae4c
import enum variants directly
ScottCarda-MS Feb 28, 2024
f2f09d1
Added documentation explaining the concrete tokens and the formatter …
ScottCarda-MS Feb 28, 2024
745fde4
Make qsc_formatter a separate crate.
ScottCarda-MS Feb 28, 2024
4bffe02
Merge branch 'main' into sccarda/Formatter
ScottCarda-MS Feb 28, 2024
5ab50c6
merge fix up
ScottCarda-MS Feb 28, 2024
77f72ff
fixed tests to say "StringToken" instead of "String"
ScottCarda-MS Feb 29, 2024
98fa0eb
Moved doc string for crate.
ScottCarda-MS Feb 29, 2024
c0a5de4
moved enum use statements to the match statement.
ScottCarda-MS Feb 29, 2024
ae29d7c
use saturating_sub
ScottCarda-MS Feb 29, 2024
97d1621
minor changes
ScottCarda-MS Feb 29, 2024
bd2ef31
WIP trying to refactor the rules
ScottCarda-MS Mar 2, 2024
d419988
went back to big match, cleaned it up a bit
ScottCarda-MS Mar 4, 2024
163d485
change name "comments" -> "comment"
ScottCarda-MS Mar 4, 2024
b3f598c
reversed String TokenKind rename
ScottCarda-MS Mar 4, 2024
9cdc6b3
correct tests after reverting rename of StringToken
ScottCarda-MS Mar 4, 2024
9c511ad
format_str and calculate_format_edits
ScottCarda-MS Mar 5, 2024
12e374d
update TextEdit structs
ScottCarda-MS Mar 5, 2024
bcdad8a
Merge branch 'main' into sccarda/Formatter
ScottCarda-MS Mar 5, 2024
b199779
clippy
ScottCarda-MS Mar 5, 2024
c218b46
little more clarity on tests names
ScottCarda-MS Mar 5, 2024
2af16d6
quick rename
ScottCarda-MS Mar 5, 2024
79f9da0
more complete functionality, includes operators
ScottCarda-MS Mar 6, 2024
c42cf65
added rules for lots of keywords
ScottCarda-MS Mar 6, 2024
0f5abec
functor keywords
ScottCarda-MS Mar 7, 2024
18cc087
Ignore `-` case
ScottCarda-MS Mar 7, 2024
d458ac8
added ignorance cases for new-lines and tweaked rules for prefixes
ScottCarda-MS Mar 7, 2024
a6ad814
string interpolation blocks
ScottCarda-MS Mar 7, 2024
d9c886d
adjusted logic for eol comments
ScottCarda-MS Mar 7, 2024
251d5e0
respect carriage returns
ScottCarda-MS Mar 7, 2024
5ac621f
close any empty block
ScottCarda-MS Mar 7, 2024
e4731c9
telemetry
ScottCarda-MS Mar 7, 2024
0fbc848
Added many tests
ScottCarda-MS Mar 11, 2024
21b52ff
account for apostrophe
ScottCarda-MS Mar 11, 2024
db65af8
control-flow-helper keywords
ScottCarda-MS Mar 13, 2024
55c8a68
other keyword rules
ScottCarda-MS Mar 13, 2024
449af25
lots of small syntax improvements
ScottCarda-MS Mar 13, 2024
04f5f0d
added some more tests
ScottCarda-MS Mar 13, 2024
2f792dc
update completions tests
ScottCarda-MS Mar 13, 2024
a8905aa
handle error cases
ScottCarda-MS Mar 14, 2024
dd9b10f
get raw tokens at start of content
ScottCarda-MS Mar 14, 2024
80ba9e7
samples formatted
ScottCarda-MS Mar 14, 2024
de61ac9
format libraries
ScottCarda-MS Mar 14, 2024
03bc13f
Merge branch 'main' into sccarda/Formatter
ScottCarda-MS Mar 14, 2024
3e85e8b
try to fix integration test
ScottCarda-MS Mar 14, 2024
c577452
update expect on test
ScottCarda-MS Mar 14, 2024
59042c6
Added setting to enable/disable formatter
ScottCarda-MS Mar 18, 2024
e044585
Revert "format libraries"
ScottCarda-MS Mar 18, 2024
1ebac90
Revert "samples formatted"
ScottCarda-MS Mar 18, 2024
9bdb950
fixed eval test
ScottCarda-MS Mar 18, 2024
57aff3a
Q# settings tweaks.
ScottCarda-MS Mar 18, 2024
decba41
revert change to debug test
ScottCarda-MS Mar 18, 2024
af8d6d4
telemetry in no-edits format
ScottCarda-MS Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions compiler/qsc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ num-complex = { workspace = true }
qsc_codegen = { path = "../qsc_codegen" }
qsc_data_structures = { path = "../qsc_data_structures" }
qsc_doc_gen = { path = "../qsc_doc_gen" }
qsc_formatter = { path = "../qsc_formatter" }
qsc_eval = { path = "../qsc_eval" }
qsc_frontend = { path = "../qsc_frontend" }
qsc_ast = { path = "../qsc_ast" }
Expand Down
2 changes: 2 additions & 0 deletions compiler/qsc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub mod interpret;
pub mod location;
pub mod target;

pub use qsc_formatter::formatter;

pub use qsc_frontend::compile::{
CompileUnit, PackageStore, RuntimeCapabilityFlags, SourceContents, SourceMap, SourceName,
};
Expand Down
20 changes: 20 additions & 0 deletions compiler/qsc_formatter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "qsc_formatter"

version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
qsc_data_structures = { path = "../qsc_data_structures" }
qsc_frontend = { path = "../qsc_frontend" }

[dev-dependencies]
expect-test = { workspace = true }
indoc = { workspace = true }

[lib]
doctest = false
Loading
Loading