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


C# Ast.AcceptChildren方法代码示例

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


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

示例1: VisitTypeDeclaration

		public override object VisitTypeDeclaration(NRefactoryAST.TypeDeclaration typeDeclaration, object data)
		{
			DomRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(typeDeclaration.BodyStartLocation, typeDeclaration.EndLocation);
			
			DefaultClass c = new DefaultClass(cu, TranslateClassType(typeDeclaration.Type), ConvertTypeModifier(typeDeclaration.Modifier), region, GetCurrentClass());
			if (c.IsStatic) {
				// static classes are also abstract and sealed at the same time
				c.Modifiers |= ModifierEnum.Abstract | ModifierEnum.Sealed;
			}
			c.BodyRegion = bodyRegion;
			ConvertAttributes(typeDeclaration, c);
			c.Documentation = GetDocumentation(region.BeginLine, typeDeclaration.Attributes);
			
			DefaultClass outerClass = GetCurrentClass();
			if (outerClass != null) {
				outerClass.InnerClasses.Add(c);
				c.FullyQualifiedName = outerClass.FullyQualifiedName + '.' + typeDeclaration.Name;
			} else {
				c.FullyQualifiedName = PrependCurrentNamespace(typeDeclaration.Name);
				cu.Classes.Add(c);
			}
			c.UsingScope = currentNamespace;
			currentClass.Push(c);
			
			ConvertTemplates(outerClass, typeDeclaration.Templates, c); // resolve constrains in context of the class
			// templates must be converted before base types because base types may refer to generic types
			
			if (c.ClassType != ClassType.Enum && typeDeclaration.BaseTypes != null) {
				foreach (NRefactoryAST.TypeReference type in typeDeclaration.BaseTypes) {
					IReturnType rt = CreateReturnType(type, null, TypeVisitor.ReturnTypeOptions.BaseTypeReference);
					if (rt != null) {
						c.BaseTypes.Add(rt);
					}
				}
			}
			
			object ret = typeDeclaration.AcceptChildren(this, data);
			currentClass.Pop();
			
			if (c.ClassType == ClassType.Module) {
				foreach (DefaultField f in c.Fields) {
					f.Modifiers |= ModifierEnum.Static;
				}
				foreach (DefaultMethod m in c.Methods) {
					m.Modifiers |= ModifierEnum.Static;
				}
				foreach (DefaultProperty p in c.Properties) {
					p.Modifiers |= ModifierEnum.Static;
				}
				foreach (DefaultEvent e in c.Events) {
					e.Modifiers |= ModifierEnum.Static;
				}
			}

            mapType(typeDeclaration, c);

			return ret;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:59,代码来源:MapAstToNRefactory.cs

示例2: VisitNamespaceDeclaration

		public override object VisitNamespaceDeclaration(NRefactoryAST.NamespaceDeclaration namespaceDeclaration, object data)
		{
			DefaultUsingScope oldNamespace = currentNamespace;
			foreach (string name in namespaceDeclaration.Name.Split('.')) {
				currentNamespace = new DefaultUsingScope {
					Parent = currentNamespace,
					NamespaceName = PrependCurrentNamespace(name),
				};
				currentNamespace.Parent.ChildScopes.Add(currentNamespace);
			}
			object ret = namespaceDeclaration.AcceptChildren(this, data);
			currentNamespace = oldNamespace;
			return ret;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:14,代码来源:MapAstToNRefactory.cs

示例3: VisitCompilationUnit

		public override object VisitCompilationUnit(NRefactoryAST.CompilationUnit compilationUnit, object data)
		{
			if (compilationUnit == null) {
				return null;
			}
            mapCompilationUnit(compilationUnit, cu);
			currentNamespace = new DefaultUsingScope();
			if (!string.IsNullOrEmpty(VBRootNamespace)) {
				foreach (string name in VBRootNamespace.Split('.')) {
					currentNamespace = new DefaultUsingScope {
						Parent = currentNamespace,
						NamespaceName = PrependCurrentNamespace(name),
					};
					currentNamespace.Parent.ChildScopes.Add(currentNamespace);
				}
			}
			cu.UsingScope = currentNamespace;
			compilationUnit.AcceptChildren(this, data);
			return cu;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:20,代码来源:MapAstToNRefactory.cs

示例4: VisitTypeDeclaration

		public override object VisitTypeDeclaration(AST.TypeDeclaration typeDeclaration, object data)
		{
			DomRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(typeDeclaration.BodyStartLocation, typeDeclaration.EndLocation);
			
			DefaultClass c = new DefaultClass(cu, TranslateClassType(typeDeclaration.Type), ConvertTypeModifier(typeDeclaration.Modifier), region, GetCurrentClass());
			c.BodyRegion = bodyRegion;
			ConvertAttributes(typeDeclaration, c);
			c.Documentation = GetDocumentation(region.BeginLine, typeDeclaration.Attributes);
			
			if (currentClass.Count > 0) {
				DefaultClass cur = GetCurrentClass();
				cur.InnerClasses.Add(c);
				c.FullyQualifiedName = cur.FullyQualifiedName + '.' + typeDeclaration.Name;
			} else {
				if (currentNamespace.Count == 0) {
					c.FullyQualifiedName = typeDeclaration.Name;
				} else {
					c.FullyQualifiedName = currentNamespace.Peek() + '.' + typeDeclaration.Name;
				}
				cu.Classes.Add(c);
			}
			currentClass.Push(c);
			
			if (c.ClassType != ClassType.Enum && typeDeclaration.BaseTypes != null) {
				foreach (AST.TypeReference type in typeDeclaration.BaseTypes) {
					IReturnType rt = CreateReturnType(type);
					if (rt != null) {
						c.BaseTypes.Add(rt);
					}
				}
			}
			
			ConvertTemplates(typeDeclaration.Templates, c); // resolve constrains in context of the class
			
			object ret = typeDeclaration.AcceptChildren(this, data);
			currentClass.Pop();
			
			if (c.ClassType == ClassType.Module) {
				foreach (IField f in c.Fields) {
					f.Modifiers |= ModifierEnum.Static;
				}
				foreach (IMethod m in c.Methods) {
					m.Modifiers |= ModifierEnum.Static;
				}
				foreach (IProperty p in c.Properties) {
					p.Modifiers |= ModifierEnum.Static;
				}
				foreach (IEvent e in c.Events) {
					e.Modifiers |= ModifierEnum.Static;
				}
			}
			
			return ret;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:55,代码来源:NRefactoryASTConvertVisitor.cs

示例5: VisitNamespaceDeclaration

		public override object VisitNamespaceDeclaration(AST.NamespaceDeclaration namespaceDeclaration, object data)
		{
			string name;
			if (currentNamespace.Count == 0) {
				name = namespaceDeclaration.Name;
			} else {
				name = currentNamespace.Peek() + '.' + namespaceDeclaration.Name;
			}
			
			currentNamespace.Push(name);
			object ret = namespaceDeclaration.AcceptChildren(this, data);
			currentNamespace.Pop();
			return ret;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:14,代码来源:NRefactoryASTConvertVisitor.cs

示例6: VisitCompilationUnit

		public override object VisitCompilationUnit(AST.CompilationUnit compilationUnit, object data)
		{
			if (compilationUnit == null) {
				return null;
			}
			compilationUnit.AcceptChildren(this, data);
			return cu;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:NRefactoryASTConvertVisitor.cs


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