2016-05-13 17:27:54 +08:00
|
|
|
//===-- SymbolIndexManager.h - Managing multiple SymbolIndices --*- C++ -*-===//
|
2016-05-04 16:22:35 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-05-13 17:27:54 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H
|
2016-05-04 16:22:35 +08:00
|
|
|
|
2016-05-13 17:27:54 +08:00
|
|
|
#include "SymbolIndex.h"
|
2016-07-08 17:10:29 +08:00
|
|
|
#include "find-all-symbols/SymbolInfo.h"
|
2016-05-04 16:22:35 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-01-13 18:14:07 +08:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
// Disable warnings from ppltasks.h transitively included by <future>.
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable:4530)
|
|
|
|
#endif
|
|
|
|
|
2017-01-09 23:18:28 +08:00
|
|
|
#include <future>
|
2016-05-04 16:22:35 +08:00
|
|
|
|
2017-01-13 18:14:07 +08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2016-05-04 16:22:35 +08:00
|
|
|
namespace clang {
|
|
|
|
namespace include_fixer {
|
|
|
|
|
|
|
|
/// This class provides an interface for finding the header files corresponding
|
2017-03-30 21:10:33 +08:00
|
|
|
/// to an identifier in the source code from multiple symbol databases.
|
2016-05-13 17:27:54 +08:00
|
|
|
class SymbolIndexManager {
|
2016-05-04 16:22:35 +08:00
|
|
|
public:
|
2017-01-09 23:18:28 +08:00
|
|
|
void addSymbolIndex(std::function<std::unique_ptr<SymbolIndex>()> F) {
|
2017-01-11 15:20:46 +08:00
|
|
|
#if LLVM_ENABLE_THREADS
|
|
|
|
auto Strategy = std::launch::async;
|
|
|
|
#else
|
|
|
|
auto Strategy = std::launch::deferred;
|
|
|
|
#endif
|
|
|
|
SymbolIndices.push_back(std::async(Strategy, F));
|
2016-05-04 16:22:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Search for header files to be included for an identifier.
|
|
|
|
/// \param Identifier The identifier being searched for. May or may not be
|
|
|
|
/// fully qualified.
|
2016-08-02 18:43:10 +08:00
|
|
|
/// \param IsNestedSearch Whether searching nested classes. If true, the
|
|
|
|
/// method tries to strip identifier name parts from the end until it
|
|
|
|
/// finds the corresponding candidates in database (e.g for identifier
|
|
|
|
/// "b::foo", the method will try to find "b" if it fails to find
|
|
|
|
/// "b::foo").
|
|
|
|
///
|
|
|
|
/// \returns A list of symbol candidates.
|
2016-07-08 17:10:29 +08:00
|
|
|
std::vector<find_all_symbols::SymbolInfo>
|
2017-01-11 18:32:47 +08:00
|
|
|
search(llvm::StringRef Identifier, bool IsNestedSearch = true,
|
|
|
|
llvm::StringRef FileName = "") const;
|
2016-05-04 16:22:35 +08:00
|
|
|
|
|
|
|
private:
|
2017-01-09 23:18:28 +08:00
|
|
|
std::vector<std::shared_future<std::unique_ptr<SymbolIndex>>> SymbolIndices;
|
2016-05-04 16:22:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace include_fixer
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif
|