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

Commit 31530ff

Browse files
committed
Basic structure working
The new code is actually so fast that it is hard to keep up with the output. It can run very quickly on the CodeAnalysis project now except there is a bug in private field rename. Need to cleanup the output to be useable again. Then onto debugging that issue.
1 parent 32a15e1 commit 31530ff

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/Microsoft.DotNet.CodeFormatting/FormattingEngineImplementation.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public Task FormatProjectAsync(Project project, CancellationToken cancellationTo
5252

5353
private async Task FormatAsync(Workspace workspace, IReadOnlyList<DocumentId> documentIds, CancellationToken cancellationToken)
5454
{
55+
var watch = new Stopwatch();
56+
watch.Start();
57+
5558
var originalSolution = workspace.CurrentSolution;
5659
var solution = originalSolution;
5760
solution = await RunSyntaxPass(solution, documentIds, cancellationToken);
@@ -73,6 +76,9 @@ private async Task FormatAsync(Workspace workspace, IReadOnlyList<DocumentId> do
7376
}
7477
}
7578
}
79+
80+
watch.Stop();
81+
Console.WriteLine("Total time {0}", watch.Elapsed);
7682
}
7783

7884
private async Task<bool> ShouldBeProcessedAsync(Document document)
@@ -101,7 +107,7 @@ private void StartDocument(Document document, int depth = 1)
101107
{
102108
for (int i = 0; i < depth; i++)
103109
{
104-
Console.Write("\t");
110+
Console.Write(" ");
105111
}
106112

107113
Console.Write("Processing {0}", document.Name);
@@ -175,7 +181,7 @@ private async Task<Solution> RunLocalSemanticPass(Solution solution, IReadOnlyLi
175181

176182
private async Task<Solution> RunLocalSemanticPass(Solution originalSolution, IReadOnlyList<DocumentId> documentIds, ILocalSemanticFormattingRule localSemanticRule, CancellationToken cancellationToken)
177183
{
178-
Console.WriteLine("\t{0}", localSemanticRule.GetType().Name);
184+
Console.WriteLine(" {0}", localSemanticRule.GetType().Name);
179185
var currentSolution = originalSolution;
180186
foreach (var documentId in documentIds)
181187
{
@@ -212,7 +218,7 @@ private async Task<Solution> RunGlobalSemanticPass(Solution solution, IReadOnlyL
212218

213219
private async Task<Solution> RunGlobalSemanticPass(Solution solution, IReadOnlyList<DocumentId> documentIds, IGlobalSemanticFormattingRule globalSemanticRule, CancellationToken cancellationToken)
214220
{
215-
Console.WriteLine("\t{0}", globalSemanticRule.GetType().Name);
221+
Console.WriteLine(" {0}", globalSemanticRule.GetType().Name);
216222
foreach (var documentId in documentIds)
217223
{
218224
var document = solution.GetDocument(documentId);

src/Microsoft.DotNet.CodeFormatting/IFormattingRule.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal interface IFormattingRule
1818
/// <summary>
1919
/// Rules which need no semantic information and operate on parse trees only.
2020
/// </summary>
21-
internal interface ISyntaxFormattingRule
21+
internal interface ISyntaxFormattingRule : IFormattingRule
2222
{
2323
SyntaxNode Process(SyntaxNode syntaxRoot);
2424
}
@@ -28,15 +28,15 @@ internal interface ISyntaxFormattingRule
2828
/// used for rules that need to see a <see cref="Document"/> and <see cref="SyntaxNode"/> which
2929
/// are in sync with each other,
3030
/// </summary>
31-
internal interface ILocalSemanticFormattingRule
31+
internal interface ILocalSemanticFormattingRule : IFormattingRule
3232
{
3333
Task<SyntaxNode> ProcessAsync(Document document, SyntaxNode syntaxRoot, CancellationToken cancellationToken);
3434
}
3535

3636
/// <summary>
3737
/// Rules which can affect more than the local document
3838
/// </summary>
39-
internal interface IGlobalSemanticFormattingRule
39+
internal interface IGlobalSemanticFormattingRule : IFormattingRule
4040
{
4141
Task<Solution> ProcessAsync(Document document, SyntaxNode syntaxRoot, CancellationToken cancellationToken);
4242
}

src/Microsoft.DotNet.CodeFormatting/Rules/HasNoIllegalHeadersFormattingRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Microsoft.DotNet.CodeFormatting.Rules
1717
{
18-
[RuleOrder(RuleOrder.HasNoIllegalHeadersFormattingRule)]
18+
// [RuleOrder(RuleOrder.HasNoIllegalHeadersFormattingRule)]
1919
internal sealed class HasNoIllegalHeadersFormattingRule
2020
{
2121
// We are going to replace this header with the actual filename of the document being processed

0 commit comments

Comments
 (0)