Previous() public method

public Previous ( List list ) : Token
list List
return Token
Exemplo n.º 1
0
 private static bool IsInsideIncompleteTagName(Token token, List<Token> tokens)
 {
     return	token != null &&
             (token.Type == TokenType.IDENTIFIER || token.Type == TokenType.KEYWORD) &&
             token.Previous(tokens).Value.Equals("<");
 }
Exemplo n.º 2
0
        private static HTMLElement GetElementWhileTypingAttribute(Token token, List<Token> tokens)
        {
            // this will return the HTMLElement when the user is typing the attributes of that element, i.e.
            //		<img class='rounded' alt='' />
            //								  ^ caret here
            // on the previous example, it will return the element "img"
            // if the caret was not inside the brackets, a null will be returned

            var currentToken = token.Previous(tokens);
            while (currentToken.Type != TokenType.EOF)
            {
                if (currentToken.Value.Equals("<") || currentToken.Value.Equals(">"))
                    break;

                if (currentToken.Type == TokenType.KEYWORD && currentToken.Previous(tokens).Value.Equals("<"))
                    break;

                currentToken = currentToken.Previous(tokens);
            }

            if (currentToken.Type == TokenType.KEYWORD)
            {
                return HTMLElements.SingleOrDefault(e => e.Name.Equals(currentToken.Value));
            }

            return null;
        }