Esempio n. 1
0
        public SuggestionContext(SuggestionList sug, Token p, int pos, string textEntered)
        {
            suggestions = sug;
            parent      = p;
            suggestions.includeAliases = suggestions.enableAutoSuggestAliases;
            if (suggestions.includeAliases == false && suggestions.enableSuggestAliases)
            {
                CheckForAlias();
            }

            tokens = p.GetTokensWithin();
            Token lastToken = tokens.GetTokenBeforeOrAtRandomOffset(pos);

            if (lastToken != null && lastToken.tokenType == TokenType.Identifier && textEntered.StartsWith(lastToken.name))
            {
                lastToken = lastToken.GetPrevToken();
            }
            if (lastToken != null)
            {
                last            = new SuggestionContextItem(lastToken, true);
                lastKeyword     = InitItem(TokenType.Keyword);
                lastLiteral     = InitItem(TokenType.Literal);
                lastTable       = InitItem(TokenType.Table);
                lastOperator    = InitItem(TokenType.Operator);
                lastConjunction = InitItem(TokenType.Keyword, new[] { "and", "or", "not" });
                lastColumn      = InitItem(TokenType.Column);

                if (lastTable.token != null)
                {
                    if (lastTable.isLast)
                    {
                        lastTable.hasComma = lastTable.token.charAfter == ',';
                    }
                    else
                    {
                        Table t = lastTable.token as Table;
                        if (t.tableAliasToken != null && t.tableAliasToken == last.token)
                        {
                            last = lastTable;
                            lastTable.aliasToken = t.tableAliasToken;
                            lastTable.hasComma   = t.tableAliasToken.charAfter == ',';
                        }
                    }
                }
                if (last.type == "column" && last.token != null && last.token.charAfter == ',')
                {
                    last.hasComma = true;
                }
            }
        }
Esempio n. 2
0
 public bool isBefore(SuggestionContextItem other)
 {
     return(false);
 }