-
Notifications
You must be signed in to change notification settings - Fork 7
Formater rewrite. #400
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
Open
Kuinox
wants to merge
77
commits into
main
Choose a base branch
from
feature/formater_rework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Formater rewrite. #400
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
68065d6
Just collapible values for now.
Kuinox ff63e2a
wip
Kuinox fc28095
wip.
Kuinox 1c475b1
Simple test case pass.
Kuinox 6be2c8c
wip
Kuinox bef4be7
wip
Kuinox 8189446
wip
Kuinox e582157
More progress
Kuinox c29882a
wip
Kuinox e51f56b
One more test green.
Kuinox 61a1dbe
More tests are passing.
Kuinox dba4b22
Time for bulldozing.
Kuinox 4dbcc9e
Some buldozing.
Kuinox e5f1661
rebuldozer
Kuinox 6987857
re - re buldozing
Kuinox 9326cd7
should i buldozer further ?
Kuinox 6a9c830
I drunk too much for not committing before coding.
Kuinox cca9727
wip
Kuinox 2495a41
All tests pass. Now need more tests.
Kuinox 41b4254
wip.
Kuinox cec80c5
wip.
Kuinox cfc2f20
A bugfix.
Kuinox eef1ff0
Simplest comment case handled.
Kuinox 9b4edb6
Added comments support.
Kuinox c43c83b
Removed CollapsableInt.
Kuinox 5cdb31c
Remove dead code.
Kuinox a62d233
Cleanup
Kuinox f5f9436
Added failing test case.
Kuinox 75e2cad
Fixed more edge case, added test for another one.
Kuinox d3961b8
Added more edgecases, more cleanup.
Kuinox e352977
Moar renames.
Kuinox 2c698a7
PR feedback.
Kuinox 845a611
Improved code readability.
Kuinox 02de0ec
Improving readability.
Kuinox 1a88e83
DRY FTW.
Kuinox 80ec52b
Stop exposing the token reference in the metadata.
Kuinox 58d9fd6
Removed token override.
Kuinox 56f75b9
Factorized out formatter.
Kuinox 82d72a9
Make the formatter core extensible.
Kuinox d6cde88
Factored out more non-draco specific code.
Kuinox 286ba34
nullfix
Kuinox 7f1f1ab
More code goes away ~
Kuinox de3ad18
Some regression.
Kuinox 61262f0
a c# formatter.
Kuinox a97eb4f
Put formatter engine in a dedicated project.
Kuinox 6d3f5e0
Conforming to repo syntax.
Kuinox 8c17604
Some debug tooling.
Kuinox b611f56
Remove OnDifferent.
Kuinox 5e589d6
bugfix
Kuinox fb40b8b
Bug fixed.
Kuinox edb4c97
Cleaned using.
Kuinox 2216605
Added line return.
Kuinox 4072e3b
Some PR feedback.
Kuinox 70f94bf
More PR feedback.
Kuinox 7dc3e8b
And more.
Kuinox 46ab610
Remove empty formatter config.
Kuinox 4b9256f
PR feedback.
Kuinox 54dfffd
Remove force right pad.
Kuinox ed54478
wip.
Kuinox 1dbbe1e
wip
Kuinox f1854a0
Removed Data property on scope infos.
Kuinox c59fe6a
More C# formatter progress.
Kuinox 229962d
Created CSharpFormatterSettings plus a Draco specific settings.
Kuinox 6cd5964
Fixed some PR feedback.
Kuinox 175d0a8
Don't merge tokens that can fuse together.
Kuinox e3a33ce
Improved C# formatter.
Kuinox 20dc27b
ohno
Kuinox 4b30c73
Update src/Draco.FormatterEngine/Scope.cs
Kuinox 57c6da8
Update src/Draco.Formatter.Csharp/CSharpFormatter.cs
Kuinox 694eeb1
Dropped box to use a future instead.
Kuinox 4199b12
Some improvements & pr feedback.
Kuinox d0f5c95
Forgot to commit this file.
Kuinox e6d5100
Deleted csharp formatter.
Kuinox 8143fff
Some code simplifications.
Kuinox 311a53e
Merge remote-tracking branch 'origin/main' into feature/formater_rework
Kuinox 14aab95
VS did open it fine...
Kuinox b702b49
Some fixes of the code simplification.
Kuinox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Draco.Compiler.Api.Syntax; | ||
|
||
namespace Draco.Compiler.Tests.Syntax; | ||
public class SyntaxHelpersTests | ||
{ | ||
|
||
[Fact] | ||
public void TestIfElseIfExpression() | ||
{ | ||
var res = SyntaxTree.Parse("func main() { var a = if (true) 1 else if (false) 2 else 3 }"); | ||
var statement = (((res.Root as CompilationUnitSyntax)!.Declarations.Single() as FunctionDeclarationSyntax)!.Body as BlockFunctionBodySyntax)!.Statements.Single() as DeclarationStatementSyntax; | ||
var variableDeclaration = statement!.Declaration as VariableDeclarationSyntax; | ||
var ifExpression = variableDeclaration!.Value!.Value as IfExpressionSyntax; | ||
Assert.True(ifExpression!.Else!.IsElseIf); | ||
} | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Draco.Compiler.Api.Syntax; | ||
|
||
public partial class ElseClauseSyntax | ||
{ | ||
/// <summary> | ||
/// Returns <see langword="true"/> when the else clause is followed by an if expression. | ||
/// </summary> | ||
public bool IsElseIf => | ||
this.Expression is IfExpressionSyntax | ||
|| this.Expression is StatementExpressionSyntax statementExpression | ||
&& statementExpression.Statement is ExpressionStatementSyntax expressionStatement | ||
&& expressionStatement.Expression is IfExpressionSyntax; | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Draco.Compiler.Api.Syntax; | ||
public partial class StringPartSyntax | ||
{ | ||
/// <summary> | ||
/// <see langword="true"/> when this <see cref="StringPartSyntax"/> is a <see cref="SyntaxToken"/> with <see cref="TokenKind.StringNewline"/>. | ||
/// </summary> | ||
public bool IsNewLine => this.Children.Count() == 1 && this.Children.SingleOrDefault() is SyntaxToken and { Kind: TokenKind.StringNewline }; | ||
} |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.