public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
        {
            var delegateVisitor = new GetDelgateUsagesVisitor (context);
            context.RootNode.AcceptVisitor (delegateVisitor);

            return new GatherVisitor (context, delegateVisitor).GetIssues ();
        }
Example #2
0
        void Analyze(CompilationStartAnalysisContext compilationContext)
        {
            var compilation = compilationContext.Compilation;

            compilationContext.RegisterSyntaxTreeAction(delegate(SyntaxTreeAnalysisContext context)
            {
                try
                {
                    if (!compilation.SyntaxTrees.Contains(context.Tree))
                    {
                        return;
                    }
                    var semanticModel = compilation.GetSemanticModel(context.Tree);
                    var root          = context.Tree.GetRoot(context.CancellationToken);
                    var model         = compilationContext.Compilation.GetSemanticModel(context.Tree);
                    if (model.IsFromGeneratedCode(compilationContext.CancellationToken))
                    {
                        return;
                    }
                    var usageVisitor = new GetDelgateUsagesVisitor(semanticModel, context.CancellationToken);
                    usageVisitor.Visit(root);

                    var analyzer = new NodeAnalyzer(context, model, usageVisitor);
                    analyzer.Visit(root);
                }
                catch (OperationCanceledException) {}
            });
        }
		public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
		{
			var delegateVisitor = new GetDelgateUsagesVisitor (context);
			context.RootNode.AcceptVisitor (delegateVisitor);

			return new GatherVisitor (context, delegateVisitor).GetIssues ();
		}
Example #4
0
        protected override IGatherVisitor CreateVisitor(BaseRefactoringContext context)
        {
            var delegateVisitor = new GetDelgateUsagesVisitor(context);

            context.RootNode.AcceptVisitor(delegateVisitor);

            return(new GatherVisitor(context, delegateVisitor));
        }
        void Analyze(CompilationStartAnalysisContext compilationContext)
        {
            var compilation = compilationContext.Compilation;
            compilationContext.RegisterSyntaxTreeAction(async delegate (SyntaxTreeAnalysisContext context)
            {
                try
                {
                    if (!compilation.SyntaxTrees.Contains(context.Tree))
                        return;
                    var semanticModel = compilation.GetSemanticModel(context.Tree);
                    var root = await context.Tree.GetRootAsync(context.CancellationToken).ConfigureAwait(false);
                    var model = compilationContext.Compilation.GetSemanticModel(context.Tree);
                    if (model.IsFromGeneratedCode(compilationContext.CancellationToken))
                        return;
                    var usageVisitor = new GetDelgateUsagesVisitor(semanticModel, context.CancellationToken);
                    usageVisitor.Visit(root);

                    var analyzer = new NodeAnalyzer(context, model, usageVisitor);
                    analyzer.Visit(root);
                }
                catch (OperationCanceledException) {}
            });
        }
 public NodeAnalyzer(SyntaxTreeAnalysisContext ctx, SemanticModel model, GetDelgateUsagesVisitor visitor)
 {
     this.ctx = ctx;
     this.model = model;
     this.visitor = visitor;
 }
Example #7
0
 public GatherVisitor(BaseRefactoringContext ctx, GetDelgateUsagesVisitor usedDelegates)
     : base(ctx)
 {
     this.usedDelegates = usedDelegates;
 }
 public GatherVisitor(BaseRefactoringContext ctx, GetDelgateUsagesVisitor usedDelegates)
     : base(ctx)
 {
     this.usedDelegates = usedDelegates;
 }
Example #9
0
 public NodeAnalyzer(SyntaxTreeAnalysisContext ctx, SemanticModel model, GetDelgateUsagesVisitor visitor)
 {
     this.ctx     = ctx;
     this.model   = model;
     this.visitor = visitor;
 }