2017-05-21 19:51:15 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "language_server_api.h"
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <mutex>
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
|
|
struct GroupMatch;
|
|
|
|
struct Project;
|
|
|
|
|
2017-05-27 04:21:00 +00:00
|
|
|
struct IncludeComplete {
|
|
|
|
IncludeComplete(Config* config, Project* project);
|
2017-05-21 19:51:15 +00:00
|
|
|
|
|
|
|
// Starts scanning directories. Clears existing cache.
|
|
|
|
void Rescan();
|
|
|
|
|
|
|
|
// Ensures the one-off file is inside |completion_items|.
|
2017-05-23 07:24:14 +00:00
|
|
|
void AddFile(const std::string& absolute_path);
|
2017-05-21 19:51:15 +00:00
|
|
|
|
|
|
|
// Scans the given directory and inserts all includes from this. This is a
|
|
|
|
// blocking function and should be run off the querydb thread.
|
2017-05-23 07:24:14 +00:00
|
|
|
void InsertIncludesFromDirectory(std::string directory, bool use_angle_brackets);
|
2017-05-21 19:51:15 +00:00
|
|
|
void InsertStlIncludes();
|
|
|
|
|
2017-05-29 23:57:19 +00:00
|
|
|
optional<lsCompletionItem> FindCompletionItemForAbsolutePath(const std::string& absolute_path);
|
|
|
|
|
2017-05-21 19:51:15 +00:00
|
|
|
// Guards |completion_items| when |is_scanning| is true.
|
|
|
|
std::mutex completion_items_mutex;
|
|
|
|
std::atomic<bool> is_scanning;
|
2017-05-23 07:24:14 +00:00
|
|
|
std::vector<lsCompletionItem> completion_items;
|
2017-05-29 23:57:19 +00:00
|
|
|
|
|
|
|
// Absolute file path to the completion item in |completion_items|. Also
|
|
|
|
// verifies that we only have one completion item per absolute path.
|
|
|
|
// We cannot just scan |completion_items| for this information because the
|
|
|
|
// same path can often be epxressed in mutliple ways; a trivial example is
|
|
|
|
// angle vs quote include style (ie, <foo> vs "foo").
|
|
|
|
std::unordered_map<std::string, int> absolute_path_to_completion_item;
|
2017-05-21 19:51:15 +00:00
|
|
|
|
|
|
|
// Cached references
|
|
|
|
Config* config_;
|
|
|
|
Project* project_;
|
|
|
|
std::unique_ptr<GroupMatch> match_;
|
|
|
|
};
|
|
|
|
|