/// <summary> /// Parses and returns a namespace. /// </summary> /// <param name="parent">The parent of the namespace.</param> /// <param name="elementReference">A reference to the element being created.</param> /// <param name="partialElements">The collection of partial elements found while parsing the files.</param> /// <param name="unsafeCode">Indicates whether the code is marked as unsafe.</param> /// <param name="generated">Indicates whether the code is marked as generated code.</param> /// <param name="xmlHeader">The element's documentation header.</param> /// <param name="attributes">The attributes on the element.</param> /// <returns>Returns the element.</returns> private Namespace ParseNamespace( CsElement parent, Reference<ICodePart> elementReference, Dictionary<string, List<CsElement>> partialElements, bool unsafeCode, bool generated, XmlHeader xmlHeader, ICollection<Attribute> attributes) { Param.AssertNotNull(parent, "parent"); Param.AssertNotNull(elementReference, "elementReference"); Param.AssertNotNull(partialElements, "partialElements"); Param.Ignore(unsafeCode); Param.Ignore(generated); Param.Ignore(xmlHeader); Param.Ignore(attributes); // Add the namespace token. Node<CsToken> firstToken = this.tokens.InsertLast(this.GetToken(CsTokenType.Namespace, SymbolType.Namespace, elementReference)); // Add the namespace name token. CsToken name = this.GetElementNameToken(elementReference, unsafeCode); this.tokens.Add(name); // Create the declaration. CsTokenList declarationTokens = new CsTokenList(this.tokens, firstToken, this.tokens.Last); Declaration declaration = new Declaration(declarationTokens, name.Text, ElementType.Namespace, AccessModifierType.Public); // Create the namespace. Namespace @namespace = new Namespace(this.document, parent, xmlHeader, attributes, declaration, unsafeCode, generated); elementReference.Target = @namespace; // Parse the body of the namespace. this.ParseElementContainer(@namespace, elementReference, partialElements, unsafeCode); return @namespace; }
private Namespace ParseNamespace(CsElement parent, Dictionary<string, List<CsElement>> partialElements, bool unsafeCode, bool generated, XmlHeader xmlHeader, ICollection<Microsoft.StyleCop.CSharp.Attribute> attributes) { Microsoft.StyleCop.Node<CsToken> firstItemNode = this.tokens.InsertLast(this.GetToken(CsTokenType.Namespace, SymbolType.Namespace)); CsToken elementNameToken = this.GetElementNameToken(unsafeCode); this.tokens.Add(elementNameToken); CsTokenList tokens = new CsTokenList(this.tokens, firstItemNode, this.tokens.Last); Declaration declaration = new Declaration(tokens, elementNameToken.Text, ElementType.Namespace, AccessModifierType.Public); Namespace element = new Namespace(this.document, parent, xmlHeader, attributes, declaration, unsafeCode, generated); this.ParseElementContainer(element, partialElements, unsafeCode); return element; }