mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 16:45:07 +00:00
44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
|
#include "language_server_api.h"
|
||
|
#include "libclangmm/CompletionString.h"
|
||
|
#include "libclangmm/Index.h"
|
||
|
#include "libclangmm/TranslationUnit.h"
|
||
|
#include "project.h"
|
||
|
#include "working_files.h"
|
||
|
|
||
|
#include <clang-c/Index.h>
|
||
|
|
||
|
struct CompletionSession {
|
||
|
CompilationEntry file;
|
||
|
|
||
|
// The active translation unit.
|
||
|
std::unique_ptr<clang::TranslationUnit> active;
|
||
|
std::unique_ptr<clang::Index> active_index;
|
||
|
|
||
|
// Updated translation unit. If |is_updated_ready| is true, then |updated|
|
||
|
// contains more recent state than |active| and the two should be swapped.
|
||
|
// TODO: implement this. Needs changes in Refresh and CodeComplete.
|
||
|
//bool is_updated_ready = false;
|
||
|
//std::unique_ptr<clang::TranslationUnit> updated;
|
||
|
//std::unique_ptr<clang::Index> updated_index;
|
||
|
|
||
|
CompletionSession(const CompilationEntry& file, WorkingFiles* working_files);
|
||
|
~CompletionSession();
|
||
|
|
||
|
// Refresh file index.
|
||
|
void Refresh(WorkingFiles* working_files);
|
||
|
};
|
||
|
|
||
|
struct CompletionManager {
|
||
|
std::vector<std::unique_ptr<CompletionSession>> sessions;
|
||
|
Project* project;
|
||
|
WorkingFiles* working_files;
|
||
|
|
||
|
CompletionManager(Project* project, WorkingFiles* working_files);
|
||
|
|
||
|
// This all should run on complete_responder thread. This will internally run a child thread to
|
||
|
// reparse.
|
||
|
NonElidedVector<lsCompletionItem> CodeComplete(const lsTextDocumentPositionParams& completion_location);
|
||
|
|
||
|
private:
|
||
|
CompletionSession* GetOrOpenSession(const std::string& filename);
|
||
|
};
|