void AddCompletionData(List <ICompletionData> resultList, ArrayList completionData) { // ReSharper disable CanBeReplacedWithTryCastAndCheckForNull // used to store the method names for grouping overloads var 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 IClass) { var c = (IClass)obj; resultList.Add(new CodeCompletionData(c, this)); } else if (obj is IMember) { var m = (IMember)obj; if (m is IMethod && ((m as IMethod).IsConstructor)) { // Skip constructors continue; } // if OnlyShowCodeCompleteResulstFromO2Namespace filter for only FluentSharp.* namepace if (OnlyShowCodeCompleteResultsFromO2Namespace && m.DeclaringType.Namespace.starts("FluentSharp") == false) { continue; } // NOT WORKING only show items that match currentCodeCompleteText regex // if (currentCodeCompleteText != "" && m.DotNetName.nregEx(currentCodeCompleteText)) // continue; //if // 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(m); } else { nameDictionary[m.Name] = data = new CodeCompletionData(m, this); resultList.Add(data); } } else { // Current ICSharpCode.SharpDevelop.Dom should never return anything else throw new NotSupportedException(); } } // ReSharper restore CanBeReplacedWithTryCastAndCheckForNull }
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 (documentation != null && documentation.Length > 0) { text.Append('\n'); text.Append(CodeCompletionData.XmlDocumentationToText(documentation)); } return(text.ToString()); }
void CodeCompletionListViewSelectedItemChanged(object sender, EventArgs e) { if (codeCompletionListView != null) { ICompletionData data = codeCompletionListView.SelectedCompletionData; if (showDeclarationWindow && data != null && data.Description != null && data.Description.Length > 0) { declarationViewWindow.Description = data.Description; if (data is O2.External.SharpDevelop.Ascx.CodeCompletionData) { lastCodeCompleteData = (O2.External.SharpDevelop.Ascx.CodeCompletionData)data; if (lastCodeCompleteData.member.notNull()) { var memberSignature = lastCodeCompleteData.member.str().remove("[DefaultMethod: ").removeLastChar(); declarationViewWindow.Description = (declarationViewWindow.Description + memberSignature).trim(); } if (lastCodeCompleteData.c.notNull()) { var classDescription = lastCodeCompleteData.c.str().remove("[DefaultClass: ").removeLastChar().line(); foreach (var method in lastCodeCompleteData.c.Methods) classDescription += " - {0}".info(method.str()).line(); declarationViewWindow.Description = (declarationViewWindow.Description + classDescription).trim(); } } SetDeclarationViewLocation(); } else { declarationViewWindow.Description = null; } } }
void AddCompletionData(List <ICompletionData> resultList, ArrayList completionData) { // var currentCodeCompleteText = ""; // var lenght = textEditor.currentOffset() - startOffset; // if (lenght >0) // currentCodeCompleteText = textEditor.get_Text(startOffset,lenght); // "{0}:{1} = {2}".format(startOffset,lenght , currentCodeCompleteText).debug(); // 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 IClass) { IClass c = (IClass)obj; resultList.Add(new CodeCompletionData(c, this)); } else if (obj is IMember) { IMember m = (IMember)obj; if (m is IMethod && ((m as IMethod).IsConstructor)) { // Skip constructors continue; } // if OnlyShowCodeCompleteResulstFromO2Namespace filter for only O2.* namepace if (OnlyShowCodeCompleteResulstFromO2Namespace && m.DeclaringType.Namespace.starts("O2") == false) { continue; } // NOT WORKING only show items that match currentCodeCompleteText regex // if (currentCodeCompleteText != "" && m.DotNetName.nregEx(currentCodeCompleteText)) // continue; //if // 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, this); resultList.Add(data); } } else { // Current ICSharpCode.SharpDevelop.Dom should never return anything else throw new NotSupportedException(); } } }