/// <summary> /// Gets the local declaration corresponding to the given name. /// </summary> /// <param name="name">A <see cref="SRC"/> element.</param> /// <returns>The corresponding declaration, null if not found.</returns> public static XElement GetLocalDecl(this XElement name) { if (null == name) { throw new ArgumentNullException("name"); } SrcMLElement.ThrowExceptionOnInvalidName(name, SRC.Name); var decls = from d in name.Ancestors(SRC.Function).First().Descendants(SRC.Declaration) where d.Elements(SRC.Name).Any() where d.IsBefore(name) && d.Element(SRC.Name).Value == name.Value select d; return(decls.Last()); }
public string GetPathForUnit(XElement unit) { if (null == unit) { throw new ArgumentNullException("unit"); } try { SrcMLElement.ThrowExceptionOnInvalidName(unit, SRC.Unit); } catch (SrcMLRequiredNameException e) { throw new ArgumentException(e.Message, "unit", e); } var fileName = unit.Attribute("filename"); if (null != fileName) { return(fileName.Value); } return(null); //return fileName.Value; }