Ejemplo n.º 1
0
 protected override void CreateTagSpans(TemplateAnalysis analysis)
 {
     if (this.CreateTagSpansMethod != null)
     {
         this.CreateTagSpansMethod(analysis);
     }
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
 protected void UpdateTagSpans(TemplateAnalysis templateAnalysis)
 {
     using (this.Update())
     {
         this.RemoveTagSpans(trackingTagSpan => true); // remove all tag spans
         this.CreateTagSpans(templateAnalysis);
     }
 }
Ejemplo n.º 5
0
        public static void CurrentAnalysisReturnsLastTemplateAnalysisResult()
        {
            var buffer = new FakeTextBuffer("<#@");
            var target = TemplateAnalyzer.GetOrCreate(buffer);
            TemplateAnalysis result = target.CurrentAnalysis;

            Assert.NotNull(result);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
        private void OnTemplateChanged(TemplateAnalysis templateAnalysis)
        {
            this.CurrentAnalysis = templateAnalysis;

            EventHandler<TemplateAnalysis> handler = this.TemplateChanged;
            if (handler != null)
            {
                handler(this, templateAnalysis);
            }
        }
Ejemplo n.º 9
0
        private void OnTemplateChanged(TemplateAnalysis templateAnalysis)
        {
            this.CurrentAnalysis = templateAnalysis;

            EventHandler <TemplateAnalysis> handler = this.TemplateChanged;

            if (handler != null)
            {
                handler(this, templateAnalysis);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 14
0
 private void TemplateChanged(object sender, TemplateAnalysis e)
 {
     this.UpdateErrorTasks(e);
 }
Ejemplo n.º 15
0
 private void TemplateChanged(object sender, TemplateAnalysis e)
 {
     this.UpdateErrorTasks(e);
 }
Ejemplo n.º 16
0
 private void TemplateChanged(object sender, TemplateAnalysis currentAnalysis)
 {
     this.UpdateTagSpans(currentAnalysis);
 }
Ejemplo n.º 17
0
 protected abstract void CreateTagSpans(TemplateAnalysis analysis);
Ejemplo n.º 18
0
 public new void UpdateTagSpans(TemplateAnalysis analysis)
 {
     base.UpdateTagSpans(analysis);
 }