/// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. /// </summary> /// <param name="pi"> /// A <see cref="ProjectInformation"/> for the current project. /// </param> /// <param name="item"> /// A <see cref="LanguageItem"/>: The item to convert. /// </param> /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> static IMember LanguageItemToIMember(ProjectInformation pi, LanguageItem item, string[] contentLines) { if (item is Class || item is Structure) { DomType klass = new DomType(new CompilationUnit(item.File), ClassType.Class, item.Name, new DomLocation((int)item.Line, 1), string.Empty, new DomRegion((int)item.Line + 1, FindFunctionEnd(contentLines, (int)item.Line - 1) + 2), new List <IMember> ()); foreach (LanguageItem li in pi.AllItems()) { if (klass.Equals(li.Parent) && FilePath.Equals(li.File, item.File)) { klass.Add(LanguageItemToIMember(pi, li, contentLines)); } } return(klass); } if (item is Enumeration) { return(new DomType(new CompilationUnit(item.File), ClassType.Enum, item.Name, new DomLocation((int)item.Line, 1), string.Empty, new DomRegion((int)item.Line + 1, (int)item.Line + 1), new List <IMember> ())); } if (item is Function) { return(new DomMethod(item.Name, Modifiers.None, MethodModifier.None, new DomLocation((int)item.Line, 1), new DomRegion((int)item.Line + 1, FindFunctionEnd(contentLines, (int)item.Line - 1) + 2), new DomReturnType())); } if (item is Member) { return(new DomField(item.Name, Modifiers.None, new DomLocation((int)item.Line, 1), new DomReturnType())); } return(null); }
/// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. /// </summary> /// <param name="pi"> /// A <see cref="ProjectInformation"/> for the current project. /// </param> /// <param name="item"> /// A <see cref="LanguageItem"/>: The item to convert. /// </param> /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> static IMember LanguageItemToIMember(ProjectInformation pi, LanguageItem item, string[] contentLines) { if (item is Class || item is Structure) { DomType klass = new DomType(new CompilationUnit(item.File), ClassType.Class, item.Name, new DomLocation((int)item.Line, 1), string.Empty, new DomRegion((int)item.Line + 1, FindFunctionEnd(contentLines, (int)item.Line - 1) + 2), new List <IMember> ()); foreach (LanguageItem li in pi.AllItems()) { if (klass.Equals(li.Parent) && FilePath.Equals(li.File, item.File)) { klass.Add(LanguageItemToIMember(pi, li, contentLines)); } } return(klass); } if (item is Enumeration) { return(new DomType(new CompilationUnit(item.File), ClassType.Enum, item.Name, new DomLocation((int)item.Line, 1), string.Empty, new DomRegion((int)item.Line + 1, (int)item.Line + 1), new List <IMember> ())); } if (item is Function) { DomMethod method = new DomMethod(item.Name, Modifiers.None, MethodModifier.None, new DomLocation((int)item.Line, 1), new DomRegion((int)item.Line + 1, FindFunctionEnd(contentLines, (int)item.Line - 1) + 2), new DomReturnType()); Function function = (Function)item; Match match; bool abort = false; List <IParameter> parameters = new List <IParameter> (); foreach (string parameter in function.Parameters) { match = paramExpression.Match(parameter); if (null == match) { abort = true; break; } DomParameter p = (new DomParameter(method, match.Groups["name"].Value, new DomReturnType(string.Format("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value)))); parameters.Add(p); } if (!abort) { method.Add(parameters); } return(method); } if (item is Member) { return(new DomField(item.Name, Modifiers.None, new DomLocation((int)item.Line, 1), new DomReturnType())); } return(null); }
/// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. /// </summary> /// <param name="pi"> /// A <see cref="ProjectInformation"/> for the current project. /// </param> /// <param name="item"> /// A <see cref="LanguageItem"/>: The item to convert. /// </param> /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> static DefaultUnresolvedTypeDefinition LanguageItemToIType(ProjectInformation pi, LanguageItem item, string[] contentLines) { var klass = new DefaultUnresolvedTypeDefinition("", item.File); if (item is Class || item is Structure) { klass.Region = new DomRegion((int)item.Line, 1, FindFunctionEnd(contentLines, (int)item.Line - 1) + 2, 1); klass.Kind = item is Class ? TypeKind.Class : TypeKind.Struct; foreach (LanguageItem li in pi.AllItems()) { if (klass.Equals(li.Parent) && FilePath.Equals(li.File, item.File)) { AddLanguageItem(pi, klass, li, contentLines); } } return(klass); } klass.Region = new DomRegion((int)item.Line, 1, (int)item.Line + 1, 1); klass.Kind = TypeKind.Enum; return(klass); }
/// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. /// </summary> /// <param name="pi"> /// A <see cref="ProjectInformation"/> for the current project. /// </param> /// <param name="item"> /// A <see cref="LanguageItem"/>: The item to convert. /// </param> /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> static IMember LanguageItemToIMember (ProjectInformation pi, LanguageItem item, string[] contentLines) { if (item is Class || item is Structure) { DomType klass = new DomType (new CompilationUnit (item.File), ClassType.Class, item.Name, new DomLocation ((int)item.Line, 1), string.Empty, new DomRegion ((int)item.Line+1, FindFunctionEnd (contentLines, (int)item.Line-1)+2), new List<IMember> ()); foreach (LanguageItem li in pi.AllItems ()) { if (klass.Equals (li.Parent) && FilePath.Equals (li.File, item.File)) { klass.Add (LanguageItemToIMember (pi, li, contentLines)); } } return klass; } if (item is Enumeration) { return new DomType (new CompilationUnit (item.File), ClassType.Enum, item.Name, new DomLocation ((int)item.Line, 1), string.Empty, new DomRegion ((int)item.Line+1, (int)item.Line+1), new List<IMember> ()); } if (item is Function) { return new DomMethod (item.Name, Modifiers.None, MethodModifier.None, new DomLocation ((int)item.Line, 1), new DomRegion ((int)item.Line+1, FindFunctionEnd (contentLines, (int)item.Line-1)+2), new DomReturnType ()); } if (item is Member) { return new DomField (item.Name, Modifiers.None, new DomLocation ((int)item.Line, 1), new DomReturnType ()); } return null; }
/// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. /// </summary> /// <param name="pi"> /// A <see cref="ProjectInformation"/> for the current project. /// </param> /// <param name="item"> /// A <see cref="LanguageItem"/>: The item to convert. /// </param> /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> static DefaultUnresolvedTypeDefinition LanguageItemToIType (ProjectInformation pi, LanguageItem item, string[] contentLines) { var klass = new DefaultUnresolvedTypeDefinition ("", item.File); if (item is Class || item is Structure) { klass.Region = new DomRegion ((int)item.Line, 1, FindFunctionEnd (contentLines, (int)item.Line-1) + 2, 1); klass.Kind = item is Class ? TypeKind.Class : TypeKind.Struct; foreach (LanguageItem li in pi.AllItems ()) { if (klass.Equals (li.Parent) && FilePath.Equals (li.File, item.File)) AddLanguageItem (pi, klass, li, contentLines); } return klass; } klass.Region = new DomRegion ((int)item.Line, 1, (int)item.Line + 1, 1); klass.Kind = TypeKind.Enum; return klass; }
/// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. /// </summary> /// <param name="pi"> /// A <see cref="ProjectInformation"/> for the current project. /// </param> /// <param name="item"> /// A <see cref="LanguageItem"/>: The item to convert. /// </param> /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> static IMember LanguageItemToIMember (ProjectInformation pi, LanguageItem item, string[] contentLines) { if (item is Class || item is Structure) { DomType klass = new DomType (new CompilationUnit (item.File), ClassType.Class, item.Name, new DomLocation ((int)item.Line, 1), string.Empty, new DomRegion ((int)item.Line+1, FindFunctionEnd (contentLines, (int)item.Line-1)+2), new List<IMember> ()); foreach (LanguageItem li in pi.AllItems ()) { if (klass.Equals (li.Parent) && FilePath.Equals (li.File, item.File)) { klass.Add (LanguageItemToIMember (pi, li, contentLines)); } } return klass; } if (item is Enumeration) { return new DomType (new CompilationUnit (item.File), ClassType.Enum, item.Name, new DomLocation ((int)item.Line, 1), string.Empty, new DomRegion ((int)item.Line+1, (int)item.Line+1), new List<IMember> ()); } if (item is Function) { DomMethod method = new DomMethod (item.Name, Modifiers.None, MethodModifier.None, new DomLocation ((int)item.Line, 1), new DomRegion ((int)item.Line+1, FindFunctionEnd (contentLines, (int)item.Line-1)+2), new DomReturnType ()); Function function = (Function)item; Match match; bool abort = false; List<IParameter> parameters = new List<IParameter> (); foreach (string parameter in function.Parameters) { match = paramExpression.Match (parameter); if (null == match) { abort = true; break; } DomParameter p = (new DomParameter (method, match.Groups["name"].Value, new DomReturnType (string.Format ("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value)))); parameters.Add (p); } if (!abort) method.Add (parameters); return method; } if (item is Member) { return new DomField (item.Name, Modifiers.None, new DomLocation ((int)item.Line, 1), new DomReturnType ()); } return null; }