Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@yjt98765
Copy link
Contributor

This PR implements an updating rule that replaces &&, ||, and ! with and, or, and not, respectively. It is proposed in issue #1200.

The tricky part is to ensure there is some space between the new keyword and the following operand. I implement a ensureSpace for this purpose. This function is used together with Expression.mapPrefix, which applies a mapper to the first prefix in an Expression. The above method changes the code a little more than necessary (for having correct grammar). For example, in the case of True &&(True || False), inserting a space before the ( is unnecessary. Nevertheless, it looks better if there is such a space, i.e., True and (True or False). By the way, we also need a formating rule to insert whitespace to these positions. Therefore, I choose to use mapPrefix instead of implementing a similar, new one.

The test cases show several scenarios. If there is one or more spaces between the operator and nearby operands, those spaces are untouched (like t1). Otherwise, a single space is inserted (like t2). It also works with nested expressions (like t3).

@ScottCarda-MS ScottCarda-MS added the area: formatter Q# source code formatter label Oct 26, 2021
Copy link
Contributor

@ScottCarda-MS ScottCarda-MS left a comment

Choose a reason for hiding this comment

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

I've gotten a chance to look over the code and test out the changes myself. All of this looks and works great! Thanks for your contribution here!

@ScottCarda-MS
Copy link
Contributor

ScottCarda-MS commented Oct 27, 2021

We are working on resolving the issue with the e2e check not responding. The build on the pipeline is successfully completing, so I believe it is something regarding the interplay between the PR and the pipeline.

@yjt98765
Copy link
Contributor Author

I am working on resolving the issue with the e2e check not responding. The build on the pipeline is successfully completing, so I believe it is something regarding the interplay between the PR and the pipeline.

I have created several PRs before, and the e2e step was always like this. It would be great if you can fix it!

@bamarsha
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@ScottCarda-MS ScottCarda-MS merged commit 9cdcb3e into microsoft:main Oct 27, 2021
@ScottCarda-MS
Copy link
Contributor

@yjt98765 The check is passing now, and I've gone ahead and merged in your changes. Thanks again for contributing!

cesarzc added a commit that referenced this pull request Nov 5, 2021
* added MSBuild_Logs to gitignore (#1171)

* Command Line Support for Project File Input (#1192)

* Change --inputs to --input (#1210)

* Deprecate new array expression (#956)

* Removing temporary project (#1225)

* Formatter Updates Deprecated Boolean Operator Syntax (#1214)

* Update the documentation found in the Q# Formatter Project (#1203)

* Formatter Updates Deprecated Specialization Declaration Parameters (#1226)

* Adding Sdk integration, and formatting support + code action for syntax updates to the language server (#1207)

Co-authored-by: Filip W <[email protected]>
Co-authored-by: Scott Carda <[email protected]>
Co-authored-by: Sarah Marshall <[email protected]>
Co-authored-by: bettinaheim <[email protected]>
Co-authored-by: Jintao YU <[email protected]>
cesarzc added a commit that referenced this pull request Nov 16, 2021
* added MSBuild_Logs to gitignore (#1171)

* Command Line Support for Project File Input (#1192)

* Change --inputs to --input (#1210)

* Deprecate new array expression (#956)

* Removing temporary project (#1225)

* Formatter Updates Deprecated Boolean Operator Syntax (#1214)

* Update the documentation found in the Q# Formatter Project (#1203)

* Formatter Updates Deprecated Specialization Declaration Parameters (#1226)

* Adding Sdk integration, and formatting support + code action for syntax updates to the language server (#1207)

* QAT v. 0.1 (#1230)

* Sdk changes to support Qir targets (#1238)

* Quantum Development Kit Telemetry Library (#1199)

Co-authored-by: Sarah Marshall <[email protected]>
Co-authored-by: Scott Carda <[email protected]>

* Allowing to use the LLVM intrinsic readcyclecounter from Q# (#1248)

* Do case-insensitive comparisons for targets names (#1241)

During the build stage of a Q# job submission via the CLI or the stand-alone executable, there is a case sensitive enforcement of target names.

Since this limitation does not exist in the service or in other clients, we're aligning by making the corresponding comparison case insensitive.

* Refactor language server code for extracting symbols from Q# fragments (#1220)

* Start adding SymbolOccurrence module

* Replace SymbolInformation implementation

* Add C# interop for SymbolOccurrence

* Rename SymbolInformation.cs to match class name

* Mark SymbolInformation as obsolete

* Add SymbolOccurrence.fsi

* Add doc comments

* Fix nullable errors with .NET Core 3.1

* Use as instead of is

* Take in fragment instead of file in SymbolOccurrence

* Update todo comments

* Return NS in open directive as UsedVariable

* Use TryGet for SymbolOccurrence C# API

* Statement Kinds Support (#1212)

* Addressing last comments - QAT v0.1 (#1240)

* Type renaming

* Removing redudant setModulePassManager

* Fixing recursion

* Refactoring filenames

* Renaming directory

* Updating names and files

* Formatting

* Fixing include

* Updates for QIR validation (#1250)

* Type renaming

* Removing redudant setModulePassManager

* Fixing recursion

* Refactoring filenames

* Renaming directory

* Updating names and files

* Formatting

* Changing default to interop friendly

* Updating base profile

* Styling

* Updating logger

* Fixing style

* Removing comment

* Moving testing to run before linting

* Updating CMake

* Attempting to solve tests issue

* Updating according to PR comments

* Complete NamespaceItem in qsfmt (#1239)

Co-authored-by: Filip W <[email protected]>
Co-authored-by: Scott Carda <[email protected]>
Co-authored-by: Sarah Marshall <[email protected]>
Co-authored-by: bettinaheim <[email protected]>
Co-authored-by: Jintao YU <[email protected]>
Co-authored-by: Troels F. Rønnow <[email protected]>
Co-authored-by: XField <[email protected]>
Co-authored-by: Ricardo Espinoza <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: formatter Q# source code formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants