-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support code folding for argument lists #71064
Support code folding for argument lists #71064
Conversation
@CyrusNajmabadi Could you review this small PR? (assuming the linked issue is something you want to fix) |
using Microsoft.CodeAnalysis.Shared.Collections; | ||
using Microsoft.CodeAnalysis.Structure; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file scoped namespace.
"""; | ||
|
||
await VerifyBlockSpansAsync(code); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test with just two args on different lines.
var code = """ | ||
var x = M$${|span:( | ||
"", | ||
"")|}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the experience you have in the IDE if you have:
var v = M(N(
"",
""));
In other words, how does nesting impact things, when the outer/inner are on the same start/end lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CyrusNajmabadi I wasn't able to get RoslynDeployment work properly. https://www.youtube.com/watch?v=ND8dDO6oJ4U see around 38:00
I'll try this out locally. |
@CyrusNajmabadi Is it better now? |
return; | ||
} | ||
|
||
switch (_count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.sort?view=net-8.0 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically:
Span<T> span = MemoryMarshal.CreateSpan(ref _item0, this.Count);
span.Sort(comparison);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not available in netstandard2.0 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah. @stephentoub Any recommendations on how to best sort a span in netstandard2.0?
@@ -205,6 +206,69 @@ public void TestReverseContents([CombinatorialRange(0, 6)] int initialItems) | |||
Assert.Equal(array[i], initialItems - 1 - i); | |||
} | |||
|
|||
[Fact] | |||
public void TestSort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would take everything out related to sorting TempArray. We don't even relaly need temparray for block-structure. That's an array that's good when you commonly have <4 elements. But for block structure, we'd almost alwayshave more. So we can just pass an ArrayBuilder along instead).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, we can keep this. i'm on the fence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CyrusNajmabadi I had the same feeling the TemporaryArray might not be very suitable for this scenario, but I preferred to limit the scope of my changes.
src/Features/Core/Portable/Structure/Syntax/AbstractBlockStructureProvider.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes under Compilers LGTM (commit 9)
…tureProvider.cs Co-authored-by: Cyrus Najmabadi <[email protected]>
@@ -54,7 +54,7 @@ using System.Linq;|}", "imports", "...")> | |||
</Workspace>, openDocuments:=False, composition:=TestLsifOutput.TestComposition) | |||
|
|||
Dim annotatedLocations = Await AbstractLanguageServerProtocolTests.GetAnnotatedLocationsAsync(workspace, workspace.CurrentSolution) | |||
Dim expectedRanges = annotatedLocations("foldingRange").Select(Function(location) CreateFoldingRange(rangeKind, location.Range, collapsedText)).OrderBy(Function(range) range.StartLine).ToArray() | |||
Dim expectedRanges = annotatedLocations("foldingRange").Select(Function(location) CreateFoldingRange(rangeKind, location.Range, collapsedText)).OrderByDescending(Function(range) range.StartLine).ToArray() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of the returned spans changed with the changes in this PR. I think the order shouldn't matter. So, I updated this test (and some others) to assert against the new order.
I think the tests could even ignore the order when comparing, but I didn't do that for now.
@CyrusNajmabadi Let me know your thoughts.
@CyrusNajmabadi Can you take a look please? Thanks! |
@CyrusNajmabadi Friendly reminder on this PR. Thanks! |
Yup yup. Thanks for the reminder! |
Fixes #67929