Skip to content

Commit

Permalink
+ Made namespace symbol on C# Quick Info interactive, displaying name…
Browse files Browse the repository at this point in the history
…space and types when clicked (#257)
  • Loading branch information
wmjordan committed May 12, 2023
1 parent 0eeafd1 commit 5b8a9eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Codist/Helpers/SymbolFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ public void ShowContainingNamespace(ISymbol symbol, TextBlock loc) {
ns = ns.ContainingNamespace;
} while (ns?.IsGlobalNamespace == false);
for (int i = n.Count - 1; i > 0; i--) {
loc.Append(n[i].Name.Render(Namespace)).Append(".");
loc.AddSymbol(n[i], false, Namespace).Append(".");
}
loc.Append(n[0].Name.Render(Namespace));
loc.AddSymbol(n[0], false, Namespace);
}

public TextBlock ShowParameters(TextBlock block, ImmutableArray<IParameterSymbol> parameters) {
Expand Down Expand Up @@ -684,7 +684,7 @@ internal void Format(InlineCollection text, ISymbol symbol, string alias, bool b
return;
case SymbolKind.Method: FormatMethodName(text, symbol, alias, bold); return;
case SymbolKind.NamedType: FormatTypeName(text, symbol, alias, bold); return;
case SymbolKind.Namespace: text.Add(symbol.Name.Render(Namespace)); return;
case SymbolKind.Namespace: text.Add(symbol.Render(alias, bold, Namespace)); return;
case SymbolKind.Parameter: text.Add(symbol.Render(null, bold, Parameter)); return;
case SymbolKind.Property: FormatPropertyName(text, (IPropertySymbol)symbol, alias, bold); return;
case SymbolKind.Local:
Expand Down Expand Up @@ -941,7 +941,7 @@ internal TextBlock Format(TextBlock block, ImmutableArray<SymbolDisplayPart> par
block.Append(part.ToString(), false, false, Keyword);
break;
case SymbolDisplayPartKind.NamespaceName:
block.Append(part.Symbol.Name, Namespace);
block.AddSymbol(part.Symbol, false, Namespace);
break;
case SymbolDisplayPartKind.TypeParameterName:
block.AddSymbol(part.Symbol, argIndex == Int32.MinValue, TypeParameter);
Expand Down
11 changes: 10 additions & 1 deletion Codist/Helpers/WpfHelper.VS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,18 @@ void DismissQuickInfo(object sender, RoutedEventArgs e) {
}

void GoToSymbol(object sender, RoutedEventArgs e) {
_Symbol.GoToDefinition();
if (_Symbol.Kind == SymbolKind.Namespace) {
FindMembersForNamespace(_Symbol);
}
else {
_Symbol.GoToDefinition();
}
QuickInfo.QuickInfoOverride.DismissQuickInfo(this);
e.Handled = true;

async void FindMembersForNamespace(ISymbol symbol) {
await SemanticContext.GetHovered().FindMembersAsync(symbol);
}
}
}
}
Expand Down

0 comments on commit 5b8a9eb

Please sign in to comment.