LSP Razor formatting for Razor code block directives (dotnet/aspnetcore-tooling#1573)

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 62051b9ad7
This commit is contained in:
Ajay Bhargav B 2020-02-13 16:37:15 -08:00 committed by GitHub
parent 3bf16941eb
commit f1ccf855eb
1 changed files with 5 additions and 0 deletions

View File

@ -18,6 +18,11 @@ namespace Microsoft.AspNetCore.Razor.Language
public ClassifiedSpanVisitor(RazorSourceDocument source)
{
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
_source = source;
_spans = new List<ClassifiedSpanInternal>();
_currentBlockKind = BlockKindInternal.Markup;