public void ShouldReturnAttributeValueContextWhenPositionedOnAnyAttributeInsideQuotes() { var point = GetSnapShotPoint("<div><set x='500' y='60' </div>", 22); var completionSet = (AttributeCompletionSet)CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _stubViewExplorer); Assert.That(completionSet.AttributeContext, Is.EqualTo(AttributeContexts.Value)); }
public void ShouldReturnAttributeNameContextWhenPositionedAfterPreviousClosedAttribute() { var point = GetSnapShotPoint("<div><set x='5' </div>", 16); var completionSet = (AttributeCompletionSet)CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _stubViewExplorer); Assert.That(completionSet.AttributeContext, Is.EqualTo(AttributeContexts.Name)); }
public void ShouldReturnSpecialNodeAttributes() { var point = GetSnapShotPoint("<div><use </div>", 10); var completionSet = CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _stubViewExplorer); var completions = completionSet.Completions.ToList(); Assert.That(completionSet, Is.InstanceOf(typeof(AttributeCompletionSet))); Assert.That(completions.Count, Is.EqualTo(7)); Assert.That(completions.Exists(a => a.DisplayText == "content")); Assert.That(completions.Exists(a => a.DisplayText == "master")); }
public void ShouldHaveAListOfVariables() { SnapshotPoint point = GetSnapShotPoint("${", 2); CompletionSet completionSet = CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _stubViewExplorer); List <Completion> completions = completionSet.Completions.ToList(); Assert.That(completionSet, Is.InstanceOf(typeof(ExpressionCompletionSet))); Assert.That(completions.Count, Is.EqualTo(7)); Assert.That(completions.Exists(a => a.DisplayText == "System")); Assert.That(completions.Exists(a => a.DisplayText == "Spark")); }
public void ShouldReturnMasterNamesAsAttributeValues() { var point = GetSnapShotPoint("<div><use master=\"\" </div>", 18); _mockViewExplorer.Expect(x => x.GetPossibleMasterLayouts()).Return(new List <string> { "html", "master" }); var completionSet = CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _mockViewExplorer); var completions = completionSet.Completions.ToList(); Assert.That(completionSet, Is.InstanceOf(typeof(AttributeCompletionSet))); Assert.That(completions.Count, Is.EqualTo(2)); Assert.That(completions.Exists(a => a.DisplayText == "html")); Assert.That(completions.Exists(a => a.DisplayText == "master")); }
public void ShouldReturnContentNamesAsAttributeValues() { var point = GetSnapShotPoint("<div><content name=\"\" </div>", 20); _mockViewExplorer.Expect(x => x.GetContentNames()).Return(new List <string> { "title", "head", "view", "footer" }); var completionSet = CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _mockViewExplorer); var completions = completionSet.Completions.ToList(); Assert.That(completionSet, Is.InstanceOf(typeof(AttributeCompletionSet))); Assert.That(completions.Count, Is.EqualTo(4)); Assert.That(completions.Exists(a => a.DisplayText == "title")); Assert.That(completions.Exists(a => a.DisplayText == "footer")); }
public void ShouldLookForRelatedPartials() { var mockViewExplorer = MockRepository.GenerateMock <IViewExplorer>(); mockViewExplorer.Expect(x => x.GetRelatedPartials()).Return(new List <string> { "partial1", "partial2" }); var set = CompletionSetFactory.Create <ElementCompletionSet>(new SnapshotPoint(), null, mockViewExplorer); var elementList = set.Completions.ToList(); Assert.That(elementList.Exists(c => c.DisplayText == "partial1")); Assert.That(elementList.Exists(c => c.DisplayText == "partial2")); mockViewExplorer.VerifyAllExpectations(); }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { var triggerPoint = session.GetTriggerPoint(_textBuffer).GetPoint(_textBuffer.CurrentSnapshot); if (!session.Properties.TryGetProperty(typeof(ITrackingSpan), out _trackingSpan)) { _trackingSpan = triggerPoint.Snapshot.CreateTrackingSpan(new Span(triggerPoint, 0), SpanTrackingMode.EdgeInclusive); } CompletionSet sparkCompletions = CompletionSetFactory.GetCompletionSetFor(triggerPoint, _trackingSpan, _viewExplorer); if (sparkCompletions == null) { return; } MergeSparkWithAllCompletionsSet(completionSets, sparkCompletions); completionSets.Add(sparkCompletions); session.Committed += session_Committed; }
public void ShouldReturnVariableNamesAsAttributeValues() { var point = GetSnapShotPoint("<div><test if=\"\" </div>", 15); _mockViewExplorer.Expect(x => x.GetLocalVariables()).Return(new List <string> { "x", "y" }); _mockViewExplorer.Expect(x => x.GetGlobalVariables()).Return(new List <string> { "g1", "g2" }); var completionSet = CompletionSetFactory.GetCompletionSetFor(point, _stubTrackingSpan, _mockViewExplorer); var completions = completionSet.Completions.ToList(); Assert.That(completionSet, Is.InstanceOf(typeof(AttributeCompletionSet))); Assert.That(completions.Count, Is.EqualTo(4)); Assert.That(completions.Exists(a => a.DisplayText == "x")); Assert.That(completions.Exists(a => a.DisplayText == "y")); Assert.That(completions.Exists(a => a.DisplayText == "g1")); Assert.That(completions.Exists(a => a.DisplayText == "g2")); }
public void ShouldReturnSparkSpecialNodes() { var set = CompletionSetFactory.Create <ElementCompletionSet>(new SnapshotPoint(_stubSnapshot, 0), _stubTrackingSpan, _stubViewExplorer); List <Completion> elementList = set.Completions.ToList(); Assert.That(elementList.Exists(c => c.DisplayText == "var")); Assert.That(elementList.Exists(c => c.DisplayText == "def")); Assert.That(elementList.Exists(c => c.DisplayText == "default")); Assert.That(elementList.Exists(c => c.DisplayText == "global")); Assert.That(elementList.Exists(c => c.DisplayText == "viewdata")); Assert.That(elementList.Exists(c => c.DisplayText == "set")); Assert.That(elementList.Exists(c => c.DisplayText == "for")); Assert.That(elementList.Exists(c => c.DisplayText == "test")); Assert.That(elementList.Exists(c => c.DisplayText == "if")); Assert.That(elementList.Exists(c => c.DisplayText == "else")); Assert.That(elementList.Exists(c => c.DisplayText == "elseif")); Assert.That(elementList.Exists(c => c.DisplayText == "content")); Assert.That(elementList.Exists(c => c.DisplayText == "use")); Assert.That(elementList.Exists(c => c.DisplayText == "macro")); Assert.That(elementList.Exists(c => c.DisplayText == "render")); Assert.That(elementList.Exists(c => c.DisplayText == "segment")); Assert.That(elementList.Exists(c => c.DisplayText == "cache")); }