internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData) { Contracts.AssertValue(intellisenseData); TexlNode curNode = intellisenseData.CurNode; int cursorPos = intellisenseData.CursorPos; // Cursor is in the operation token or before. // Suggest all value possibilities. UnaryOpNode unaryOpNode = curNode.CastUnaryOp(); var tokenSpan = unaryOpNode.Token.Span; if (cursorPos < tokenSpan.Min) { return(false); } Contracts.Assert(cursorPos >= tokenSpan.Min || cursorPos <= tokenSpan.Lim); string keyword = TexlParser.GetTokString(unaryOpNode.Token.Kind); Contracts.Assert(intellisenseData.MatchingLength <= keyword.Length); var replacementLength = tokenSpan.Min == cursorPos ? 0 : tokenSpan.Lim - tokenSpan.Min; intellisenseData.SetMatchArea(tokenSpan.Min, cursorPos, replacementLength); intellisenseData.BoundTo = intellisenseData.MatchingLength == 0 ? string.Empty : keyword; IntellisenseHelper.AddSuggestionsForValuePossibilities(intellisenseData, curNode); return(true); }
public bool EnsureParsed(TexlParser.Flags flags) { AssertValid(); if (_tree == null) { var result = TexlParser.ParseScript(Script, loc: Loc, flags: flags); _tree = result.Root; _errors = result.Errors; _comments = result.Comments; HasParseErrors = result.HasError; Contracts.AssertValue(_tree); AssertValid(); } return(_errors == null); }
public override LazyList <string> Visit(DottedNameNode node, Precedence parentPrecedence) { Contracts.AssertValue(node); string separator = TexlParser.GetTokString(node.Token.Kind); var values = node.Left.Accept(this, Precedence.Primary); values = values.With(separator); if (node.Right.AtToken != null) { values = values.With(TexlLexer.PunctuatorAt); } values = values.With(GetRightToken(node.Left, node.Right)); if (node.UsesBracket) { values = values.With(TexlLexer.PunctuatorBracketClose); } return(ApplyPrecedence(parentPrecedence, Precedence.Primary, values)); }
public override LazyList <string> Visit(DottedNameNode node, Precedence parentPrecedence) { Contracts.AssertValue(node); string separator = TexlParser.GetTokString(node.Token.Kind); var values = node.Left.Accept(this, Precedence.Primary); values = values.With(separator); if (node.Right.AtToken != null || node.UsesBracket) { values = values.With("#$disambiguation$#"); } else { values = values.With(node.RightNode?.Accept(this, parentPrecedence) ?? LazyList <string> .Of("#$righthandid$#")); } return(ApplyPrecedence(parentPrecedence, Precedence.Primary, values)); }
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData) { Contracts.AssertValue(intellisenseData); TexlNode curNode = intellisenseData.CurNode; // Cursor is in the operation token. // Suggest binary operators. BinaryOpNode binaryOpNode = curNode.CastBinaryOp(); var tokenSpan = binaryOpNode.Token.Span; string keyword = binaryOpNode.Op == BinaryOp.Error ? tokenSpan.GetFragment(intellisenseData.Script) : TexlParser.GetTokString(binaryOpNode.Token.Kind); int replacementLength = tokenSpan.Min == intellisenseData.CursorPos ? 0 : tokenSpan.Lim - tokenSpan.Min; intellisenseData.SetMatchArea(tokenSpan.Min, intellisenseData.CursorPos, replacementLength); intellisenseData.BoundTo = binaryOpNode.Op == BinaryOp.Error ? string.Empty : keyword; AddSuggestionsForBinaryOperatorKeyWords(intellisenseData); return(true); }