Beispiel #1
0
                public override TooltipInformation CreateTooltipInformation(bool smartWrap)
                {
                    var def    = type.GetDefinition();
                    var result = def != null?MemberCompletionData.CreateTooltipInformation(compilation, file, List.Resolver, ext.TextEditorData, ext.FormattingPolicy, def, smartWrap)  : new TooltipInformation();

                    if (ConflictingTypes != null)
                    {
                        var conflicts = new StringBuilder();
                        var sig       = new SignatureMarkupCreator(List.Resolver, ext.FormattingPolicy.CreateOptions());
                        for (int i = 0; i < ConflictingTypes.Count; i++)
                        {
                            var ct = ConflictingTypes[i];
                            if (i > 0)
                            {
                                conflicts.Append(", ");
                            }
                            if ((i + 1) % 5 == 0)
                            {
                                conflicts.Append(Environment.NewLine + "\t");
                            }
                            conflicts.Append(sig.GetTypeReferenceString(((TypeCompletionData)ct).type));
                        }
                        result.AddCategory("Type Conflicts", conflicts.ToString());
                    }
                    return(result);
                }
Beispiel #2
0
        public static TooltipInformation CreateTooltipInformation(ICompilation compilation, CSharpUnresolvedFile file, TextEditorData textEditorData, MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy formattingPolicy, IType type, bool smartWrap, bool createFooter = false)
        {
            var tooltipInfo = new TooltipInformation();
            var resolver    = file != null?file.GetResolver(compilation, textEditorData.Caret.Location) : new CSharpResolver(compilation);

            var sig = new SignatureMarkupCreator(resolver, formattingPolicy.CreateOptions());

            sig.BreakLineAfterReturnType = smartWrap;
            try {
                tooltipInfo.SignatureMarkup = sig.GetMarkup(type.IsParameterized ? type.GetDefinition() : type);
            } catch (Exception e) {
                LoggingService.LogError("Got exception while creating markup for :" + type, e);
                return(new TooltipInformation());
            }
            if (type.IsParameterized)
            {
                var typeInfo = new StringBuilder();
                for (int i = 0; i < type.TypeParameterCount; i++)
                {
                    typeInfo.AppendLine(type.GetDefinition().TypeParameters [i].Name + " is " + sig.GetTypeReferenceString(type.TypeArguments [i]));
                }
                tooltipInfo.AddCategory("Type Parameters", typeInfo.ToString());
            }

            var def = type.GetDefinition();

            if (def != null)
            {
                if (createFooter && !string.IsNullOrEmpty(def.ParentAssembly.AssemblyName))
                {
                    tooltipInfo.FooterMarkup = "<small> From " + AmbienceService.EscapeText(def.ParentAssembly.AssemblyName) + "</small>";
                }
                tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup(def) ?? "";
            }
            return(tooltipInfo);
        }