protected Dom.IMember GetParentMember(ICSharpCode.TextEditor.TextEditorControl textEditor, int line, int column) { Dom.ParseInformation parseInfo = ParserService.GetParseInformation(textEditor.FileName); if (parseInfo != null) { Dom.IClass c = parseInfo.MostRecentCompilationUnit.GetInnermostClass(line, column); if (c != null) { foreach (Dom.IMember member in c.Properties) { if (member.BodyRegion.IsInside(line, column)) { return(member); } } foreach (Dom.IMember member in c.Methods) { if (member.BodyRegion.IsInside(line, column)) { return(member); } } } } return(null); }
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(); } } }
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(); } } }
void AddCompletionData(List <ICompletionData> resultList, ArrayList completionData) { // 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; if (c.ClassType == Dom.ClassType.Enum) { resultList.Add(new DefaultCompletionData(c.Name, GetDescription(c), 4)); } else // missing: struct, delegate etc. { resultList.Add(new DefaultCompletionData(c.Name, GetDescription(c), 0)); } } 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; } // TODO: Group results by name and add "(x Overloads)" to the // description if there are multiple results with the same name. resultList.Add(new DefaultCompletionData(m.Name, GetDescription(m), GetMemberImageIndex(m))); } else { // Current ICSharpCode.SharpDevelop.Dom should never return anything else throw new NotSupportedException(); } } }
TypeReference FixTypeReference(TypeReference type, Location location, ICompilationUnit domCu, ReturnTypeOptions options) { if (type == null || type.IsKeyword) { return(type); } ICSharpCode.SharpDevelop.Dom.IClass curType = domCu.GetInnermostClass(location.Y, location.X); IReturnType rt = SharpDevelop.Dom.NRefactoryResolver.TypeVisitor.CreateReturnType( type, curType, null, location.Y, location.X, domCu.ProjectContent, options); if (rt != null && rt.GetUnderlyingClass() != null) { return(SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertType(rt, null)); } else { return(type); } }