================ @@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer { std::shared_ptr<GlobalCodeCompletionAllocator> CCAllocator; CodeCompletionTUInfo CCTUInfo; std::vector<std::string> &Results; + ReplCodeCompleter &CC; +}; + +/* + The abstract class CompletionContextHandler contains four interfaces, each of + which handles one type of completion result. + + Its substract classes are used to create concrete handlers based on + CodeCompletionContext. + */ +class CompletionContextHandler { +protected: + CodeCompletionContext CCC; + std::vector<std::string> &Results; + +public: + CompletionContextHandler(CodeCompletionContext CCC, + std::vector<std::string> &Results) + : CCC(CCC), Results(Results) {} + + // convert a Declaration completion result to a completion string, and then store it in Results. + virtual void handleDeclaration(const CodeCompletionResult &Result) {} + + // convert a Keyword completion result to a completion string, and then store it in Results. + virtual void handleKeyword(const CodeCompletionResult &Result) {} + + // convert a Pattern completion result to a completion string, and then store it in Results. + virtual void handlePattern(const CodeCompletionResult &Result) {} + + // convert a Macro completion result to a completion string, and then store it in Results. + virtual void handleMacro(const CodeCompletionResult &Result) {} +}; + +class DotMemberAccessHandler : public CompletionContextHandler { ---------------- vgvassilev wrote:
Maybe we can add some documentation here explaining what we do on a high-level as it seems the main part of this PR. https://github.com/llvm/llvm-project/pull/67349 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits