Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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"));
        }
Example #5
0
        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"));
        }
Example #6
0
        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 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;
        }
Example #8
0
        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"));
        }