当前位置: 首页>>代码示例>>C#>>正文


C# NamespaceDeclaration.AddChild方法代码示例

本文整理汇总了C#中NamespaceDeclaration.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceDeclaration.AddChild方法的具体用法?C# NamespaceDeclaration.AddChild怎么用?C# NamespaceDeclaration.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NamespaceDeclaration的用法示例。


在下文中一共展示了NamespaceDeclaration.AddChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Visit

			public override void Visit(ModuleContainer mc)
			{
				bool first = true;
				foreach (var container in mc.Containers) {
					var nspace = container as NamespaceContainer;
					if (nspace == null) {
						container.Accept(this);
						continue;
					}
					NamespaceDeclaration nDecl = null;
					var loc = LocationsBag.GetLocations(nspace);
					
					if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) {
						nDecl = new NamespaceDeclaration ();
						if (loc != null) {
							nDecl.AddChild(new CSharpTokenNode (Convert(loc [0])), Roles.NamespaceKeyword);
						}
						ConvertNamespaceName(nspace.RealMemberName, nDecl);
						if (loc != null && loc.Count > 1) {
							nDecl.AddChild(new CSharpTokenNode (Convert(loc [1])), Roles.LBrace);
						}
						AddToNamespace(nDecl);
						namespaceStack.Push(nDecl);
					}
					
					if (nspace.Usings != null) {
						foreach (var us in nspace.Usings) {
							us.Accept(this);
						}
					}
					
					if (first) {
						first = false;
						AddAttributeSection(Unit, mc);
					}
					
					if (nspace.Containers != null) {
						foreach (var subContainer in nspace.Containers) {
							subContainer.Accept(this);
						}
					}
					if (nDecl != null) {
						AddAttributeSection (nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
						if (loc != null && loc.Count > 2)
							nDecl.AddChild (new CSharpTokenNode (Convert (loc [2])), Roles.RBrace);
						if (loc != null && loc.Count > 3)
							nDecl.AddChild (new CSharpTokenNode (Convert (loc [3])), Roles.Semicolon);
						
						namespaceStack.Pop ();
					} else {
						AddAttributeSection (unit, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
					}
				}
				AddAttributeSection (unit, mc.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
			}
开发者ID:head-thrash,项目名称:monodevelop,代码行数:55,代码来源:CSharpParser.cs

示例2: Visit

			public override void Visit (UsingsBag.Namespace nspace)
			{
				NamespaceDeclaration nDecl = null;
				if (nspace.Name != null) {
					nDecl = new NamespaceDeclaration ();
					nDecl.AddChild (new CSharpTokenNode (Convert (nspace.NamespaceLocation), "namespace".Length), NamespaceDeclaration.Roles.Keyword);
					nDecl.AddChild (new Identifier (nspace.Name.Name, Convert (nspace.Name.Location)), NamespaceDeclaration.Roles.Identifier);
					nDecl.AddChild (new CSharpTokenNode (Convert (nspace.OpenBrace), 1), NamespaceDeclaration.Roles.LBrace);
					AddToNamespace (nDecl);
					namespaceStack.Push (nDecl);
					
				}
				VisitNamespaceUsings (nspace);
				VisitNamespaceBody (nspace);
				
				if (nDecl != null) {
					nDecl.AddChild (new CSharpTokenNode (Convert (nspace.CloseBrace), 1), NamespaceDeclaration.Roles.RBrace);
					if (!nspace.OptSemicolon.IsNull)
						nDecl.AddChild (new CSharpTokenNode (Convert (nspace.OptSemicolon), 1), NamespaceDeclaration.Roles.Semicolon);
				
					namespaceStack.Pop ();
				}
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:23,代码来源:CSharpParser.cs

示例3: Visit

			public override void Visit(NamespaceContainer ns)
			{
				NamespaceDeclaration nDecl = null;
				var loc = LocationsBag.GetLocations(ns);
				// <invalid> is caused by the parser - see Bug 12383 - [AST] Non existing namespaces generated
				if (ns.NS != null && !string.IsNullOrEmpty(ns.NS.Name) && !ns.NS.Name.EndsWith("<invalid>", StringComparison.Ordinal)) {
					nDecl = new NamespaceDeclaration();
					if (loc != null) {
						nDecl.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.NamespaceKeyword), Roles.NamespaceKeyword);
					}
					nDecl.AddChild(ConvertNamespaceName(ns.RealMemberName), NamespaceDeclaration.NamespaceNameRole);
					if (loc != null && loc.Count > 1) {
						nDecl.AddChild(new CSharpTokenNode(Convert(loc [1]), Roles.LBrace), Roles.LBrace);
					}

					AddToNamespace(nDecl);
					namespaceStack.Push(nDecl);
				}
				
				if (ns.Usings != null) {
					foreach (var us in ns.Usings) {
						us.Accept(this);
					}
				}
				
				if (ns.Containers != null) {
					foreach (var container in ns.Containers) {
						container.Accept(this);
					}
				}
				
				if (nDecl != null) {
					AddAttributeSection(nDecl, ns.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
					if (loc != null && loc.Count > 2)
						nDecl.AddChild(new CSharpTokenNode(Convert(loc [2]), Roles.RBrace), Roles.RBrace);
					if (loc != null && loc.Count > 3)
						nDecl.AddChild(new CSharpTokenNode(Convert(loc [3]), Roles.Semicolon), Roles.Semicolon);
					
					namespaceStack.Pop();
				}
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:41,代码来源:CSharpParser.cs

示例4: Visit

            public override void Visit(NamespaceContainer nspace)
            {
                NamespaceDeclaration nDecl = null;
                var loc = LocationsBag.GetLocations(nspace);

                if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) {
                    nDecl = new NamespaceDeclaration ();
                    if (loc != null) {
                        nDecl.AddChild(new CSharpTokenNode (Convert(loc [0]), Roles.NamespaceKeyword), Roles.NamespaceKeyword);
                    }
                    ConvertNamespaceName(nspace.RealMemberName, nDecl);
                    if (loc != null && loc.Count > 1) {
                        nDecl.AddChild(new CSharpTokenNode (Convert(loc [1]), Roles.LBrace), Roles.LBrace);
                    }
                    AddToNamespace(nDecl);
                    namespaceStack.Push(nDecl);
                }

                if (nspace.Usings != null) {
                    foreach (var us in nspace.Usings) {
                        us.Accept(this);
                    }
                }

                if (nspace.Containers != null) {
                    foreach (var container in nspace.Containers) {
                        container.Accept(this);
                    }
                }

                if (nDecl != null) {
                    AddAttributeSection(nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
                    if (loc != null && loc.Count > 2)
                        nDecl.AddChild (new CSharpTokenNode (Convert (loc [2]), Roles.RBrace), Roles.RBrace);
                    if (loc != null && loc.Count > 3)
                        nDecl.AddChild (new CSharpTokenNode (Convert (loc [3]), Roles.Semicolon), Roles.Semicolon);

                    namespaceStack.Pop ();
                }
            }
开发者ID:kaagati,项目名称:NRefactory,代码行数:40,代码来源:CSharpParser.cs


注:本文中的NamespaceDeclaration.AddChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。