public override bool ShowEntry(object o)
 {
     if (opType == 0)
     {
         return(a.ShowEntry(o) || b.ShowEntry(o));
     }
     if (opType == 1)
     {
         return(a.ShowEntry(o) && b.ShowEntry(o));
     }
     return(a.ShowEntry(o) ^ b.ShowEntry(o));
 }
Exemple #2
0
 public override bool ShowEntry(ICompletionEntry o)
 {
     if (opType == 0)
     {
         return(a.ShowEntry(o) || b.ShowEntry(o));
     }
     else if (opType == 1)
     {
         return(a.ShowEntry(o) && b.ShowEntry(o));
     }
     else
     {
         return(a.ShowEntry(o) ^ b.ShowEntry(o));
     }
 }
Exemple #3
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();
                }
            }
        }
		public static DefaultCompletionItemList ConvertCompletionData(DefaultCompletionItemList result, List<ICompletionEntry> arr, ExpressionContext context)
		{
			if (arr == null)
				return result;
			
			Dictionary<string, CodeCompletionItem> methodItems = new Dictionary<string, CodeCompletionItem>();
			foreach (ICompletionEntry o in arr) {
				if (context != null && !context.ShowEntry(o))
					continue;
				
				IMethod method = o as IMethod;
				if (method != null) {
					CodeCompletionItem codeItem;
					if (methodItems.TryGetValue(method.Name, out codeItem)) {
						codeItem.Overloads++;
						continue;
					}
				}
				
				ICompletionItem item = CreateCompletionItem(o, context);
				if (item != null) {
					result.Items.Add(item);
					CodeCompletionItem codeItem = item as CodeCompletionItem;
					if (method != null && codeItem != null) {
						methodItems[method.Name] = codeItem;
					}
				}
			}
			
			// Suggested entry (List<int> a = new => suggest List<int>).
			if (context.SuggestedItem is SuggestedCodeCompletionItem) {
				result.SuggestedItem = (SuggestedCodeCompletionItem)context.SuggestedItem;
				result.Items.Insert(0, result.SuggestedItem);
			}
			return result;
		}
		protected void AddResolveResults(ICollection list, ExpressionContext context)
		{
			if (list == null) {
				return;
			}
			completionData.Capacity += list.Count;
			CodeCompletionData suggestedData = null;
			foreach (object o in list) {
				if (context != null && !context.ShowEntry(o))
					continue;
				CodeCompletionData ccd = CreateItem(o, context);
				if (object.Equals(o, context.SuggestedItem))
					suggestedData = ccd;
				if (ccd != null)
					completionData.Add(ccd);
			}
			if (context.SuggestedItem != null) {
				if (suggestedData == null) {
					suggestedData = CreateItem(context.SuggestedItem, context);
					if (suggestedData != null) {
						completionData.Add(suggestedData);
					}
				}
				if (suggestedData != null) {
					completionData.Sort(DefaultCompletionData.Compare);
					this.DefaultIndex = completionData.IndexOf(suggestedData);
				}
			}
		}