static PythonClass GetClass (PythonModule module, int line) { foreach (PythonClass pyClass in module.Classes) if (InRegion (pyClass.Region, line)) return pyClass; // todo: classes in functions? return null; }
/// <summary> /// Walks the xml element tree to build a result. This expects /// rootElement to be a <module /> element. /// <param name="rootElement"> /// A <see cref="XmlElement"/> /// </param> /// </summary> /// <param name="rootElement"> /// A <see cref="XmlElement"/> /// </param> void BuildFromXmlElement (XmlElement rootElement, StringReader content) { Debug.Assert (rootElement.LocalName == "module"); string moduleName = String.Empty; if (!String.IsNullOrEmpty (FileName)) moduleName = PythonHelper.ModuleFromFilename (FileName); Module = new PythonModule () { FullName = moduleName, Region = GetDomRegion (rootElement), }; foreach (XmlElement child in rootElement) { switch (child.LocalName) { case "import": BuildImport (child); break; case "class": BuildClass (child); break; case "attribute": BuildAttribute (child); break; case "function": BuildFunction (child); break; case "warning": BuildWarning (child); break; default: Debug.Assert (false, "Assert not reached"); break; } } }