Expand inline hints to type-locations#48422
Conversation
src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs
Show resolved
Hide resolved
It should not. Will fix :) |
| // No need to do anything if we're already in the requested state | ||
| var state = workspace.Options.GetOption(InlineHintsOptions.DisplayAllOverride); | ||
| var state = _globalOptionService.GetOption(InlineHintsOptions.DisplayAllOverride); | ||
| if (state == on) |
There was a problem hiding this comment.
Ignore this if you don't agree, but to me this reads confusingly. desiredState instead of on maybe?
There was a problem hiding this comment.
That works for me :-)
|
@davidwengier ptal if you have time :) |
| this.BackgroundBrush = Brushes.LightGray; | ||
| this.DisplayName = EditorFeaturesResources.Inline_Hints; | ||
| this.ForegroundBrush = new SolidColorBrush(Color.FromRgb(104, 104, 104)); | ||
| this.BackgroundBrush = new SolidColorBrush(Color.FromRgb(230, 230, 230)); |
There was a problem hiding this comment.
these match the values we have in the xml files. This means that we get these as the defaults no matter what.
| private readonly ITextView _textView; | ||
| private readonly SnapshotSpan _span; | ||
| private readonly SymbolKey _key; | ||
| private readonly SymbolKey? _key; |
There was a problem hiding this comment.
This goes away in #48479 when i update this UI code to not be C#/VB specific.
|
|
||
| public async Task<IReadOnlyCollection<object>> CreateDescriptionAsync(CancellationToken cancellationToken) | ||
| { | ||
| var document = _textView.TextBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); |
There was a problem hiding this comment.
this method added a null check and changed indentation. it's otherwise unchanged.
davidwengier
left a comment
There was a problem hiding this comment.
Seems GitHub doesn't do a good job when "changes since last review" includes merge commits ¯\_(ツ)_/¯
|
hey, would you consider adding an option to show the inline type hints for var and lambdas above the code line (like my extension does) so the line doesn't become illegible when having long generic names? |
|
@AdmiralSnyder can you point me to how you do this. I can try it out. I'm worried about two things:
that said, since this is suggesting an option to have that be the view, i think that that might be acceptable since it was all opt in. |
|
@CyrusNajmabadi i create SpaceNegotiatingAdornmentTags above the var lines. my project is on azure devops (and nonpublic) so i cannot directly point you towards it. var node = RoslynUtils.GetNodeAtSpan(root, span, index);
if (RoslynUtils.IsVarSyntaxNode(node))
{
yield return new TagSpan<VarLineTag>(new SnapshotSpan(span.Snapshot.TextBuffer.CurrentSnapshot, span), new VarLineTag(0, options.Size * 1.1, 0, 0, 0, PositionAffinity.Predecessor, null, null));
break; // max. one per line
}
`
where the VarLineTag is just a SpaceNegotiatingAdornmentTag descendant.
I create one tag per line.
and then i create multiple adornments in the tag's space.
i attach to the LayoutChanged event of the View, then iterate the visible lines and the `var` in the lines., i then get the roslyn node at the position, check whether it's a `var` node, and draw the adornment
if you wanna have a look at the (probably embarrassing :-) ) source, i can invite you to the azure devops project or create a copy in github and invite you there. or i can paste stuff that might be interesting into a gist... just tell me :-) |

New Options:
(the last three options are new).
These showup as:
With #48411 these can be off by default and lightup when holding ctrl-alt.