Skip to content

Shorten type annotation for Code Lens + small fixes - #5145

Merged
KevinRansom merged 18 commits into
dotnet:masterfrom
realvictorprm:codelensfixes
Mar 11, 2020
Merged

KevinRansom merged 18 commits into
dotnet:masterfrom
realvictorprm:codelensfixes

Conversation

@realvictorprm

Copy link
Copy Markdown
Contributor

This shorts the type annotation so that prior e.g. override or member or new isn't shown anymore for member functions.

@realvictorprm realvictorprm changed the title Shorten type annotation for Code Lens Shorten type annotation for Code Lens + small fixes Jun 8, 2018
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
@realvictorprm

Copy link
Copy Markdown
Contributor Author

This is kind of a hotfix for the Code Lens. It fixes the appearance of them (shorten) and fixes the caching algorithm so we don't loose any Code Lens. I've created those fixes already months ago but due to that @cartermp or someone else commited changes to my branch I didn't found them anymore.

Anyways I was able to extract the important changes and checked that they still work.

I'm aware of the missalignment of the Code Lens if scrolled too fast e.g. with mouse but I have not enough time right now to investigate that.

@cartermp this is ready!

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test this please

@KevinRansom

Copy link
Copy Markdown
Contributor

@realvictorprm. We are now in escrow, so the turn around time, for the dev15.8 branch is going to be much higher for a while.

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@KevinRansom can we please merge this. Those fixes are crucial for the caching and will solve at least part of the existing issues.

@cartermp

cartermp commented Jun 9, 2018 •

Copy link
Copy Markdown
Contributor

This counts as a bug fix, but it will need to be validated/reviewed and bundled with other bug fixes that will require approval to merge and insert into the product. Because of that, we cannot say for sure that it will be merged in time, but we'll strive to make it happen.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
@realvictorprm

Copy link
Copy Markdown
Contributor Author

@cartermp This also fixes now #5138

In my opinion this bug fix is important for the experimental feature. I don't want that people won't try it anymore due to the initial bugs.

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@KevinRansom the layout but was introduced by the tweaks. A single wrong field access caused that adornments on non visibile lines aren't hidden, only those on the last recent visible line.

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test this please

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@cartermp can we at least merge this for the next version? Would be great!

Comment thread src/fsharp/NicePrint.fs Resolved
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
@realvictorprm

Copy link
Copy Markdown
Contributor Author

@dsyme @KevinRansom @cartermp applied review and suggestions from both the issue and here. This is ready, please do another last review and if it's fine please merge soon.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
correcting wrong parameter for layoutOfPrettyMember
@realvictorprm

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test Windows_NT Release_ci_part1 Build please

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@cartermp fixed

@cartermp cartermp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good on a first pass. Some requests and questions below.

Comment thread src/fsharp/NicePrint.fs Resolved
Comment thread src/fsharp/NicePrint.fs Resolved
@realvictorprm

Copy link
Copy Markdown
Contributor Author

OK thank you for letting me know.

@dsyme, @KevinRansom is this now fine to merge?

@realvictorprm

Copy link
Copy Markdown
Contributor Author

ping, request confirmation

@chadunit

chadunit commented Jan 6, 2019

Copy link
Copy Markdown

CodeLens would be a great feature to have working but IMO it really needs this fix for the misplaced annotations, see #5138, #5960, #6066. Any chance of bumping priority on this?

@realvictorprm

Copy link
Copy Markdown
Contributor Author

@chadunit we need to wait another year :p

@realvictorprm

Copy link
Copy Markdown
Contributor Author

OK just forget about this PR. I'll close it myself as nobody important cares :)

@realvictorprm

Copy link
Copy Markdown
Contributor Author

one time again, maybe you now have some time to recheck this and finally decide to merge it. Would be great :)

@realvictorprm realvictorprm reopened this Apr 25, 2019
@realvictorprm

Copy link
Copy Markdown
Contributor Author

Geez I'll have a look into those merge conflicts :/

@cartermp

Copy link
Copy Markdown
Contributor

@KevinRansom Let's try to get this one reviewed and in

@Happypig375

Copy link
Copy Markdown
Member

Yeah, try for literally a month...

@cartermp

cartermp commented Jun 8, 2019

Copy link
Copy Markdown
Contributor

@happypig being passive aggressive is neither appreciated nor will it achieve your goals.

@Happypig375

Copy link
Copy Markdown
Member

Lots of nice comments by @realvictorprm as seen above also didn't achieve goals. What kind of comment would push this forward, if I may ask?

@cartermp

Copy link
Copy Markdown
Contributor

Awaiting @KevinRansom's review

@realvictorprm

Copy link
Copy Markdown
Contributor Author

Thank you

@realvictorprm

Copy link
Copy Markdown
Contributor Author

All checks have passed :)

let fullTypeSignature = func.FullType.ToString()
// Try to re-use the last results
if lastResults.ContainsKey fullDeclarationText then
if lastResults.ContainsKey funcID then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you're hashing the text, should lastResults have its key be an int rather than a string? This would avoid an extra allocation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we want to minimize allocations I need to look into this again.

Maybe it would be enough to make a dictionary which maps from function name to the hash of the full type (last time it was used) and then only compare the value/hash of the last type to change only the code lens above functions which type has really changed. Would that allocate less?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally no, it's preferable not to use a string as a key if you can get away with it. Although it's still all small allocations, if you're already hashing something then that would be adequate for a key.

Though generally it's recommended to use more information than just a hash for a key, since there can be hash collisions.

Alternatively, does this caching provide any notable benefits? That is, if nothing was cached, does it meaningfully affect UX when used?

@realvictorprm realvictorprm Jun 26, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Of course, I wouldn't apply it if it wouldn't be of benefit :D
The current problem is that the key isn't unqiue which results in code lenses which aren't removed.

I think about removing the |> hash as it's better to hash the whole string anyways (so no hash collisions, thanks for the reminder btw). Currently I cannot see any possibility to remove the usage of a string as key. The small allocation is still much better than what would result in not using the cache (because that's what you get if you don't want it :D).

Comment thread src/fsharp/NicePrint.fs
let private prettyLayoutOfMember denv typarInst (v: Val) =
module private PrintTastMemberOrVals =
open PrintTypes
let private prettyLayoutOfMemberShortOption denv typarInst (v:Val) short =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this is a private function I think it's fine to leave the name as-is and just have the additional flag. Perhaps rename the flag to shortMemberDisplay?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok will do. Thanks :)

@KevinRansom KevinRansom closed this Mar 7, 2020
@KevinRansom KevinRansom reopened this Mar 7, 2020

@KevinRansom KevinRansom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I only re-discovered this last night, I am soooo sorry it dropped off my radar.

Thanks for doing this

Kevin

@KevinRansom
KevinRansom merged commit 8ed8651 into dotnet:master Mar 11, 2020
@realvictorprm

Copy link
Copy Markdown
Contributor Author

@KevinRansom thank you very much for merging 👍

I guess meanwhile the UI related stuff could be replaced with the official code lens API. That should at least prevent any position issues and scrolling. However right now that is super off my limits.

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* Short type annotation.

* fix caching to avoid any duplicates.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Fixing layout bug.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Wrapping all warning logging messages with #if Debug

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Removed code duplication / applied review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* fixing build

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Update NicePrint.fs

correcting wrong parameter for layoutOfPrettyMember

* fixing build

* Applying review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Applied review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Fix merge

* Fix fsharpcodelensservice.fs

* Syntax fix for release mode

Co-authored-by: Phillip Carter <pcarter@fastmail.com>
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* Short type annotation.

* fix caching to avoid any duplicates.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Fixing layout bug.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Wrapping all warning logging messages with #if Debug

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Removed code duplication / applied review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* fixing build

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Update NicePrint.fs

correcting wrong parameter for layoutOfPrettyMember

* fixing build

* Applying review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Applied review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Fix merge

* Fix fsharpcodelensservice.fs

* Syntax fix for release mode

Co-authored-by: Phillip Carter <pcarter@fastmail.com>
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* Short type annotation.

* fix caching to avoid any duplicates.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Fixing layout bug.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Wrapping all warning logging messages with #if Debug

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Removed code duplication / applied review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* fixing build

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Update NicePrint.fs

correcting wrong parameter for layoutOfPrettyMember

* fixing build

* Applying review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Applied review.

Signed-off-by: realvictorprm <mueller.vpr@gmail.com>

* Fix merge

* Fix fsharpcodelensservice.fs

* Syntax fix for release mode

Co-authored-by: Phillip Carter <pcarter@fastmail.com>
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.

7 participants