Ejemplo n.º 1
0
        public static void AddError(Token token, string message)
        {
            if (errors.ContainsKey(token))
                return;

            errors.Add(token, message);
        }
Ejemplo n.º 2
0
 public EngineException(ExceptionType type, string message, Token token)
 {
     Type = type;
     Message = message;
     Token = token;
     Line = token.Line;
     Position = token.Position;
 }
Ejemplo n.º 3
0
 public EngineException(ExceptionType type, string message)
 {
     Type = type;
     Message = message;
     Token = new Token(TokenType.IDENTIFIER, "", null);
     Line = (GetCurrentLine == null) ? 0 : GetCurrentLine();
     Position = 0;
 }
Ejemplo n.º 4
0
        public TokenChars(Token token)
        {
            Token = token;
            Characters = GetCharsByIndices(token.Indices);

            foreach (var c in Characters)
            {
                c.ParentToken = token;
            }
        }
Ejemplo n.º 5
0
        private static void PopulateHTMLAttributeList(Token token, List<Token> tokens)
        {
            AutoCompleteService.Instance.ClearListboxItems();

            // add element-specific attributes
            if (IsInsideIncompleteAttributeName(token, tokens))
            {
                var element = GetElementWhileTypingAttribute(token, tokens);

                if (element != null)
                    AddHTMLAttributesToList(element.Attributes);
            }

            // add global attributes
            AddHTMLAttributesToList(GlobalHTMLAttributes);

            _listState = AutoCompleteListState.Attributes;
        }
Ejemplo n.º 6
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("<");
 }
Ejemplo n.º 7
0
        private static bool IsInsideIncompleteAttributeName(Token token, List<Token> tokens)
        {
            Token currentToken;

            if (token == null) // this is true when the character before caret is white-space
                currentToken = Controller.Instance.TokenBeforeCaret;
            else
                currentToken = token;

            if (token == null)
                return false;

            if (token.Type != TokenType.IDENTIFIER)
                return false;

            while (currentToken.Type != TokenType.EOF)
            {
                if (currentToken.Value.Equals("<"))
                    return true;

                if (currentToken.Value.Equals("/"))
                    return false;

                if (currentToken.Value.Equals(">"))
                    return false;

                currentToken = currentToken.Previous(tokens);
            }

            return false;
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
        public void GotoToken(Token token)
        {
            currentTokenIndex = tokens.IndexOf(token);

            if (currentTokenIndex == -1)
                currentTokenIndex = 0;
        }
Ejemplo n.º 10
0
        public bool FallsBefore(List<Token> list, Token target)
        {
            int selfIndex = Index(list);
            int targetIndex = list.IndexOf(target);

            if (selfIndex < targetIndex)
                return true;

            return false;
        }
Ejemplo n.º 11
0
        public static TokenChars GetTokenCharsByToken(this List<TokenChars> tcList, Token t)
        {
            foreach (var tc in tcList)
            {
                if (tc.Token == t)
                    return tc;
            }

            return null;
        }