Skip to content

Commit 55725f4

Browse files
pattern match fail
1 parent 65ceeae commit 55725f4

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/Lsp/LspRequestRouter.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,34 @@ private ILspHandlerDescriptor FindDescriptor(string method, JToken @params)
5454
return null;
5555
}
5656

57-
if (typeof(ITextDocumentIdentifierParams).GetTypeInfo().IsAssignableFrom(descriptor.Params))
57+
if (@params != null && descriptor.Params != null)
5858
{
59-
var textDocumentIdentifierParams = @params.ToObject(descriptor.Params) as ITextDocumentIdentifierParams;
60-
var attributes = GetTextDocumentAttributes(textDocumentIdentifierParams.TextDocument.Uri);
59+
var paramsValue = @params.ToObject(descriptor.Params);
60+
if (paramsValue is ITextDocumentIdentifierParams textDocumentIdentifierParams)
61+
{
62+
var attributes = GetTextDocumentAttributes(textDocumentIdentifierParams.TextDocument.Uri);
6163

62-
_logger.LogTrace("Found attributes {Count}, {Attributes}", attributes.Count, attributes.Select(x => $"{x.LanguageId}:{x.Scheme}:{x.Uri}"));
64+
_logger.LogTrace("Found attributes {Count}, {Attributes}", attributes.Count, attributes.Select(x => $"{x.LanguageId}:{x.Scheme}:{x.Uri}"));
6365

64-
return GetHandler(method, attributes);
65-
}
66-
else if (@params?.ToObject(descriptor.Params) is DidOpenTextDocumentParams openTextDocumentParams)
67-
{
68-
var attributes = new TextDocumentAttributes(openTextDocumentParams.TextDocument.Uri, openTextDocumentParams.TextDocument.LanguageId);
66+
return GetHandler(method, attributes);
67+
}
68+
else if (paramsValue is DidOpenTextDocumentParams openTextDocumentParams)
69+
{
70+
var attributes = new TextDocumentAttributes(openTextDocumentParams.TextDocument.Uri, openTextDocumentParams.TextDocument.LanguageId);
6971

70-
_logger.LogTrace("Created attribute {Attribute}", $"{attributes.LanguageId}:{attributes.Scheme}:{attributes.Uri}");
72+
_logger.LogTrace("Created attribute {Attribute}", $"{attributes.LanguageId}:{attributes.Scheme}:{attributes.Uri}");
7173

72-
return GetHandler(method, attributes);
73-
}
74-
else if (@params?.ToObject(descriptor.Params) is DidChangeTextDocumentParams didChangeDocumentParams)
75-
{
76-
// TODO: Do something with document version here?
77-
var attributes = GetTextDocumentAttributes(didChangeDocumentParams.TextDocument.Uri);
74+
return GetHandler(method, attributes);
75+
}
76+
else if (paramsValue is DidChangeTextDocumentParams didChangeDocumentParams)
77+
{
78+
// TODO: Do something with document version here?
79+
var attributes = GetTextDocumentAttributes(didChangeDocumentParams.TextDocument.Uri);
7880

79-
_logger.LogTrace("Found attributes {Count}, {Attributes}", attributes.Count, attributes.Select(x => $"{x.LanguageId}:{x.Scheme}:{x.Uri}"));
81+
_logger.LogTrace("Found attributes {Count}, {Attributes}", attributes.Count, attributes.Select(x => $"{x.LanguageId}:{x.Scheme}:{x.Uri}"));
8082

81-
return GetHandler(method, attributes);
83+
return GetHandler(method, attributes);
84+
}
8285
}
8386

8487
// TODO: How to split these

0 commit comments

Comments
 (0)