Skip to content

Commit

Permalink
LSP Razor formatting for Razor code block directives (dotnet/razor#1573)
Browse files Browse the repository at this point in the history
LSP Razor formatting for Razor code block directives
- Support for @code/@functions block formatting
    - Except when it contains Markup or other Razor constructs
- Added a RazorFormattingService which is invoked by the RazorFormattingEndpoint.
- Added a custom razor/rangeFormatting command that the server can use to ask the client to format a range of the projected C# or HTML document
- Added a CSharpFormatter and HTMLFormatter that invoke the above mentioned command
- Added FormattingSpan and its corresponding visitor to represent Razor understanding of indentation
- Moved the document mapping code to a separate RazorDocumentMappingService service for ease of use
- Added necessary extension methods for convenience. Some of them were copied from Roslyn
- Some cleanup
- Added a C# test formatter to enable unit testing. Right now it calls Roslyn APIs directly. As far as I've seen its behavior is the same as OmniSharp formatting except it doesn't remove trailing whitespace and empty lines. I am following up with people to understand why that is the case.
Added/updated tests
\n\nCommit migrated from dotnet/razor@62051b9

Commit migrated from dotnet/aspnetcore@f1ccf855ebfc
  • Loading branch information
ajaybhargavb authored Feb 14, 2020
1 parent 5458213 commit 9204abf
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ internal class ClassifiedSpanVisitor : SyntaxWalker

public ClassifiedSpanVisitor(RazorSourceDocument source)
{
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}

_source = source;
_spans = new List<ClassifiedSpanInternal>();
_currentBlockKind = BlockKindInternal.Markup;
Expand Down

0 comments on commit 9204abf

Please sign in to comment.