mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-08 09:14:54 +00:00
* Add %h for C header files (the suffix .h is considered a C header, not a C++ header) * Add %hpp for C++ header files * If .ccls exists, it provides full command line for files not specified by compile_commands.json (before, compile_commands.json was ignored) * If the first line of .ccls is %compile_commands.json, it appends flags to compile_commands.json "arguments", instead of overriding. Files not specified by compile_commands.json will not be added to folder.entries, but their command line can be inferred from other files. Also fix `#include <` completion of -I flags for clang < 8
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
/* Copyright 2017-2018 ccls Authors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
==============================================================================*/
|
|
|
|
#pragma once
|
|
|
|
#include "message_handler.hh"
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
|
|
namespace ccls {
|
|
struct GroupMatch;
|
|
struct Project;
|
|
|
|
struct IncludeComplete {
|
|
IncludeComplete(Project *project);
|
|
~IncludeComplete();
|
|
|
|
// Starts scanning directories. Clears existing cache.
|
|
void Rescan();
|
|
|
|
// Ensures the one-off file is inside |completion_items|.
|
|
void AddFile(const std::string &absolute_path);
|
|
|
|
std::optional<ccls::CompletionItem>
|
|
FindCompletionItemForAbsolutePath(const std::string &absolute_path);
|
|
|
|
// Insert item to |completion_items|.
|
|
// Update |absolute_path_to_completion_item| and |inserted_paths|.
|
|
void InsertCompletionItem(const std::string &absolute_path,
|
|
ccls::CompletionItem &&item);
|
|
|
|
// Guards |completion_items| when |is_scanning| is true.
|
|
std::mutex completion_items_mutex;
|
|
std::atomic<bool> is_scanning;
|
|
std::vector<ccls::CompletionItem> completion_items;
|
|
|
|
// Absolute file path to the completion item in |completion_items|.
|
|
// Keep the one with shortest include path.
|
|
std::unordered_map<std::string, int> absolute_path_to_completion_item;
|
|
|
|
// Only one completion item per include path.
|
|
std::unordered_map<std::string, int> inserted_paths;
|
|
|
|
// Cached references
|
|
Project *project_;
|
|
std::unique_ptr<GroupMatch> match_;
|
|
};
|
|
} // namespace ccls
|