public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context) { var delegateVisitor = new GetDelgateUsagesVisitor (context); context.RootNode.AcceptVisitor (delegateVisitor); return new GatherVisitor (context, delegateVisitor).GetIssues (); }
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) {} }); }
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; }
public GatherVisitor(BaseRefactoringContext ctx, GetDelgateUsagesVisitor usedDelegates) : base(ctx) { this.usedDelegates = usedDelegates; }