#pragma once #include #include #include #include namespace NSQLComplete { using NSQLTranslation::ILexer; using NSQLTranslation::TParsedToken; using NSQLTranslation::TParsedTokenList; struct TCursor { TMaybe PrevTokenIndex = Nothing(); size_t NextTokenIndex = PrevTokenIndex ? *PrevTokenIndex : 0; size_t Position = 0; }; struct TRichParsedToken { const TParsedToken* Base = nullptr; size_t Index = 0; size_t Position = 0; [[nodiscard]] bool IsLiteral() const; [[nodiscard]] size_t End() const; }; struct TCursorTokenContext { TParsedTokenList Tokens; TVector TokenPositions; TCursor Cursor; [[nodiscard]] TMaybe Enclosing() const; [[nodiscard]] TMaybe MatchCursorPrefix(const TVector& pattern) const; }; bool GetStatement( ILexer::TPtr& lexer, const TMaterializedInput& input, TCompletionInput& output, size_t& output_position); bool GetCursorTokenContext( ILexer::TPtr& lexer, TCompletionInput input, TCursorTokenContext& context); } // namespace NSQLComplete