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