Beispiel #1
0
        public void ShouldReturnElementNodeGivenPositionAfterColonInElementName()
        {
            var nodeType  = SparkSyntax.ParseContext("<div><use: </div>", position: 10);
            var chunkType = SparkSyntax.ParseContextChunk("<div><use: </div>", position: 10);

            Assert.That(nodeType, Is.EqualTo(typeof(ElementNode)));
            Assert.That(chunkType, Is.EqualTo(typeof(UseContentChunk)));
        }
Beispiel #2
0
 private bool IsSparkSyntax(int caretPosition)
 {
     //TODO: Rob G This is a general catch all trap because if something goes wrong during the Beta.
     // We don't was Visual Studio to explode, but rather just that intellisense stops working for
     // this particular key press - it'll try again next time. The Beta will drive out most syntax issues.
     try
     {
         _currentContext = SparkSyntax.ParseContext(_textView.TextBuffer.CurrentSnapshot.GetText(), caretPosition);
         return(_currentContext != null && _currentContext != typeof(TextNode));
     }
     catch
     {
         return(false);
     }
 }
Beispiel #3
0
        public static CompletionSet GetCompletionSetFor(SnapshotPoint triggerPoint, ITrackingSpan trackingSpan, IViewExplorer viewExplorer)
        {
            Type currentContext = SparkSyntax.ParseContext(triggerPoint.Snapshot.GetText(), triggerPoint);

            if (currentContext == typeof(ElementNode))
            {
                return(Create <ElementCompletionSet>(triggerPoint, trackingSpan, viewExplorer));
            }
            if (currentContext == typeof(AttributeNode))
            {
                return(Create <AttributeCompletionSet>(triggerPoint, trackingSpan, viewExplorer));
            }
            if (currentContext == typeof(ExpressionNode))
            {
                return(Create <ExpressionCompletionSet>(triggerPoint, trackingSpan, viewExplorer));
            }
            return(null);
        }
Beispiel #4
0
        public void ShouldReturnTextNodeGivenPositionAfterOpeningBrace()
        {
            Type nodeType = SparkSyntax.ParseContext("{", position: 1);

            Assert.That(nodeType, Is.EqualTo(typeof(TextNode)));
        }
Beispiel #5
0
        public void ShouldReturnExpressionNodeGivenPositionAfterExclamationOpeningBrace()
        {
            Type nodeType = SparkSyntax.ParseContext("!{", position: 2);

            Assert.That(nodeType, Is.EqualTo(typeof(ExpressionNode)));
        }
Beispiel #6
0
        public void ShouldReturnElementNodeGivenPositionInNameOfElement()
        {
            Type nodeType = SparkSyntax.ParseContext("<div><us</div>", position: 8);

            Assert.That(nodeType, Is.EqualTo(typeof(ElementNode)));
        }
Beispiel #7
0
        public void ShouldReturnElementNodeGivenPositionAtStartOfNewlyOpenedElement()
        {
            Type nodeType = SparkSyntax.ParseContext("<div><</div>", position: 6);

            Assert.That(nodeType, Is.EqualTo(typeof(ElementNode)));
        }
Beispiel #8
0
        public void ShouldReturnAttributeNodeGivenPositionInQuotes()
        {
            var nodeType = SparkSyntax.ParseContext("<div><use content=\"main\"/></div>", position: 19);

            Assert.That(nodeType, Is.EqualTo(typeof(AttributeNode)));
        }