protected override void CreateTagSpans(TemplateAnalysis analysis) { if (this.CreateTagSpansMethod != null) { this.CreateTagSpansMethod(analysis); } }
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)); }
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; }
protected void UpdateTagSpans(TemplateAnalysis templateAnalysis) { using (this.Update()) { this.RemoveTagSpans(trackingTagSpan => true); // remove all tag spans this.CreateTagSpans(templateAnalysis); } }
public static void CurrentAnalysisReturnsLastTemplateAnalysisResult() { var buffer = new FakeTextBuffer("<#@"); var target = TemplateAnalyzer.GetOrCreate(buffer); TemplateAnalysis result = target.CurrentAnalysis; Assert.NotNull(result); }
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)); } }
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); }
private void OnTemplateChanged(TemplateAnalysis templateAnalysis) { this.CurrentAnalysis = templateAnalysis; EventHandler<TemplateAnalysis> handler = this.TemplateChanged; if (handler != null) { handler(this, templateAnalysis); } }
private void OnTemplateChanged(TemplateAnalysis templateAnalysis) { this.CurrentAnalysis = templateAnalysis; EventHandler <TemplateAnalysis> handler = this.TemplateChanged; if (handler != null) { handler(this, templateAnalysis); } }
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); } }
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); } } }
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); } }
private void TemplateChanged(object sender, TemplateAnalysis e) { this.UpdateErrorTasks(e); }
private void TemplateChanged(object sender, TemplateAnalysis currentAnalysis) { this.UpdateTagSpans(currentAnalysis); }
protected abstract void CreateTagSpans(TemplateAnalysis analysis);
public new void UpdateTagSpans(TemplateAnalysis analysis) { base.UpdateTagSpans(analysis); }