Пример #1
0
 protected override void CreateTagSpans(TemplateAnalysis analysis)
 {
     if (this.CreateTagSpansMethod != null)
     {
         this.CreateTagSpansMethod(analysis);
     }
 }
Пример #2
0
        public Task <QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken)
        {
            QuickInfoItem quickInfoItem = null;

            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            TemplateAnalysis analysis     = this.analyzer.CurrentAnalysis;
            SnapshotPoint?   triggerPoint = session.GetTriggerPoint(analysis.TextSnapshot);

            if (triggerPoint != null && analysis.Template != null)
            {
                string description;
                Span   applicableTo;
                if (analysis.Template.TryGetDescription(triggerPoint.Value.Position, out description, out applicableTo))
                {
                    ITrackingSpan applicableToSpan = analysis.TextSnapshot.CreateTrackingSpan(applicableTo, SpanTrackingMode.EdgeExclusive);
                    quickInfoItem = new QuickInfoItem(applicableToSpan, description);
                }
            }

            return(Task.FromResult(quickInfoItem));
        }
Пример #3
0
        public void AugmentQuickInfoSession(IAsyncQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            if (quickInfoContent == null)
            {
                throw new ArgumentNullException("quickInfoContent");
            }

            TemplateAnalysis analysis     = this.analyzer.CurrentAnalysis;
            SnapshotPoint?   triggerPoint = session.GetTriggerPoint(analysis.TextSnapshot);

            if (triggerPoint != null && analysis.Template != null)
            {
                string description;
                Span   applicableTo;
                if (analysis.Template.TryGetDescription(triggerPoint.Value.Position, out description, out applicableTo))
                {
                    quickInfoContent.Add(description);
                    applicableToSpan = analysis.TextSnapshot.CreateTrackingSpan(applicableTo, SpanTrackingMode.EdgeExclusive);
                    return;
                }
            }

            applicableToSpan = null;
        }
Пример #4
0
 protected void UpdateTagSpans(TemplateAnalysis templateAnalysis)
 {
     using (this.Update())
     {
         this.RemoveTagSpans(trackingTagSpan => true); // remove all tag spans
         this.CreateTagSpans(templateAnalysis);
     }
 }
Пример #5
0
        public static void CurrentAnalysisReturnsLastTemplateAnalysisResult()
        {
            var buffer = new FakeTextBuffer("<#@");
            var target = TemplateAnalyzer.GetOrCreate(buffer);
            TemplateAnalysis result = target.CurrentAnalysis;

            Assert.NotNull(result);
        }
Пример #6
0
        protected override void CreateTagSpans(TemplateAnalysis analysis)
        {
            ITextSnapshot snapshot = analysis.TextSnapshot;

            foreach (TemplateError error in analysis.Errors)
            {
                this.CreateTagSpan(snapshot.CreateTrackingSpan(error.Span, SpanTrackingMode.EdgeNegative), new ErrorTag(PredefinedErrorTypeNames.SyntaxError, error.Message));
            }
        }
Пример #7
0
        public static void TemplateChangeEventArgumentSuppliesCurrentTemplateAnalysis()
        {
            var buffer = new FakeTextBuffer(string.Empty);
            var target = TemplateAnalyzer.GetOrCreate(buffer);
            TemplateAnalysis eventArgument = null;

            target.TemplateChanged += (sender, args) => { eventArgument = args; };
            buffer.CurrentSnapshot  = new FakeTextSnapshot("42");
            Assert.Same(target.CurrentAnalysis, eventArgument);
        }
Пример #8
0
        private void OnTemplateChanged(TemplateAnalysis templateAnalysis)
        {
            this.CurrentAnalysis = templateAnalysis;

            EventHandler<TemplateAnalysis> handler = this.TemplateChanged;
            if (handler != null)
            {
                handler(this, templateAnalysis);
            }
        }
Пример #9
0
        private void OnTemplateChanged(TemplateAnalysis templateAnalysis)
        {
            this.CurrentAnalysis = templateAnalysis;

            EventHandler <TemplateAnalysis> handler = this.TemplateChanged;

            if (handler != null)
            {
                handler(this, templateAnalysis);
            }
        }
Пример #10
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            Debug.Assert(session != null, "session");
            Debug.Assert(completionSets != null, "completionSets");

            TemplateAnalysis current = this.analyzer.CurrentAnalysis;
            var builder = new TemplateCompletionBuilder(session.GetTriggerPoint(current.TextSnapshot).Value.Position);

            builder.Visit(current.Template);
            if (builder.Completions != null)
            {
                ITrackingSpan            applicableTo = current.TextSnapshot.CreateTrackingSpan(builder.Node.Span, SpanTrackingMode.EdgeInclusive);
                IEnumerable <Completion> completions  = builder.Completions.OrderBy(completion => completion.DisplayText);
                var completionSet = new CompletionSet("All", "All", applicableTo, completions, null);
                completionSets.Add(completionSet);
            }
        }
Пример #11
0
        protected override void CreateTagSpans(TemplateAnalysis analysis)
        {
            // If text buffer contains recognizable template
            Template template = analysis.Template;

            if (template != null)
            {
                ITextSnapshot snapshot = analysis.TextSnapshot;
                string        text     = snapshot.GetText();
                foreach (CodeBlock codeBlock in template.ChildNodes().OfType <CodeBlock>())
                {
                    ITrackingSpan trackingSpan = snapshot.CreateTrackingSpan(codeBlock.Span, SpanTrackingMode.EdgeNegative);

                    string collapsedForm     = GetCollapsedForm(codeBlock, text);
                    string collapsedHintForm = GetCollapsedHintForm(codeBlock, text);
                    var    tag = new OutliningRegionTag(collapsedForm, collapsedHintForm);

                    this.CreateTagSpan(trackingSpan, tag);
                }
            }
        }
Пример #12
0
        private void UpdateErrorTasks(TemplateAnalysis templateAnalysis)
        {
            if (this.errorListProvider != null)
            {
                this.errorListProvider.Tasks.Clear();
            }
            else if (templateAnalysis.Errors.Count > 0)
            {
                this.errorListProvider = new ErrorListProvider(this.serviceProvider);
            }

            foreach (TemplateError error in templateAnalysis.Errors)
            {
                var errorTask = new ErrorTask();
                errorTask.Document = this.document.FilePath;
                errorTask.Category = TaskCategory.BuildCompile;
                errorTask.Text = error.Message;
                errorTask.ErrorCategory = TaskErrorCategory.Error;
                errorTask.Line = error.Position.Line;
                errorTask.Column = error.Position.Column;
                errorTask.Navigate += this.NavigateToError;
                this.errorListProvider.Tasks.Add(errorTask);
            }
        }
Пример #13
0
        private void UpdateErrorTasks(TemplateAnalysis templateAnalysis)
        {
            if (this.errorListProvider != null)
            {
                this.errorListProvider.Tasks.Clear();
            }
            else if (templateAnalysis.Errors.Count > 0)
            {
                this.errorListProvider = new ErrorListProvider(this.serviceProvider);
            }

            foreach (TemplateError error in templateAnalysis.Errors)
            {
                var errorTask = new ErrorTask();
                errorTask.Document      = this.document.FilePath;
                errorTask.Category      = TaskCategory.BuildCompile;
                errorTask.Text          = error.Message;
                errorTask.ErrorCategory = TaskErrorCategory.Error;
                errorTask.Line          = error.Position.Line;
                errorTask.Column        = error.Position.Column;
                errorTask.Navigate     += this.NavigateToError;
                this.errorListProvider.Tasks.Add(errorTask);
            }
        }
Пример #14
0
 private void TemplateChanged(object sender, TemplateAnalysis e)
 {
     this.UpdateErrorTasks(e);
 }
Пример #15
0
 private void TemplateChanged(object sender, TemplateAnalysis e)
 {
     this.UpdateErrorTasks(e);
 }
Пример #16
0
 private void TemplateChanged(object sender, TemplateAnalysis currentAnalysis)
 {
     this.UpdateTagSpans(currentAnalysis);
 }
Пример #17
0
 protected abstract void CreateTagSpans(TemplateAnalysis analysis);
Пример #18
0
 public new void UpdateTagSpans(TemplateAnalysis analysis)
 {
     base.UpdateTagSpans(analysis);
 }