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))); }
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); } }
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); }
public void ShouldReturnTextNodeGivenPositionAfterOpeningBrace() { Type nodeType = SparkSyntax.ParseContext("{", position: 1); Assert.That(nodeType, Is.EqualTo(typeof(TextNode))); }
public void ShouldReturnExpressionNodeGivenPositionAfterExclamationOpeningBrace() { Type nodeType = SparkSyntax.ParseContext("!{", position: 2); Assert.That(nodeType, Is.EqualTo(typeof(ExpressionNode))); }
public void ShouldReturnElementNodeGivenPositionInNameOfElement() { Type nodeType = SparkSyntax.ParseContext("<div><us</div>", position: 8); Assert.That(nodeType, Is.EqualTo(typeof(ElementNode))); }
public void ShouldReturnElementNodeGivenPositionAtStartOfNewlyOpenedElement() { Type nodeType = SparkSyntax.ParseContext("<div><</div>", position: 6); Assert.That(nodeType, Is.EqualTo(typeof(ElementNode))); }
public void ShouldReturnAttributeNodeGivenPositionInQuotes() { var nodeType = SparkSyntax.ParseContext("<div><use content=\"main\"/></div>", position: 19); Assert.That(nodeType, Is.EqualTo(typeof(AttributeNode))); }