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>
This commit is contained in:
Ivan Donchevskii
2017-07-27 13:20:22 +02:00
parent c6ff65fd65
commit 32d38789f9
10 changed files with 418 additions and 21 deletions

View File

@@ -27,12 +27,8 @@
#include <clangbackendipc/codecompletion.h>
#include <utf8string.h>
#include <clang-c/Index.h>
class Utf8String;
namespace ClangBackEnd {
class Cursor;
@@ -41,6 +37,7 @@ class DiagnosticSet;
class HighlightingMarkContainer;
class HighlightingMarks;
class ReferencesResult;
class FollowSymbolResult;
class SkippedSourceRanges;
class SourceLocation;
class SourceRange;
@@ -48,6 +45,7 @@ class SourceRangeContainer;
class TranslationUnitUpdateInput;
class TranslationUnitUpdateResult;
class UnsavedFiles;
class CommandLineArguments;
class TranslationUnit
{
@@ -102,6 +100,10 @@ public:
HighlightingMarks highlightingMarksInRange(const SourceRange &range) const;
SkippedSourceRanges skippedSourceRanges() const;
FollowSymbolResult followSymbol(uint line,
uint column,
const QVector<Utf8String> &dependentFiles,
const CommandLineArguments &currentArgs) const;
private:
const Utf8String m_id;