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


C# CompilationUnit.AcceptVisitor方法代码示例

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


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

示例1: VisitCompilationUnit

		public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
		{
			base.VisitCompilationUnit(compilationUnit, data);
			if (!string.IsNullOrEmpty(NamespacePrefixToAdd)) {
				for (int i = 0; i < compilationUnit.Children.Count; i++) {
					NamespaceDeclaration ns = compilationUnit.Children[i] as NamespaceDeclaration;
					if (ns != null) {
						ns.Name = NamespacePrefixToAdd + "." + ns.Name;
					}
					if (compilationUnit.Children[i] is TypeDeclaration || compilationUnit.Children[i] is DelegateDeclaration) {
						ns = new NamespaceDeclaration(NamespacePrefixToAdd);
						ns.AddChild(compilationUnit.Children[i]);
						compilationUnit.Children[i] = ns;
					}
				}
			}
			
			ToCSharpConvertVisitor v = new ToCSharpConvertVisitor();
			compilationUnit.AcceptVisitor(v, data);
			if (projectContent != null && projectContent.DefaultImports != null) {
				int index = 0;
				foreach (string u in projectContent.DefaultImports.Usings) {
					compilationUnit.Children.Insert(index++, new UsingDeclaration(u));
				}
			}
			return null;
		}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:27,代码来源:VBNetToCSharpConvertVisitor.cs

示例2: VisitCompilationUnit

		public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
		{
			base.VisitCompilationUnit(compilationUnit, data);
			ToVBNetConvertVisitor v = new ToVBNetConvertVisitor();
			compilationUnit.AcceptVisitor(v, data);
			return null;
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:CSharpToVBNetConvertVisitor.cs

示例3: GenerateText

		public static string GenerateText(TypeDeclaration type, OrderedPartCollection<AbstractDynamicCompilationExtension> extensions)
		{
			var unit = new CompilationUnit();

			var namespaces = new HashSet<string>
			{
				typeof (SystemTime).Namespace,
				typeof (AbstractViewGenerator).Namespace,
				typeof (Enumerable).Namespace,
				typeof (IEnumerable<>).Namespace,
				typeof (IEnumerable).Namespace,
				typeof (int).Namespace,
				typeof (LinqOnDynamic).Namespace,
				typeof(Field).Namespace,
			};
			foreach (var extension in extensions)
			{
				foreach (var ns in extension.Value.GetNamespacesToImport())
				{
					namespaces.Add(ns);
				}
			}

			foreach (var ns in namespaces)
			{
				unit.AddChild(new Using(ns));
			}

			unit.AddChild(type);
			var output = new CSharpOutputVisitor();
			unit.AcceptVisitor(output, null);

			return output.Text;
		}
开发者ID:iamnilay3,项目名称:ravendb,代码行数:34,代码来源:QueryParsingUtils.cs

示例4: rewriteCode_CSharp

 public void rewriteCode_CSharp(CompilationUnit unit, IList<ISpecial> specials)
 {        	
     var outputVisitor  = new CSharpOutputVisitor();    		
     using (SpecialNodesInserter.Install(specials, outputVisitor)) {
         unit.AcceptVisitor(outputVisitor, null);
     }
     //codeTextBox.Text = outputVisitor.Text.Replace("\t", "  ");
     CSharpCode = outputVisitor.Text;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:AstDetails.cs

示例5: ConvertAst

		protected override void ConvertAst(CompilationUnit compilationUnit, List<ISpecial> specials, FileProjectItem sourceItem)
		{
			PreprocessingDirective.CSharpToVB(specials);
			IProjectContent pc = ParserService.GetProjectContent(sourceItem.Project) ?? ParserService.CurrentProjectContent;
			CSharpToVBNetConvertVisitor visitor = new CSharpToVBNetConvertVisitor(pc, ParserService.GetParseInformation(sourceItem.FileName));
			visitor.RootNamespaceToRemove = sourceItem.Project.RootNamespace;
			visitor.DefaultImportsToRemove = defaultImports;
			visitor.StartupObjectToMakePublic = startupObject;
			compilationUnit.AcceptVisitor(visitor, null);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:10,代码来源:CSharpToVBNetConverter.cs

示例6: ConvertAst

		protected override void ConvertAst(CompilationUnit compilationUnit, List<ISpecial> specials, FileProjectItem sourceItem)
		{
			PreprocessingDirective.VBToCSharp(specials);
			CompilableProject project = (CompilableProject)sourceItem.Project;
			RemoveWindowsFormsSpecificCode(compilationUnit, specials, project.OutputType == OutputType.WinExe);
			
			IProjectContent pc = ParserService.GetProjectContent(sourceItem.Project) ?? ParserService.CurrentProjectContent;
			VBNetToCSharpConvertVisitor visitor = new VBNetToCSharpConvertVisitorWithMyFormsSupport(pc, ParserService.GetParseInformation(sourceItem.FileName), sourceItem.Project.RootNamespace);
			compilationUnit.AcceptVisitor(visitor, null);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:10,代码来源:VBNetToCSharpConverter.cs

示例7: setCurrentCompilationUnit

 public ICompilationUnit setCurrentCompilationUnit(CompilationUnit compilationUnit)
 {
     if (compilationUnit == null)
         return null;
     NRefactoryASTConvertVisitor converter;
     converter = new NRefactoryASTConvertVisitor(myProjectContent);
     compilationUnit.AcceptVisitor(converter, null);
     var newCompilationUnit = converter.Cu;
     parseInformation.SetCompilationUnit(newCompilationUnit);
     return newCompilationUnit;            
 }
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:11,代码来源:O2AstResolver.cs

示例8: rewriteCode_VBNet

        public void rewriteCode_VBNet(CompilationUnit unit, IList<ISpecial> specials)
        {
            var outputVisitor  = new VBNetOutputVisitor();
            using (SpecialNodesInserter.Install(specials, outputVisitor)) {
                unit.AcceptVisitor(outputVisitor, null);
            }
            //codeTextBox.Text = outputVisitor.Text.Replace("\t", "  ");
            VBNetCode = outputVisitor.Text;

            //    		PublicDI.log.debug(recreatedCode);
        }
开发者ID:njmube,项目名称:FluentSharp,代码行数:11,代码来源:AstDetails.cs

示例9: loadCompilationUnit

    //DC
 /*   public void loadCode(string code)
    { 
        code = (code.fileExists()) ? code.fileContents() : code;
        var parser = code.csharpAst();
        loadCompilationUnit(parser.CompilationUnit);
    }*/
    //DC
    public void loadCompilationUnit(CompilationUnit compilationUnit)
    {
        try
        {
            compilationUnit.AcceptVisitor(this, null);
        }
        catch (Exception ex)
        {
            ex.log("in MapAstToDom loadCompilationUnit");
        }
    }
开发者ID:pusp,项目名称:o2platform,代码行数:19,代码来源:MapAstToDom.cs

示例10: GenerateText

        public static string GenerateText(TypeDeclaration type)
        {
            var unit = new CompilationUnit();
            unit.AddChild(new Using(typeof (AbstractViewGenerator).Namespace));
            unit.AddChild(new Using(typeof (Enumerable).Namespace));
            unit.AddChild(new Using(typeof (int).Namespace));
            unit.AddChild(new Using(typeof (LinqOnDynamic).Namespace));
            unit.AddChild(type);

            var output = new CSharpOutputVisitor();
            unit.AcceptVisitor(output, null);

            return output.Text;
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:14,代码来源:QueryParsingUtils.cs

示例11: ConvertAst

		protected override void ConvertAst(CompilationUnit compilationUnit, List<ISpecial> specials, FileProjectItem sourceItem)
		{
			PreprocessingDirective.VBToCSharp(specials);
			CompilableProject project = (CompilableProject)sourceItem.Project;
			RemoveWindowsFormsSpecificCode(compilationUnit, specials, project.OutputType == OutputType.WinExe);
			
			IProjectContent pc = ParserService.GetProjectContent(sourceItem.Project) ?? ParserService.CurrentProjectContent;
			VBNetToCSharpConvertVisitor visitor = new VBNetToCSharpConvertVisitorWithMyFormsSupport(pc, ParserService.GetParseInformation(sourceItem.FileName), sourceItem.Project.RootNamespace);
						
			// set project options
			visitor.OptionInfer = (project.GetEvaluatedProperty("OptionInfer") ?? "Off")
				.Equals("On", StringComparison.OrdinalIgnoreCase);
			visitor.OptionStrict = (project.GetEvaluatedProperty("OptionStrict") ?? "Off")
				.Equals("On", StringComparison.OrdinalIgnoreCase);
			
			compilationUnit.AcceptVisitor(visitor, null);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:17,代码来源:VBNetToCSharpConverter.cs

示例12: ConvertCompilationUnit

 private ICompilationUnit ConvertCompilationUnit(CompilationUnit cu)
 {
     NRefactoryASTConvertVisitor converter;
     converter = new NRefactoryASTConvertVisitor(myProjectContent);
     cu.AcceptVisitor(converter, null);
     return converter.Cu;
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:7,代码来源:MainForm.cs

示例13: ConvertCompilationUnit

		private ICompilationUnit ConvertCompilationUnit(CompilationUnit cu)
		{
			var supportedLanguage = SupportedLanguage == SupportedLanguage.CSharp
				? ICSharpCode.NRefactory.SupportedLanguage.CSharp
				: ICSharpCode.NRefactory.SupportedLanguage.VBNet;
			var converter = new NRefactoryASTConvertVisitor(ProjectContent, supportedLanguage);
			cu.AcceptVisitor(converter, null);
			return converter.Cu;
		}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:9,代码来源:IntellisenseForm.cs

示例14: ResolveLowLevel

		public static ResolveResult ResolveLowLevel(string fileName, string fileContent, int caretLine, int caretColumn, CompilationUnit compilationUnit, string expressionString, Expression expression, ExpressionContext context)
		{
			if (fileName == null) {
				throw new ArgumentNullException("fileName");
			}
			if (fileContent == null) {
				throw new ArgumentNullException("fileName");
			}
			if (expression == null) {
				throw new ArgumentNullException("expression");
			}
			
			IProject p = ProjectFileDictionaryService.GetProjectForFile(fileName);
			if (p == null) {
				LoggingService.Info("ResourceToolkit: NRefactoryAstCacheService: ResolveLowLevel failed. Project is null for file '"+fileName+"'");
				return null;
			}
			
			IProjectContent pc = ResourceResolverService.GetProjectContent(p);
			if (pc == null) {
				LoggingService.Info("ResourceToolkit: NRefactoryAstCacheService: ResolveLowLevel failed. ProjectContent is null for project '"+p.ToString()+"'");
				return null;
			}
			
			NRefactoryResolver resolver = ResourceResolverService.CreateResolver(fileName) as NRefactoryResolver;
			if (resolver == null) {
				resolver = new NRefactoryResolver(LanguageProperties.CSharp);
			}
			
			if (compilationUnit == null) {
				compilationUnit = GetFullAst(resolver.Language, fileName, fileContent);
			}
			if (compilationUnit == null) {
				LoggingService.Info("ResourceToolkit: NRefactoryAstCacheService: ResolveLowLevel failed due to the compilation unit being unavailable.");
				return null;
			}
			
			if (!resolver.Initialize(ParserService.GetParseInformation(fileName), caretLine, caretColumn)) {
				LoggingService.Info("ResourceToolkit: NRefactoryAstCacheService: ResolveLowLevel failed. NRefactoryResolver.Initialize returned false.");
				return null;
			}
			
			if (resolver.CallingClass != null) {
				ResolveResult rr;
				if (expressionString == null) {
					// HACK: Re-generate the code for the expression from the expression object by using the code generator.
					// This is necessary when invoking from inside an AST visitor where the
					// code belonging to this expression is unavailable.
					expressionString = resolver.LanguageProperties.CodeGenerator.GenerateCode(expression, String.Empty);
				}
				if ((rr = CtrlSpaceResolveHelper.GetResultFromDeclarationLine(resolver.CallingClass, resolver.CallingMember as IMethodOrProperty, caretLine, caretColumn, new ExpressionResult(expressionString))) != null) {
					return rr;
				}
			}
			
			if (resolver.CallingMember != null) {
				
				// Cache member->node mappings to improve performance
				// (if cache is enabled)
				INode memberNode;
				if (!CacheEnabled || !cachedMemberMappings.TryGetValue(resolver.CallingMember, out memberNode)) {
					MemberFindAstVisitor visitor = new MemberFindAstVisitor(resolver.CallingMember);
					compilationUnit.AcceptVisitor(visitor, null);
					memberNode = visitor.MemberNode;
					if (CacheEnabled && memberNode != null) {
						cachedMemberMappings.Add(resolver.CallingMember, memberNode);
					}
				}
				
				if (memberNode == null) {
					LoggingService.Info("ResourceToolkit: NRefactoryAstCacheService: Could not find member in AST: "+resolver.CallingMember.ToString());
				} else {
					resolver.RunLookupTableVisitor(memberNode);
				}
				
			}
			
			return resolver.ResolveInternal(expression, context);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:79,代码来源:NRefactoryAstCacheService.cs

示例15: RemoveWindowsFormsSpecificCode

		void RemoveWindowsFormsSpecificCode(CompilationUnit compilationUnit, List<ISpecial> specials, bool keepCode)
		{
			for (int i = 0; i < specials.Count; i++) {
				PreprocessingDirective ppd = specials[i] as PreprocessingDirective;
				if (ppd != null && ppd.Cmd == "#if") {
					if (ppd.Arg == "_MyType = \"WindowsForms\"") {
						int depth = 1;
						for (int j = i + 1; j < specials.Count; j++) {
							ppd = specials[j] as PreprocessingDirective;
							if (ppd != null) {
								if (ppd.Cmd == "#if") {
									depth++;
								} else if (ppd.Cmd == "#endif") {
									depth--;
									if (depth == 0) {
										if (keepCode) {
											// keep code, remove only the ifdef
											specials.RemoveAt(j);
											specials.RemoveAt(i);
										} else {
											// remove ifdef including the code
											compilationUnit.AcceptVisitor(new RemoveMembersInRangeVisitor(
												DomRegion.FromLocation(specials[i].StartPosition, specials[j].EndPosition)), null);
											specials.RemoveRange(i, j - i + 1);
										}
										i--;
										break;
									}
								}
							}
						}
					}
				}
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:35,代码来源:VBNetToCSharpConverter.cs


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