CodeCompletionData CreateItem(object o, ExpressionContext context) { if (o is string) { return(new CodeCompletionData(o.ToString(), ClassBrowserIconService.NamespaceIndex)); } else if (o is IClass) { return(new CodeCompletionData((IClass)o)); } else if (o is IProperty) { IProperty property = (IProperty)o; if (property.Name != null && insertedPropertiesElements[property.Name] == null) { insertedPropertiesElements[property.Name] = property; return(new CodeCompletionData(property)); } } else if (o is IMethod) { IMethod method = (IMethod)o; if (method.Name != null && !method.IsConstructor) { CodeCompletionData ccd = new CodeCompletionData(method); if (insertedElements[method.Name] == null) { insertedElements[method.Name] = ccd; return(ccd); } else { CodeCompletionData oldMethod = (CodeCompletionData)insertedElements[method.Name]; ++oldMethod.Overloads; } } } else if (o is IField) { return(new CodeCompletionData((IField)o)); } else if (o is IEvent) { IEvent e = (IEvent)o; if (e.Name != null && insertedEventElements[e.Name] == null) { insertedEventElements[e.Name] = e; return(new CodeCompletionData(e)); } } else { throw new ApplicationException("Unknown object: " + o); } return(null); }
public string GetInsightData(int number) { IMember method = methods[number]; IAmbience conv = AmbienceService.GetCurrentAmbience(); conv.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.UseFullyQualifiedMemberNames; string documentation = method.Documentation; string text = conv.Convert(method); return(text + "\n" + CodeCompletionData.ConvertDocumentation(documentation)); }
protected bool ProvideContextCompletion(SharpDevelopTextAreaControl editor, IReturnType expected, char charTyped) { if (expected == null) { return(false); } IClass c = expected.GetUnderlyingClass(); if (c == null) { return(false); } if (c.ClassType == ClassType.Enum) { CtrlSpaceCompletionDataProvider cdp = new CtrlSpaceCompletionDataProvider(); cdp.ForceNewExpression = true; ContextCompletionDataProvider cache = new ContextCompletionDataProvider(cdp); cache.activationKey = charTyped; cache.GenerateCompletionData(editor.FileName, editor.ActiveTextAreaControl.TextArea, charTyped); ICompletionData[] completionData = cache.CompletionData; Array.Sort(completionData); for (int i = 0; i < completionData.Length; i++) { CodeCompletionData ccd = completionData[i] as CodeCompletionData; if (ccd != null && ccd.Class != null) { if (ccd.Class.FullyQualifiedName == expected.FullyQualifiedName) { cache.DefaultIndex = i; break; } } } if (cache.DefaultIndex >= 0) { if (charTyped != ' ') { cdp.InsertSpace = true; } editor.ShowCompletionWindow(cache, charTyped); return(true); } } return(false); }
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 && !ccd.Text.StartsWith("___")) { 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(); this.DefaultIndex = completionData.IndexOf(suggestedData); } } }
public string GetInsightData(int number) { IMember method = methods[number]; IAmbience conv = AmbienceService.CurrentAmbience; conv.ConversionFlags = ConversionFlags.StandardConversionFlags; string documentation = method.Documentation; string text; if (method is IMethod) { text = conv.Convert(method as IMethod); } else if (method is IProperty) { text = conv.Convert(method as IProperty); } else { text = method.ToString(); } return(text + "\n" + CodeCompletionData.GetDocumentation(documentation)); }
public OverrideCompletionData(IProperty property) : base(property.Name, "override " + property.Name + "\n\n" + CodeCompletionData.ConvertDocumentation(property.Documentation), ClassBrowserIconService.GetIcon(property)) { this.member = property; }
CodeCompletionData CreateItem(object o, ExpressionContext context) { if (o is string) { return new CodeCompletionData(o.ToString(), ClassBrowserIconService.NamespaceIndex); } else if (o is IClass) { return new CodeCompletionData((IClass)o); } else if (o is IProperty) { IProperty property = (IProperty)o; if (property.Name != null && insertedPropertiesElements[property.Name] == null) { insertedPropertiesElements[property.Name] = property; return new CodeCompletionData(property); } } else if (o is IMethod) { IMethod method = (IMethod)o; if (method.Name != null) { CodeCompletionData ccd = new CodeCompletionData(method); if (insertedElements[method.Name] == null) { insertedElements[method.Name] = ccd; return ccd; } else { CodeCompletionData oldMethod = (CodeCompletionData)insertedElements[method.Name]; ++oldMethod.Overloads; } } } else if (o is IField) { return new CodeCompletionData((IField)o); } else if (o is IEvent) { IEvent e = (IEvent)o; if (e.Name != null && insertedEventElements[e.Name] == null) { insertedEventElements[e.Name] = e; return new CodeCompletionData(e); } } else { throw new ApplicationException("Unknown object: " + o); } return null; }