Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduce new refactoring code actions based on the Swift syntax tree. #1179
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
Introduce new refactoring code actions based on the Swift syntax tree. #1179
Changes from all commits
a8b61a5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Could you add a test case for this, checking that the refactoring do actually show up when retrieving code actions? Ie. a test in https://github.com/apple/sourcekit-lsp/blob/main/Tests/SourceKitLSPTests/CodeActionTests.swift
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’d prefer to fail the creation of
SyntaxCodeActionScope
and emit alogger.fault
if we can’t find a token at a specific position. It’s the kind of thing where things start failing and then it’s hard to track down what’s going wrong if there’s no logging.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.
Should we traverse the parents until we find a node of type
Input
? That way you don’t need to start eg. aMigrateToNewIfLetSyntax
refactoring on theif
token but you could also start it from within the condition or the body (not sure if we want the latter though, maybe we should stop the traversal at some pre-defined nodes likeCodeBlockItemListSyntax
andMemberBlockItemListSyntax
to prevent that).Similarly, the
OpaqueParameterToGeneric
refactoring action can’t currently be invoked from one of thesome
types, which might be confusing.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'm wondering if this is something that should be handled by the
MigrateToNewIfLetSyntax
,OpaqueParameterToGeneric
, etc., refactorings themselves, because we don't necessarily know how far out in the tree we should go.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.
That seems reasonable.
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’d prefer to format this as
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 think you should pass
callerFile
andcallerLine
intoposition(of:)
so that the logger fault message contains the file and line number that is the real originator if position conversion fails.