Skip to content
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

Merged
merged 3 commits into from
Jun 6, 2018

Conversation

bjorkstromm
Copy link
Member

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))
Copy link
Contributor

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.

Copy link
Member Author

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 &&
Copy link
Contributor

@DustinCampbell DustinCampbell Jun 5, 2018

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;
}

Copy link
Member Author

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;
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. Thanks!

Copy link
Member

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 👍

Copy link
Member Author

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/

@bjorkstromm
Copy link
Member Author

@DustinCampbell addressed feedback and rebased!

Copy link
Contributor

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DustinCampbell DustinCampbell merged commit 36491de into OmniSharp:master Jun 6, 2018
@bjorkstromm bjorkstromm deleted the feature/GH-1205 branch June 6, 2018 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants