コード例 #1
0
        void AddCompletionData(ref List <ICompletionData> resultList, ArrayList completionData, Dom.ExpressionContext context)
        {
            // used to store the method names for grouping overloads
            Dictionary <string, CSCompletionData> nameDictionary = new Dictionary <string, CSCompletionData>();

            // Add the completion data as returned by SharpDevelop.Dom to the
            // list for the text editor
            foreach (object obj in completionData)
            {
                if (!context.ShowEntry(obj))
                {
                    continue;
                }

                if (obj is string)
                {
                    // namespace names are returned as string
                    resultList.Add(new DefaultCompletionData((string)obj, "namespace " + obj, 5));
                }
                else if (obj is Dom.IClass)
                {
                    Dom.IClass c = (Dom.IClass)obj;
                    resultList.Add(new CSCompletionData(c));
                }
                else if (obj is Dom.IMember)
                {
                    Dom.IMember m = (Dom.IMember)obj;
                    if (m is Dom.IMethod && ((m as Dom.IMethod).IsConstructor))
                    {
                        // Skip constructors
                        continue;
                    }
                    // Group results by name and add "(x Overloads)" to the
                    // description if there are multiple results with the same name.

                    CSCompletionData data;
                    if (nameDictionary.TryGetValue(m.Name, out data))
                    {
                        data.AddOverload();
                    }
                    else
                    {
                        nameDictionary[m.Name] = data = new CSCompletionData(m);
                        resultList.Add(data);
                    }
                }
                else
                {
                    // Current ICSharpCode.SharpDevelop.Dom should never return anything else
                    throw new NotSupportedException();
                }
            }
        }
コード例 #2
0
        string GetMemberText(IAmbience ambience, IEntity member)
        {
            StringBuilder text = new StringBuilder();

            if (member is IField)
            {
                text.Append(ambience.Convert(member as IField));
            }
            else if (member is IProperty)
            {
                text.Append(ambience.Convert(member as IProperty));
            }
            else if (member is IEvent)
            {
                text.Append(ambience.Convert(member as IEvent));
            }
            else if (member is IMethod)
            {
                text.Append(ambience.Convert(member as IMethod));
            }
            else if (member is IClass)
            {
                text.Append(ambience.Convert(member as IClass));
            }
            else
            {
                text.Append("unknown member ");
                text.Append(member.ToString());
            }
            string documentation = member.Documentation;

            if (documentation != null && documentation.Length > 0)
            {
                text.Append('\n');
                text.Append(CSCompletionData.XmlDocumentationToText(documentation));
            }
            return(text.ToString());
        }