-
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
Address layering of navigation action in code actions #59856
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,8 @@ | |
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.Threading; | ||
using Microsoft.CodeAnalysis.Navigation; | ||
using Microsoft.CodeAnalysis.Shared.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.CodeActions | ||
{ | ||
|
@@ -21,25 +17,18 @@ namespace Microsoft.CodeAnalysis.CodeActions | |
/// </summary> | ||
public class DocumentNavigationOperation : CodeActionOperation | ||
{ | ||
private readonly DocumentId _documentId; | ||
private readonly int _position; | ||
internal DocumentId DocumentId { get; } | ||
internal int Position { get; } | ||
|
||
public DocumentNavigationOperation(DocumentId documentId, int position = 0) | ||
{ | ||
_documentId = documentId ?? throw new ArgumentNullException(nameof(documentId)); | ||
_position = position; | ||
DocumentId = documentId ?? throw new ArgumentNullException(nameof(documentId)); | ||
Position = position; | ||
} | ||
|
||
public override void Apply(Workspace workspace, CancellationToken cancellationToken) | ||
{ | ||
CyrusNajmabadi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (workspace.CanOpenDocuments) | ||
{ | ||
var navigationService = workspace.Services.GetService<IDocumentNavigationService>(); | ||
var threadingService = workspace.Services.GetService<IWorkspaceThreadingServiceProvider>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you delete IWorkspaceThreadingServiceProvider or did something else still use it too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately, unit testing and TS are still using it in exactly 2 locations. |
||
|
||
threadingService.Service.Run( | ||
() => navigationService.TryNavigateToPositionAsync(workspace, _documentId, _position, cancellationToken)); | ||
} | ||
// Intentionally empty. Handling of this operation is special cased in CodeActionEditHandlerService.cs | ||
} | ||
} | ||
} |
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.
Consider SingleOrDefault, since if we have more than one I'm suspicious about what happened there.
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.
well SingleOrDefault throws... and that worries me about somethign potentially throwing now taht just had wonky behavior before.