-
Notifications
You must be signed in to change notification settings - Fork 418
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
GH1205: Add support for code actions in Cake #1212
Conversation
bjorkstromm
commented
Jun 4, 2018
- Fixes [Cake] Code actions not working #1205
CHANGELOG.md
Outdated
@@ -1,6 +1,9 @@ | |||
# Changelog | |||
All changes to the project will be documented in this file. | |||
|
|||
## [1.32.0] - _Not Yet Released_ | |||
* Added support for code actions in `.cake` files. ([#1205](https://github.com/OmniSharp/omnisharp-roslyn/issues/1205)) |
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 won the merge race. This will probably have a conflict.
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.
Good that I caught my eyes on the /codestructure
PR. We need to create a Cake endpoint for that too.. Created issue here #1214
foreach (var change in changes) | ||
{ | ||
|
||
if (!(fileOperations.FirstOrDefault(x => x.FileName == change.Key && |
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.
You could just invert this to avoid having a continue
and an ugly !
before a pattern match. E.g.
if (fileOperations.FirstOrDefault(x => x.FileName == change.Key && x.ModificationType == FileModificationType.Modified) is ModifiedFileResponse modifiedFile)
{
modifiedFile.Changes = change.Value;
}
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.
Yes, will fix this!
continue; | ||
} | ||
|
||
modifiedFile.Changes = change.Value; |
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.
This means that modifiedFile.Changes
will only ever have the last matching value. Is that intentional or should there by some sort of merging?
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.
No, change
is of type KeyValuePair<string, List<LinePositionSpanTextChange>>
and the dictionary it's contained in is populated above, using the PopulateModificationsAsync
.
This is the same thing we do with rename responses also. it's ugly, but due to the fact that loaded scripts are "merged" into the base script we might end up in a situation where a ModifiledFileResponse
contains modifications belonging to a different file. This is what we are trying to fix in this method, e.g. loop through all modifications, map line numbers and assign them to the correct ModifiedFileResponse
.
Someday, Cake should not "copy & paste" loaded script contents in the base file and instead use #load
as provided by Roslyn scripting.
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.
got it. Thanks!
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.
Someday, Cake should not "copy & paste" loaded script contents in the base file and instead use #load as provided by Roslyn scripting.
this 👍
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.
@filipw I see somebody has already written a blog post that will help me getting started 😉 https://www.strathweb.com/2016/06/implementing-custom-load-behavior-in-roslyn-scripting/
b6f5afc
to
635e66a
Compare
@DustinCampbell addressed feedback and rebased! |
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.
LGTM