Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbrandenburg committed Aug 28, 2020
1 parent 4446f6e commit 0790f9b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private RazorLanguageServer(ILanguageServer innerServer)

public Task WaitForExit => _innerServer.WaitForExit;

public Task InitializedAsync(CancellationToken token) => _innerServer.InitializedAsync(token);
public Task InitializedAsync(CancellationToken token) => _innerServer.Initialize(token);

public static Task<RazorLanguageServer> CreateAsync(Stream input, Stream output, Trace trace, Action<RazorLanguageServerBuilder> configure = null)
{
Expand All @@ -70,6 +70,16 @@ public static Task<RazorLanguageServer> CreateAsync(Stream input, Stream output,
options
.WithInput(input)
.WithOutput(output)
// StreamJsonRpc has both Serial and Parallel requests. With WithContentModifiedSupport(true) (which is default) when a Serial
// request is made any Parallel requests will be cancelled because the assumption is that Serial requests modify state, and that
// therefore any Parallel request is now invalid and should just try again. A specific instance of this can be seen when you
// hover over a TagHelper while the switch is set to true. Hover is parallel, and a lot of our endpoints like
// textDocument/_ms_onAutoInsert, and razor/languageQuery are Serial. I BELIEVE that specifically what happened is the serial
// languageQuery event gets fired by our semantic tokens endpoint (which fires constantly), cancelling the hover, which red-bars.
// We can prevent that behavior entirely by doing WithContentModifiedSupport, at the possible expense of some delays due doing all requests in serial.
//
// I recommend that we attempt to resolve this and switch back to WithContentModifiedSupport(true) in the future,
// I think that would mean either having 0 Serial Handlers in the whole LS, or making VSLanguageServerClient handle this more gracefully.
.WithContentModifiedSupport(false)
.WithSerializer(Serializer.Instance)
.ConfigureLogging(builder => builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,26 @@ private bool ClassifyTagName(MarkupTagHelperElementSyntax node)

private SemanticRange CreateSemanticRange(SyntaxNode node, SyntaxKind kind)
{
int kindUint;
int semanticKind;
switch (kind)
{
case SyntaxKind.MarkupTagHelperDirectiveAttribute:
case SyntaxKind.MarkupMinimizedTagHelperDirectiveAttribute:
kindUint = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorDirectiveAttribute];
semanticKind = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorDirectiveAttribute];
break;
case SyntaxKind.MarkupTagHelperStartTag:
case SyntaxKind.MarkupTagHelperEndTag:
kindUint = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorTagHelperElement];
semanticKind = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorTagHelperElement];
break;
case SyntaxKind.MarkupTagHelperAttribute:
case SyntaxKind.MarkupMinimizedTagHelperAttribute:
kindUint = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorTagHelperAttribute];
semanticKind = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorTagHelperAttribute];
break;
case SyntaxKind.Transition:
kindUint = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorTransition];
semanticKind = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorTransition];
break;
case SyntaxKind.Colon:
kindUint = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorDirectiveColon];
semanticKind = RazorSemanticTokensLegend.TokenTypesLegend[RazorSemanticTokensLegend.RazorDirectiveColon];
break;
default:
throw new NotImplementedException();
Expand All @@ -208,7 +208,7 @@ private SemanticRange CreateSemanticRange(SyntaxNode node, SyntaxKind kind)
var source = _razorCodeDocument.Source;
var range = node.GetRange(source);

var result = new SemanticRange(kindUint, range);
var result = new SemanticRange(semanticKind, range);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ internal DefaultRazorLanguageServerCustomMessageTarget(TrackingLSPDocumentManage

public override async Task UpdateCSharpBufferAsync(UpdateBufferRequest request, CancellationToken cancellationToken)
{
if (request is null){
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}

Expand All @@ -89,7 +90,8 @@ internal void UpdateCSharpBuffer(UpdateBufferRequest request)

public override async Task UpdateHtmlBufferAsync(UpdateBufferRequest request, CancellationToken cancellationToken)
{
if (request is null){
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ internal class InitializeHandler : IRequestHandler<InitializeParams, InitializeR
SemanticTokensOptions = new SemanticTokensOptions()
{
RangeProvider = true,
DocumentProvider = new SemanticTokensDocumentProviderOptions() {
DocumentProvider = new SemanticTokensDocumentProviderOptions()
{
Edits = true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.FileSystemGlobbing.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.FileProviders.Abstractions.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.FileProviders.Physical.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="System.IO.Pipelines.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="System.Reactive.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.LanguageServer.Common.dll" />
Expand Down

0 comments on commit 0790f9b

Please sign in to comment.