Skip to content

Commit

Permalink
Pass solution
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Mar 11, 2022
1 parent f1322cf commit b657e22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ private static async Task<TextEdit[]> FormatOnServerAsync(
var csharpDocument = context.CSharpWorkspaceDocument;
var csharpSourceText = context.CodeDocument.GetCSharpSourceText();
var spanToFormat = projectedRange.AsTextSpan(csharpSourceText);
var root = await context.CSharpWorkspaceDocument.GetSyntaxRootAsync(cancellationToken);
Assumes.NotNull(root);

var changes = await RazorCSharpFormattingInteractionService.GetFormattedTextChangesAsync(csharpDocument, spanToFormat, context.Options.GetIndentationOptions(), cancellationToken).ConfigureAwait(false);
var changes = RazorCSharpFormattingInteractionService.GetFormattedTextChanges(csharpDocument.Project.Solution, root, spanToFormat, context.Options.GetIndentationOptions(), cancellationToken);

var edits = changes.Select(c => c.AsTextEdit(csharpSourceText)).ToArray();
return edits;
Expand All @@ -121,7 +123,7 @@ private static async Task<Dictionary<int, int>> GetCSharpIndentationCoreAsync(Fo

// At this point, we have added all the necessary markers and attached annotations.
// Let's invoke the C# formatter and hope for the best.
var formattedRoot = await RazorCSharpFormattingInteractionService.FormatAsync(context.CSharpWorkspaceDocument, root, context.Options.GetIndentationOptions(), cancellationToken: cancellationToken);
var formattedRoot = RazorCSharpFormattingInteractionService.Format(context.CSharpWorkspaceDocument.Project.Solution, root, context.Options.GetIndentationOptions(), cancellationToken);
var formattedText = formattedRoot.GetText();

var desiredIndentationMap = new Dictionary<int, int>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Microsoft.CodeAnalysis.Razor.Workspaces\IsExternalInit.cs" Link="IsExternalInit.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj" />
</ItemGroup>
Expand Down

0 comments on commit b657e22

Please sign in to comment.