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

            // Add the completion data as returned by SharpDevelop.Dom to the
            // list for the text editor
            foreach (object obj in completionData)
            {
                if (obj is Dom.NamespaceEntry)
                {
                    resultList.Add(new DefaultCompletionData(obj.ToString(), "namespace " + obj, 5));
                }
                else if (obj is Dom.NRefactoryResolver.KeywordEntry)
                {
                    resultList.Add(new DefaultCompletionData(obj.ToString(), obj.ToString(), 5));
                }
                else if (obj is Dom.IClass)
                {
                    Dom.IClass c = (Dom.IClass)obj;
                    resultList.Add(new CodeCompletionData(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.

                    CodeCompletionData data;
                    if (nameDictionary.TryGetValue(m.Name, out data))
                    {
                        data.AddOverload();
                    }
                    else
                    {
                        nameDictionary[m.Name] = data = new CodeCompletionData(m);
                        resultList.Add(data);
                    }
                }
                else
                {
                    // Current ICSharpCode.SharpDevelop.Dom should never return anything else
                    throw new NotSupportedException();
                }
            }
        }
コード例 #2
0
        private void AddCompletionData(List <ICompletionData> resultList, ArrayList completionData)
        {
            // used to store the method names for grouping overloads
            Dictionary <string, CodeCompletionData> nameDictionary = new Dictionary <string, CodeCompletionData>();

            // Add the completion data as returned by SharpDevelop.Dom to the
            // list for the text editor
            foreach (object obj in completionData)
            {
                var s = obj as string;
                if (s != null)
                {
                    // namespace names are returned as string
                    resultList.Add(new DefaultCompletionData(s, "namespace " + obj, 5));
                }
                else if (obj is IClass)
                {
                    IClass c = (IClass)obj;
                    resultList.Add(new CodeCompletionData(c));
                }
                else if (obj is IMember)
                {
                    IMember m = (IMember)obj;
                    if (m is IMethod && (m as 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.
                    CodeCompletionData data;
                    if (nameDictionary.TryGetValue(m.Name, out data))
                    {
                        data.AddOverload();
                    }
                    else
                    {
                        nameDictionary[m.Name] = data = new CodeCompletionData(m);
                        resultList.Add(data);
                    }
                }
                else
                {
                    // Current ICSharpCode.SharpDevelop.Dom should never return anything else
                    throw new NotSupportedException();
                }
            }
        }
コード例 #3
0
        private static 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 (!string.IsNullOrEmpty(documentation))
            {
                text.Append('\n');
                text.Append(CodeCompletionData.XmlDocumentationToText(documentation));
            }

            return(text.ToString());
        }
コード例 #4
0
		void AddCompletionData(List<ICompletionData> resultList, ArrayList completionData)
		{
			// used to store the method names for grouping overloads
			Dictionary<string, CodeCompletionData> nameDictionary = new Dictionary<string, CodeCompletionData>();
			
			// Add the completion data as returned by SharpDevelop.Dom to the
			// list for the text editor
			foreach (object obj in completionData) {
				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 CodeCompletionData(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.
					
					CodeCompletionData data;
					if (nameDictionary.TryGetValue(m.Name, out data)) {
						data.AddOverload();
					} else {
						nameDictionary[m.Name] = data = new CodeCompletionData(m);
						resultList.Add(data);
					}
				} else {
					// Current ICSharpCode.SharpDevelop.Dom should never return anything else
					throw new NotSupportedException();
				}
			}
		}