/// <summary>Initializes a new instance of the <see cref="CodeAnnotationFix"/> class.</summary> /// <param name="highlight">The highlight.</param> public CodeAnnotationFix([NotNull] CodeAnnotationHighlight highlight) { this.Highlight = highlight; }
/// <summary>Runs the specified element.</summary> /// <param name="treeNode">The tree node.</param> /// <param name="data">The data.</param> /// <param name="consumer">The consumer.</param> protected override void Run(ITypeMemberDeclaration treeNode, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { CodeAnnotationModel model = null; var daemon = (DaemonProcessBase)data.Process; if (daemon.LastRunTimestamp != this.lastRunTimestamp) { this.SetAttributes(data, treeNode); this.lastRunTimestamp = daemon.LastRunTimestamp; } var range = DocumentRange.InvalidRange; var method = treeNode as IMethodDeclaration; if (method != null) { model = new CodeAnnotationModel(this.PublicAssertionCode, this.NonPublicAssertionCode, this.AlternativeAssertions); model.Inspect(method); range = method.NameIdentifier.GetDocumentRange(); } if (model == null) { var property = treeNode as IPropertyDeclaration; if (property != null) { model = new CodeAnnotationModel(this.PublicAssertionCode, this.NonPublicAssertionCode, this.AlternativeAssertions); model.Inspect(property); range = property.NameIdentifier.GetDocumentRange(); } } if (model == null) { var constructor = treeNode as IConstructorDeclaration; if (constructor != null) { model = new CodeAnnotationModel(this.PublicAssertionCode, this.NonPublicAssertionCode, this.AlternativeAssertions); model.Inspect(constructor); range = constructor.Name.GetDocumentRange(); } } if (model == null) { var indexer = treeNode as IIndexerDeclaration; if (indexer != null) { model = new CodeAnnotationModel(this.PublicAssertionCode, this.NonPublicAssertionCode, this.AlternativeAssertions); model.Inspect(indexer); range = indexer.NameIdentifier.GetDocumentRange(); } } if (model == null || model.IsAnnotated) { return; } var highlight = new CodeAnnotationHighlight(model, range); consumer.AddHighlighting(highlight, range, treeNode.GetContainingFile()); }