aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2017-07-27 13:20:22 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2017-08-18 12:09:51 +0000
commit32d38789f9bb322ef9510cf79c1ce0de017e07b6 (patch)
treecfbfeb42e918abc1210d3dc8f54070af05a390eb /src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp
parentc6ff65fd65790a6a3a93472efff1f71d26854ef6 (diff)
Clang: implement followSymbol in TranslationUnit
Follow symbol in current TU or dependent files Current algorithm tries to do the same as built-in follow symbol but better. Currently clang-based follow symbol has some limitations: - following function usage may return the declaration instead of definition because we don't have header dependencies in backend - overrides are not searched because of the same reason and the amount of dependent files (parsing 250 files takes a while) - some includes are not handled correctly, in that case we return failure and ask built-in code model to follow (example: <QtGui> or other qt includes) Change-Id: If35028ee0b5e818fdba29363c9520c5cca996348 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp')
-rw-r--r--src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp b/src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp
index 813f6f839ff..ffac66b65fd 100644
--- a/src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp
+++ b/src/tools/clangbackend/ipcsource/clangfollowsymboljob.cpp
@@ -37,11 +37,11 @@ static FollowSymbolJob::AsyncResult runAsyncHelperFollow(const TranslationUnit &
quint32 line,
quint32 column,
const QVector<Utf8String> &dependentFiles,
- bool resolveTarget)
+ const CommandLineArguments &currentArgs)
{
TIME_SCOPE_DURATION("FollowSymbolJobRunner");
- return FollowSymbolResult();
+ return translationUnit.followSymbol(line, column, dependentFiles, currentArgs);
}
IAsyncJob::AsyncPrepareResult FollowSymbolJob::prepareAsyncRun()
@@ -49,6 +49,8 @@ IAsyncJob::AsyncPrepareResult FollowSymbolJob::prepareAsyncRun()
const JobRequest jobRequest = context().jobRequest;
QTC_ASSERT(jobRequest.type == JobRequest::Type::FollowSymbol,
return AsyncPrepareResult());
+ // Is too slow because of IPC timings, no implementation for now
+ QTC_ASSERT(jobRequest.resolveTarget, return AsyncPrepareResult());
try {
m_pinnedDocument = context().documentForJobRequest();
@@ -56,12 +58,18 @@ IAsyncJob::AsyncPrepareResult FollowSymbolJob::prepareAsyncRun()
const TranslationUnit translationUnit
= m_pinnedDocument.translationUnit(jobRequest.preferredTranslationUnit);
+
+ const TranslationUnitUpdateInput updateInput = m_pinnedDocument.createUpdateInput();
+ const CommandLineArguments currentArgs(updateInput.filePath.constData(),
+ updateInput.projectArguments,
+ updateInput.fileArguments,
+ false);
+
const quint32 line = jobRequest.line;
const quint32 column = jobRequest.column;
const QVector<Utf8String> &dependentFiles = jobRequest.dependentFiles;
- const bool resolveTarget = jobRequest.resolveTarget;
- setRunner([translationUnit, line, column, dependentFiles, resolveTarget]() {
- return runAsyncHelperFollow(translationUnit, line, column, dependentFiles, resolveTarget);
+ setRunner([translationUnit, line, column, dependentFiles, currentArgs]() {
+ return runAsyncHelperFollow(translationUnit, line, column, dependentFiles, currentArgs);
});
return AsyncPrepareResult{translationUnit.id()};
@@ -77,8 +85,8 @@ void FollowSymbolJob::finalizeAsyncRun()
const AsyncResult result = asyncResult();
const FollowSymbolMessage message(m_pinnedFileContainer,
- result.m_range,
- result.m_failedToFollow,
+ result.range,
+ result.failedToFollow,
context().jobRequest.ticketNumber);
context().client->followSymbol(message);
}