Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detection of nested symbols in Document Outline #68107

Merged
merged 1 commit into from
May 15, 2023

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented May 4, 2023

Fixes #66012
Fixes #66473

@sharwell sharwell requested a review from a team as a code owner May 4, 2023 23:30
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 4, 2023
{
var parentRange = ProtocolConversions.RangeToLinePositionSpan(parent.Range);
var childRange = ProtocolConversions.RangeToLinePositionSpan(child.Range);
return childRange.Start > parentRange.Start && childRange.End <= parentRange.End;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 This is a move from comparing line number to comparing position number. Since the LSP Position type didn't support the comparison, we convert to a Roslyn TextPosition which provides the > and <= operators.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh jeez. yeah.

@sharwell sharwell added IDE-Navigation Navigation and search Navigation-Document Outline label to groups issues reported for the document outline feature and removed untriaged Issues and PRs which have not yet been triaged by a lead labels May 4, 2023
@dotnet dotnet deleted a comment from azure-pipelines bot May 12, 2023
@dotnet dotnet deleted a comment from azure-pipelines bot May 12, 2023
@@ -194,9 +194,12 @@ public static LSP.VersionedTextDocumentIdentifier DocumentToVersionedTextDocumen
public static LinePosition PositionToLinePosition(LSP.Position position)
=> new LinePosition(position.Line, position.Character);

public static LinePositionSpan RangeToLinePositionSpan(LSP.Range range)
=> new(PositionToLinePosition(range.Start), PositionToLinePosition(range.End));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 This is a restoration of a helper method that was recently removed in #68081 due to lack of use

@@ -107,7 +107,7 @@ protected async Task<DocumentOutlineTestMocks> CreateMocksAsync(string code)
async Task<ManualInvocationResponse?> RequestAsync(ITextBuffer textBuffer, Func<JToken, bool> capabilitiesFilter, string languageServerName, string method, Func<ITextSnapshot, JToken> parameterFactory, CancellationToken cancellationToken)
{
var request = parameterFactory(textBuffer.CurrentSnapshot).ToObject<RoslynDocumentSymbolParams>();
var response = await testLspServer.ExecuteRequestAsync<RoslynDocumentSymbolParams, DocumentSymbol[]>(method, request!, cancellationToken);
var response = await testLspServer.ExecuteRequestAsync<RoslynDocumentSymbolParams, object[]>(method, request!, cancellationToken);
Copy link
Member Author

@sharwell sharwell May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 The tests took longer than expected to write because this mock isn't the real call and didn't match the signature of the real call:

public async Task<object[]> HandleRequestAsync(RoslynDocumentSymbolParams request, RequestContext context, CancellationToken cancellationToken)

The use of DocumentSymbol[] was forcing it to serialize DocumentSymbol items, which is a base type of the actual RoslynDocumentSymbol items contained in this array, so all the items in the tests failed to have the Glyph property set.

@sharwell sharwell enabled auto-merge May 12, 2023 23:15
@sharwell sharwell merged commit ce19d97 into dotnet:main May 15, 2023
@ghost ghost added this to the Next milestone May 15, 2023
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE IDE-Navigation Navigation and search Navigation-Document Outline label to groups issues reported for the document outline feature
Projects
None yet
3 participants