protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) { base.OnMouseRightButtonDown(e); if (ContextMenu != null) { //ContextMenu.IsOpen = true; return; } var ctx = SemanticContext.GetHovered(); if (ctx != null) { SyncHelper.RunSync(() => ctx.UpdateAsync(default));
public static ThemedToolTip CreateToolTip(ISymbol symbol, bool forMemberList, SemanticContext context) { var tip = new ThemedToolTip(); if (Config.Instance.DisplayOptimizations.MatchFlags(DisplayOptimizations.CodeWindow)) { WpfHelper.SetUITextRenderOptions(tip, true); } if (forMemberList == false) { tip.Title.Append(ThemeHelper.GetImage(symbol.GetImageId()).WrapMargin(WpfHelper.GlyphMargin)); } tip.Title .Append(symbol.GetAccessibility() + symbol.GetAbstractionModifier() + (symbol as IMethodSymbol).GetSpecialMethodModifier() + symbol.GetSymbolKindName() + " ") .Append(symbol.Name, true) .Append(symbol.GetParameterString()); var content = tip.Content; var t = symbol.GetReturnType(); if (t != null) { content.Append(R.T_MemberType) .Append(t.ToDisplayString(CodeAnalysisHelper.MemberNameFormat), true); } else if (symbol.Kind == SymbolKind.TypeParameter) { content.Append(R.T_DefinedInType) .Append(symbol.ContainingSymbol?.ToDisplayString(CodeAnalysisHelper.MemberNameFormat) ?? String.Empty, true); var tp = symbol as ITypeParameterSymbol; if (tp.HasConstraint()) { content.AppendLine().Append(R.T_Constraint); SymbolFormatter.Instance.ShowTypeConstaints(tp, content); } } t = symbol.ContainingType; if (t != null && t.TypeKind != TypeKind.Enum) { content.AppendLineBreak() .Append(t.GetSymbolKindName(), SymbolFormatter.Instance.Keyword).Append(": ") .Append(t.ToDisplayString(CodeAnalysisHelper.MemberNameFormat), true); } if (forMemberList == false) { content.AppendLineBreak() .Append(R.T_Namespace + symbol.ContainingNamespace?.ToString()).AppendLine(); if (symbol.Kind == SymbolKind.Namespace) { // hack: workaround to exclude references that returns null from GetDocument content.Append(R.T_Assembly).Append(String.Join(", ", ((INamespaceSymbol)symbol).ConstituentNamespaces.Select(n => n.GetAssemblyModuleName()).Distinct())) .AppendLine().Append(R.T_Project).Append(String.Join(", ", symbol.GetSourceReferences().Select(r => context.GetProject(r.SyntaxTree)).Where(p => p != null).Distinct().Select(p => p.Name))) .AppendLine().Append(R.T_Location).Append(symbol.Locations.Length); } else { if (symbol.HasSource()) { content.Append(R.T_SourceFile).Append(String.Join(", ", symbol.GetSourceReferences().Select(r => System.IO.Path.GetFileName(r.SyntaxTree.FilePath)))) .AppendLine().Append(R.T_Project).Append(String.Join(", ", symbol.GetSourceReferences().Select(r => context.GetProject(r.SyntaxTree)).Where(p => p != null).Distinct().Select(p => p.Name))); } else { content.Append(R.T_Assembly).Append(symbol.GetAssemblyModuleName()); } if (symbol.Kind == SymbolKind.NamedType) { switch (((INamedTypeSymbol)symbol).TypeKind) { case TypeKind.Delegate: ShowDelegateSignature(content, (INamedTypeSymbol)symbol); break; case TypeKind.Enum: ShowEnumType(content, symbol); break; } } } } ShowAttributes(symbol, content); if (context.SemanticModel?.Compilation != null && Config.Instance.SymbolToolTipOptions.MatchFlags(SymbolToolTipOptions.XmlDocSummary)) { ShowXmlDocSummary(symbol, context.SemanticModel.Compilation, tip); } ShowNumericForms(symbol, tip); return(tip); }