public static void CurrentAnalysisReturnsSemanticErrorsDetectedInTextBuffer() { var buffer = new FakeTextBuffer("<#@ template bad=\"puppy\" #>"); var target = TemplateAnalyzer.GetOrCreate(buffer); Assert.Equal(1, target.CurrentAnalysis.Errors.Count); }
public static void GetOrCreateReturnsNewTemplateAnalyzerFirstTimeItIsRequestedForTextBuffer() { ITextBuffer buffer = new FakeTextBuffer(string.Empty); TemplateAnalyzer analyzer = TemplateAnalyzer.GetOrCreate(buffer); Assert.NotNull(analyzer); }
internal TemplateCompletionSource(ITextBuffer buffer) { Debug.Assert(buffer != null, "buffer"); this.buffer = buffer; this.analyzer = TemplateAnalyzer.GetOrCreate(buffer); }
public static void CurrentAnalysisReturnsLastTemplateAnalysisResult() { var buffer = new FakeTextBuffer("<#@"); var target = TemplateAnalyzer.GetOrCreate(buffer); TemplateAnalysis result = target.CurrentAnalysis; Assert.NotNull(result); }
public static void GetOrCreateReturnsExistingTemplateAnalyzerSecondTimeItIsRequestedForTextBuffer() { ITextBuffer buffer = new FakeTextBuffer(string.Empty); TemplateAnalyzer analyzer1 = TemplateAnalyzer.GetOrCreate(buffer); TemplateAnalyzer analyzer2 = TemplateAnalyzer.GetOrCreate(buffer); Assert.Same(analyzer1, analyzer2); }
public static void CurrentAnalysisReturnsTextSnapshotForWhichItWasCreated() { var buffer = new FakeTextBuffer(string.Empty); var analyzer = TemplateAnalyzer.GetOrCreate(buffer); ITextSnapshot analysisSnapshot = analyzer.CurrentAnalysis.TextSnapshot; Assert.Same(buffer.CurrentSnapshot, analysisSnapshot); }
public static void CurrentAnalysisReturnsDefaultTemplateIfParserCouldNotCreateOne() { var buffer = new FakeTextBuffer("<#@ t"); var target = TemplateAnalyzer.GetOrCreate(buffer); Template template = target.CurrentAnalysis.Template; Assert.NotNull(template); Assert.Equal(0, template.ChildNodes().Count()); }
public static void CurrentAnalysisReturnsTemplateParsedFromTextBuffer() { var buffer = new FakeTextBuffer("<#@ template language=\"VB\" #>"); var target = TemplateAnalyzer.GetOrCreate(buffer); Template template = target.CurrentAnalysis.Template; Assert.NotNull(template); Assert.Equal(1, template.ChildNodes().Count()); }
public static void GetOrCreateDoesNotPreventGarbageCollectionOfPreviouslyCreatedTemplateAnalyzers() { var analyzer = new WeakReference(TemplateAnalyzer.GetOrCreate(new FakeTextBuffer(string.Empty))); GC.Collect(2, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); Assert.False(analyzer.IsAlive); }
public static void CurrentAnalysisReturnsUpdatedTemplateWhenTextBufferChanges() { var buffer = new FakeTextBuffer("<#@ template language=\"VB\" #>"); var target = TemplateAnalyzer.GetOrCreate(buffer); Assert.Equal(1, target.CurrentAnalysis.Template.ChildNodes().Count()); // Need to touch lazy Template before buffer change for test to be valid buffer.CurrentSnapshot = new FakeTextSnapshot(string.Empty); Assert.Equal(0, target.CurrentAnalysis.Template.ChildNodes().Count()); }
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); }
public static void TemplateChangedEventIsRaisedWhenTextBufferChanges() { var buffer = new FakeTextBuffer(string.Empty); var target = TemplateAnalyzer.GetOrCreate(buffer); bool templateChanged = false; target.TemplateChanged += (sender, args) => { templateChanged = true; }; buffer.CurrentSnapshot = new FakeTextSnapshot("42"); Assert.True(templateChanged); }
public static void CurrentAnalysisReturnsUpdatedErrorsWhenTextBufferChanges() { var buffer = new FakeTextBuffer("<#@"); var target = TemplateAnalyzer.GetOrCreate(buffer); Assert.Equal(1, target.CurrentAnalysis.Errors.Count); // Need to touch lazy property before buffer change for test to be valid buffer.CurrentSnapshot = new FakeTextSnapshot(string.Empty); Assert.Equal(0, target.CurrentAnalysis.Errors.Count); }
public static void TemplateAnalyzerDoesNotPreventTemplateErrorTaggerFromGarbageCollection() { var buffer = new FakeTextBuffer(string.Empty); var analyzer = TemplateAnalyzer.GetOrCreate(buffer); var tagger = new WeakReference(new TestableTemplateTagger(buffer)); GC.Collect(2, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); Assert.NotNull(analyzer); Assert.False(tagger.IsAlive); }
private TemplateErrorReporter(ITextBuffer buffer, IServiceProvider serviceProvider, ITextDocumentFactoryService documentFactory) { Debug.Assert(buffer != null, "buffer"); Debug.Assert(serviceProvider != null, "serviceProvider"); Debug.Assert(documentFactory != null, "documentFactory"); this.serviceProvider = serviceProvider; documentFactory.TryGetTextDocument(buffer, out this.document); WeakEventManager <ITextDocumentFactoryService, TextDocumentEventArgs> .AddHandler(documentFactory, "TextDocumentDisposed", this.DocumentDisposed); this.analyzer = TemplateAnalyzer.GetOrCreate(buffer); WeakEventManager <TemplateAnalyzer, TemplateAnalysis> .AddHandler(this.analyzer, "TemplateChanged", this.TemplateChanged); this.UpdateErrorTasks(this.analyzer.CurrentAnalysis); }
protected TemplateTagger(ITextBuffer buffer) : base(buffer) { this.analyzer = TemplateAnalyzer.GetOrCreate(buffer); WeakEventManager <TemplateAnalyzer, TemplateAnalysis> .AddHandler(this.analyzer, "TemplateChanged", this.TemplateChanged); }
public TemplateQuickInfoSource(ITextBuffer buffer) { Debug.Assert(buffer != null, "buffer"); this.analyzer = TemplateAnalyzer.GetOrCreate(buffer); }