public void ShouldReturnTextNodeWhenGivenNewlyOpenedElementAtEndOfLine()
        {
            var node = SparkSyntax.ParseNode(String.Format("<div><{0}</div>", Environment.NewLine), position: 7);

            Assert.That(node, Is.InstanceOf(typeof(TextNode)));
            Assert.That(((TextNode)node).Text, Is.EqualTo("<"));
        }
        public void ShouldReturnTextNodeWhenGivenNewlyOpenedElement()
        {
            var node = SparkSyntax.ParseNode("<div><</div>", position: 6);

            Assert.That(node, Is.InstanceOf(typeof(TextNode)));
            Assert.That(((TextNode)node).Text, Is.EqualTo("<"));
        }
        public void ShouldReturnExpressionNodeGivenAnUnclosedExpression()
        {
            var node = SparkSyntax.ParseNode("<div>${item</div>", position: 11);

            Assert.That(node, Is.InstanceOf(typeof(ExpressionNode)));
            Assert.That(((ExpressionNode)node).Code.Count, Is.EqualTo(1));
        }
        public void ShouldReturnElementNodeGivenPositionInsideAnyElement()
        {
            var node = SparkSyntax.ParseNode("<div></div>", position: 1);

            Assert.That(node, Is.InstanceOf(typeof(ElementNode)));
            Assert.That(((ElementNode)node).Name, Is.EqualTo("div"));
        }
        public void ShouldReturnElementNodeWithoutAttributesWhenGivenAnUnclosedAttributeValue()
        {
            var node = SparkSyntax.ParseNode("<use content='main ", position: 10);

            Assert.That(node, Is.InstanceOf(typeof(ElementNode)));
            Assert.That(((ElementNode)node).Name, Is.EqualTo("use"));
            Assert.That(((ElementNode)node).Attributes.Count, Is.EqualTo(0));
        }
Beispiel #6
0
        public void ParseNodeShouldReturnElementNodeGivenPositionOne()
        {
            var sparkSyntax = new SparkSyntax();
            var node        = sparkSyntax.ParseNode("<div></div>", position: 1);

            Assert.That(node, Is.InstanceOfType(typeof(ElementNode)));
            Assert.That(((ElementNode)node).Name, Is.EqualTo("div"));
        }
        private bool TryEvaluateSparkSyntax(int caretPosition, out Node sparkNode)
        {
            var sparkSyntax = new SparkSyntax();
            var currentNode = sparkSyntax.ParseNode(_textView.TextBuffer.CurrentSnapshot.GetText(), caretPosition);

            sparkNode = null;
            return(_projectExplorer.IsCurrentDocumentASparkFile()
                ? sparkSyntax.IsSparkElementNode(currentNode, out sparkNode)
                : false);
        }
        public void ShouldReturnElementNodeGivenAnUnclosedElementAtTheEndOfTheContent()
        {
            var node = SparkSyntax.ParseNode("<use content='main'", position: 10);

            Assert.That(node, Is.InstanceOf(typeof(ElementNode)));
            Assert.That(((ElementNode)node).Name, Is.EqualTo("use"));
            Assert.That(((ElementNode)node).Attributes.Count, Is.EqualTo(1));
            Assert.That(((ElementNode)node).Attributes[0].Name, Is.EqualTo("content"));
            Assert.That(((ElementNode)node).Attributes[0].Value, Is.EqualTo("main"));
        }
        public void ShouldReturnElementNodeGivenPositionInsideACompleteElement()
        {
            var node = SparkSyntax.ParseNode("<div><use content='main'/></div>", position: 6);

            Assert.That(node, Is.InstanceOf(typeof(ElementNode)));
            Assert.That(((ElementNode)node).Name, Is.EqualTo("use"));
            Assert.That(((ElementNode)node).Attributes.Count, Is.EqualTo(1));
            Assert.That(((ElementNode)node).Attributes[0].Name, Is.EqualTo("content"));
            Assert.That(((ElementNode)node).Attributes[0].Value, Is.EqualTo("main"));
        }
        public void IsSparkNodeShouldReturnSpecialNodeForUnclosedElement()
        {
            var node = SparkSyntax.ParseNode("<use >", position: 1);

            Node sparkNode;
            var  isSparkNode = SparkSyntax.IsSpecialNode(node, out sparkNode);

            Assert.That(isSparkNode);
            Assert.IsNotNull(sparkNode);
            Assert.That(sparkNode, Is.InstanceOf(typeof(SpecialNode)));
        }
        public void IsSparkNodeShouldReturnElementNodeIfNotSparkSyntax()
        {
            var node = SparkSyntax.ParseNode("<div id='products'/>", position: 1);

            Node elementNode;
            var  isSparkNode = SparkSyntax.IsSpecialNode(node, out elementNode);

            Assert.That(!isSparkNode);
            Assert.IsNotNull(elementNode);
            Assert.That(elementNode, Is.InstanceOf(typeof(ElementNode)));
        }
        public void IsSparkNodeShouldReturnSpecialNodeForFullElementAtPositionInsideASpecialNode()
        {
            var node = SparkSyntax.ParseNode("<use content='main'/>", position: 1);

            Node sparkNode;
            var  isSparkNode = SparkSyntax.IsSpecialNode(node, out sparkNode);

            Assert.That(isSparkNode);
            Assert.IsNotNull(sparkNode);
            Assert.That(sparkNode, Is.InstanceOf(typeof(SpecialNode)));
        }
Beispiel #13
0
        public void ParseNodeShouldReturnElementNodeGivenAnUnclosedElementWithValidAttributes()
        {
            var sparkSyntax = new SparkSyntax();
            var node        = sparkSyntax.ParseNode("<div><use content='main' </div>", position: 10);

            Assert.That(node, Is.InstanceOfType(typeof(ElementNode)));
            Assert.That(((ElementNode)node).Name, Is.EqualTo("use"));
            Assert.That(((ElementNode)node).Attributes.Count, Is.EqualTo(1));
            Assert.That(((ElementNode)node).Attributes[0].Name, Is.EqualTo("content"));
            Assert.That(((ElementNode)node).Attributes[0].Value, Is.EqualTo("main"));
        }
Beispiel #14
0
        public void IsSparkNodeShouldReturnASpecialNodeForClosedEmptyElement()
        {
            var sparkSyntax = new SparkSyntax();
            var node        = sparkSyntax.ParseNode("<use />", position: 1);

            Node sparkNode;
            var  isSparkNode = sparkSyntax.IsSparkElementNode(node, out sparkNode);

            Assert.That(isSparkNode);
            Assert.IsNotNull(sparkNode);
            Assert.That(sparkNode, Is.InstanceOfType(typeof(SpecialNode)));
        }
Beispiel #15
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            _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);
            }

            var           syntax           = new SparkSyntax();
            Node          currentNode      = syntax.ParseNode(_textBuffer.CurrentSnapshot.GetText(), _triggerPoint);
            CompletionSet sparkCompletions = GetCompletionSetFor(currentNode);

            if (sparkCompletions == null)
            {
                return;
            }

            MergeSparkWithAllCompletionsSet(completionSets, sparkCompletions);
            completionSets.Add(sparkCompletions);
        }
        public void ShouldReturnNullGivenPositionAtEndOfLine()
        {
            var node = SparkSyntax.ParseNode(String.Format("<div><use content='main'/>{0}</div>", Environment.NewLine), position: 27);

            Assert.That(node, Is.Null);
        }
        public void ShouldReturnNullGivenPositionBetweenNodes()
        {
            var node = SparkSyntax.ParseNode("<div><use content='main'/></div>", position: 5);

            Assert.That(node, Is.Null);
        }
        public void ShouldReturnNullGivenPositionInAnEndElement()
        {
            var node = SparkSyntax.ParseNode("<div></div>", position: 10);

            Assert.That(node, Is.Null);
        }
        public void ShouldReturnNullGivenPositionAtTheEnd()
        {
            var node = SparkSyntax.ParseNode("<div></div>", position: 11);

            Assert.That(node, Is.Null);
        }