Skip to content

Fix detection of nested symbols in Document Outline#68107

Merged
sharwell merged 1 commit intodotnet:mainfrom
sharwell:nested-symbol
May 15, 2023
Merged

Fix detection of nested symbols in Document Outline#68107
sharwell merged 1 commit intodotnet:mainfrom
sharwell:nested-symbol

Conversation

@sharwell
Copy link
Copy Markdown
Contributor

@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
@ghost ghost 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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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
=> new LinePosition(position.Line, position.Character);

public static LinePositionSpan RangeToLinePositionSpan(LSP.Range range)
=> new(PositionToLinePosition(range.Start), PositionToLinePosition(range.End));
Copy link
Copy Markdown
Contributor 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

{
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
Copy Markdown
Contributor 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