コード例 #1
0
ファイル: ErrorTooltip.xaml.cs プロジェクト: anaimi/codebox
        public static void AddError(Token token, string message)
        {
            if (errors.ContainsKey(token))
                return;

            errors.Add(token, message);
        }
コード例 #2
0
ファイル: EngineException.cs プロジェクト: jonathanm/CodeBox
 public EngineException(ExceptionType type, string message, Token token)
 {
     Type = type;
     Message = message;
     Token = token;
     Line = token.Line;
     Position = token.Position;
 }
コード例 #3
0
ファイル: EngineException.cs プロジェクト: jonathanm/CodeBox
 public EngineException(ExceptionType type, string message)
 {
     Type = type;
     Message = message;
     Token = new Token(TokenType.IDENTIFIER, "", null);
     Line = (GetCurrentLine == null) ? 0 : GetCurrentLine();
     Position = 0;
 }
コード例 #4
0
ファイル: TokenChars.cs プロジェクト: anaimi/codebox
        public TokenChars(Token token)
        {
            Token = token;
            Characters = GetCharsByIndices(token.Indices);

            foreach (var c in Characters)
            {
                c.ParentToken = token;
            }
        }
コード例 #5
0
ファイル: AutoComplete.cs プロジェクト: anaimi/codebox
        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;
        }
コード例 #6
0
ファイル: AutoComplete.cs プロジェクト: anaimi/codebox
 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("<");
 }
コード例 #7
0
ファイル: AutoComplete.cs プロジェクト: anaimi/codebox
        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;
        }
コード例 #8
0
ファイル: AutoComplete.cs プロジェクト: anaimi/codebox
        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;
        }
コード例 #9
0
ファイル: TokenList.cs プロジェクト: anaimi/codebox
        public void GotoToken(Token token)
        {
            currentTokenIndex = tokens.IndexOf(token);

            if (currentTokenIndex == -1)
                currentTokenIndex = 0;
        }
コード例 #10
0
ファイル: Token.cs プロジェクト: anaimi/codebox
        public bool FallsBefore(List<Token> list, Token target)
        {
            int selfIndex = Index(list);
            int targetIndex = list.IndexOf(target);

            if (selfIndex < targetIndex)
                return true;

            return false;
        }
コード例 #11
0
ファイル: TokenChars.cs プロジェクト: jonathanm/CodeBox
        public static TokenChars GetTokenCharsByToken(this List<TokenChars> tcList, Token t)
        {
            foreach (var tc in tcList)
            {
                if (tc.Token == t)
                    return tc;
            }

            return null;
        }