forked from qt-creator/qt-creator
CppEditor: Fix looking up containing function for search result
- Move look-up to CplusPlus::FindUsages, where we are guaranteed that
we actually have the document source.
- Use the same straightforward algorithm as with clangd.
- Undo the changes to CppDocument::functionAt(), which broke
the autotest.
Amends 6f7e7980d2.
Change-Id: I008d05ba41a3b63b71e3131d7021e0d4e7d0641f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -42,11 +42,14 @@ public:
|
||||
enum class Type { Declaration, Initialization, Read, Write, WritableRef, Other };
|
||||
|
||||
Usage() = default;
|
||||
Usage(const Utils::FilePath &path, const QString &lineText, Type t, int line, int col, int len)
|
||||
: path(path), lineText(lineText), type(t), line(line), col(col), len(len) {}
|
||||
Usage(const Utils::FilePath &path, const QString &lineText, const QString &func, Type t,
|
||||
int line, int col, int len)
|
||||
: path(path), lineText(lineText), containingFunction(func), type(t),
|
||||
line(line), col(col), len(len) {}
|
||||
|
||||
Utils::FilePath path;
|
||||
QString lineText;
|
||||
QString containingFunction;
|
||||
Type type = Type::Other;
|
||||
int line = 0;
|
||||
int col = 0;
|
||||
@@ -75,6 +78,7 @@ protected:
|
||||
void reportResult(unsigned tokenIndex, const Name *name, Scope *scope = nullptr);
|
||||
void reportResult(unsigned tokenIndex, const QList<LookupItem> &candidates);
|
||||
Usage::Type getType(int line, int column, int tokenIndex);
|
||||
QString getContainingFunction(int line, int column);
|
||||
|
||||
bool checkCandidates(const QList<LookupItem> &candidates) const;
|
||||
void checkExpression(unsigned startToken, unsigned endToken, Scope *scope = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user