-
Notifications
You must be signed in to change notification settings - Fork 842
Implement FSharpQuickInfoProvider (by @OmarTawfik) #1849
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
Conversation
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.
Replace with |> CommonRoslynHelpers.StartAsyncAsTask cancellationToken now please
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.
In the GotoDefinition implementation we now have
match classifiedSpan.ClassificationType with
| ClassificationTypeNames.ClassName
| ClassificationTypeNames.DelegateName
| ClassificationTypeNames.EnumName
| ClassificationTypeNames.InterfaceName
| ClassificationTypeNames.ModuleName
| ClassificationTypeNames.StructName
| ClassificationTypeNames.TypeParameterName
| ClassificationTypeNames.Identifier ->
So I'm assuming quickinfo won't work at operators with this PR.
I think you should abstract out the tryClassifyAtPosition implementation and use it in both places.
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.
Done.
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.
Why are these needed? thx
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.
PresentationFrameword is needed for Label type.
WindowsBase is for FrameworkElement.
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.
ok
|
Could you add one or two unit tests that exercises |
|
@vasily-kirichenko Absolutely fantastic to see this in place. |
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.
The C# and VB implementations have very different constructor signatures?
Perhaps that's the reason for the composition error?
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.
Please note I understand nothing about MEF composition :/
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, C# provider imports other dependencies, but I don't think it's the problem. We successfully import SVsServiceProvider in several places. I don't know much about MEF either :(
b8cc1b9 to
ed912f4
Compare
I'd like to make it work first. I still throws exception. |
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.
Did this work?
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, it works now.
|
It kind of works now. The tooltip is always positioned below all visible text, not close to the symbol. |
|
@vasily-kirichenko Yeah, getting the positioning right is really important. |
|
Great to see the progress! |
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 don't think this cache works given that CWT referential identity of an object as a 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.
Ah ok. That was my code. Needs to be fixed
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.
@vasily-kirichenko Could you check the identity used by ConditionalWeakTable and see if it uses .Equals and .GetHashCode or just object identity? Probably the latter. Thanks. (Not sure if there's any good key available in that case, maybe just remove this CWT for now)
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.
Looks like it's pure hash table https://referencesource.microsoft.com/#mscorlib/system/runtime/compilerservices/ConditionalWeakTable.cs,464
Is it ok or I should remove the cache?
|
@vasily-kirichenko See #1855 for one methodology to add tests. I particularly like to write tests without using the |
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 remove these changes from the PR please? Presumably the lines are needed. Just remove them locally
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.
These lines prevents the project to be load in VS.
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.
Yep, I know. But we shouldn't check in their removal until we find out what they are for. People working on master who want to load FSHarp.Compiler into VS can just remove them by hand until tomorrow, 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.
Please just use single line formatting for 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.
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.
Please use single line formatting for this - multi-line is not useful - it's basically a record in any case
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.
Likewise - single line please
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.
Please use new Label(Content=content, Foreground=SolidColorBrush(Colors.Black))
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.
Single line signature please
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.
Please use ParseAndCheckFileInProject (see #1855 )
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.
What is 189? The tokenTag I guess. I think you can use tagOfToken on an identifier
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.
Please just use null given this is implementing a C# interface
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.
(Or use None followed by Option.toObj at the end)
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.
Single line signature please
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.
(or formatted like the original)
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.
Maybe minimize the diff in this method? Many of the changes are formatting
|
@vasily-kirichenko This looks great. I left a bunch of fairly minor comments. |
dsyme
left a comment
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.
see requested changes (Relatively minor)
|
I've ported somewhat hacky code from VFPT to get current theme colors (https://github.com/fsprojects/VisualFSharpPowerTools/blob/03c613acd3aa67cb5e3a339d3dcf1c7c783f30c2/src/FSharp.Editing.VisualStudio/Common/VSColors.fs) It works: If anybody knows a better way to do it, please tell us. |
|
Awesome! |
|
This is fantastic. Looks ready to go to me, once green |
|
@vasily-kirichenko Thank you! |
Yes, that's an object identity hash, not a call to obj.GetHashCode(). We should remove the cache for now |
|
@dsyme we don't have control over errors formatting. |
A long needed and overdue feature 😄 |
| open System.Reflection | ||
| open Microsoft.VisualStudio.Shell | ||
| open System.Windows.Controls | ||
| // A port of https://github.com/tomasr/viasfora/blob/master/Viasfora/Util/VsColors.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.
If you guys are supporting VS 2010 in this release then you'll need to interact with colors this way. In which case I'd add a comment that says something like "We want to support Visual Studio 2010, but EnvironmentColors weren't added until Visual Studio 2012 so we have to load the VS2012 DLL dynamically and interact with themes using reflection." (The file you've linked to doesn't exist at that location anymore)
If this .vsix isn't going to be used in VS2010 then I believe you can take a dependency on Microsoft.VisualStudio.Shell.11.0 and refer to EnvironmentColors directly.
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.
- We don't support any VS version prior to 2017.
- I've already removed that code.
- We now use
IClassificationFormatMapServicehttps://github.com/Microsoft/visualfsharp/blob/master/vsintegration/src/FSharp.Editor/QuickInfoProvider.fs#L63
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.
👍
|
@cartermp @brettfo @vasily-kirichenko I'm noticing a lot of issues where VIsual Studio seems to hang while getting QuickInfo during debugging of F# code. I'm not sure if this is our problem, but it feels like it is. It may make sense to work out how to turn off semantic/error quick info while debugging F# code. At least we need to investigate further |
|
Is it quick info, or determining data-tip spans? Perhaps something in that code path is sub-optimal? |
|
@Pilchie Hard to tell. It's an outright hang of the VS IDE. I got one stack trace where the main UI thread was on roslyn code calling through to a quick info provider in a blocking wait (the word "QuickInfo" was definitely on the Roslyn call stack on the UI thread). I couldn't see any other useful stacks. I presume it was the F# provider for quick info tips. I'll try to repro and get better stack traces. Is there a way to disable the F# Quick Info service when debugging is active if we need it? thanks |
|
Maybe it's not related, but I think this code https://github.com/Microsoft/visualfsharp/blob/master/vsintegration/src/FSharp.Editor/QuickInfoProvider.fs#L81-L88 is too heavy weight to get qualified name island, start column of the last part of it and its |
|
@vasily-kirichenko Hmmm... it felt more async-lock-up-the-system than that |
|
however, code is not changed during debugging, so FCS should cache everything and answer very fast. It's strange. I've not able to investigate it today, been trying to build behind the proxy. |
|
@dsyme on a hello world console application debugger works OK for me: it does not show tooltips and it does show proper debug information (current variable values). On VFT solution it does not work, hanging on this dialog: Did you mean this behavior? |
|
@vasily-kirichenko I've noticed that too |
|
If it hangs forever, a dump with heap would really make investigations go a lot faster. |
|
@Pilchie it does not hang forever, sorry for misinformation. The dialog is shown until you move mouse somewhere else, after that VS is responsive until you hover the mouse over another symbol again. |
|
I debugged it and I was wrong: |
|
I make interface IBreakpointResolutionService with
member this.ResolveBreakpointAsync(_document: Document, _textSpan: TextSpan, _cancellationToken: CancellationToken): Task<BreakpointResolutionResult> =
Task.FromResult null(I mean "Getting datatip text" dialog still hangs) |
|
I also make interface IQuickInfoProvider with
override this.GetItemAsync(_document: Document, _position: int, _cancellationToken: CancellationToken): Task<QuickInfoItem> =
Task.FromResult null |
|
Obviously it hangs in |
|
@vasily-kirichenko COuld you add a new bug with repro steps you are using? This seems important to fix (even though we're only seeing it in the VisualFSharp.sln right now, I presume it happens on other large solutions) |
* Implement FSharpQuickInfoProvider (by @OmarTawfik) * extract tryClassifyAtPosition and reuse it in QuickInfoProvider * address code review * fix QuickInfo text span * don't show empty tooltip * add a QuickInfoProvider test * QuickInfoProvider respects current theme colors * revert problem stuff into FSharp.Compiler.fsproj





No description provided.