Clang: Use current TranslationUnit follow symbol based on clang code model

It might be quite a safe replacement which can fix builtin
code model issues.

If clang code model fails to follow symbol or does not find
a definition when it's required we fall back to the built-in
code model to proceed with project-wide follow symbol.

To make it almost a full replacement tweak include paths underline
on cursor hover to match what we have in built-in code model.

SIGNAL/SLOTS macros are not yet supported but can be handled
in follow up patch.

Task-number: QTCREATORBUG-19477
Change-Id: Id1611511d661a8aaf3e93502b4e03e1792c7c1d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-01-05 10:50:37 +01:00
parent 388713df12
commit 7b2774dea1
5 changed files with 79 additions and 25 deletions

View File

@@ -64,12 +64,6 @@ using namespace ClangCodeModel::Internal;
static ModelManagerSupportClang *m_instance = 0;
static bool useClangFollowSymbol()
{
static bool use = qEnvironmentVariableIntValue("QTC_CLANG_FOLLOW_SYMBOL");
return use;
}
static CppTools::CppModelManager *cppModelManager()
{
return CppTools::CppModelManager::instance();
@@ -77,16 +71,12 @@ static CppTools::CppModelManager *cppModelManager()
ModelManagerSupportClang::ModelManagerSupportClang()
: m_completionAssistProvider(m_communicator)
, m_followSymbol(new ClangFollowSymbol)
, m_refactoringEngine(new RefactoringEngine)
{
QTC_CHECK(!m_instance);
m_instance = this;
if (useClangFollowSymbol())
m_followSymbol.reset(new ClangFollowSymbol);
else
m_followSymbol.reset(new CppTools::FollowSymbolUnderCursor);
CppTools::CppModelManager::instance()->setCurrentDocumentFilter(
std::make_unique<ClangCurrentDocumentFilter>());