コード例 #1
0
        /// <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());
        }
コード例 #2
0
 /// <summary>Initializes a new instance of the <see cref="CodeAnnotationHighlight"/> class.</summary>
 /// <param name="model">The literal.</param>
 /// <param name="range"></param>
 public CodeAnnotationHighlight([NotNull] CodeAnnotationModel model, DocumentRange range)
 {
     this.Model = model;
     this.Range = range;
 }