forked from qt-creator/qt-creator
Store location of definition of functions...
...instead of declarations. Declarations will now be used only as fallback if definition cannot be found for some reason. Change-Id: I1b79622e70d2227cd715f3d82b12f36997080a2e Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -68,11 +68,19 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
|
|||||||
if (const auto func = type->asFunctionType()) {
|
if (const auto func = type->asFunctionType()) {
|
||||||
if (func->isSlot() && member->isPrivate()) {
|
if (func->isSlot() && member->isPrivate()) {
|
||||||
const QString name = o.prettyName(func->name());
|
const QString name = o.prettyName(func->name());
|
||||||
// TODO use definition of function instead of declaration!
|
|
||||||
TestCodeLocationAndType locationAndType;
|
TestCodeLocationAndType locationAndType;
|
||||||
locationAndType.m_fileName = QLatin1String(member->fileName());
|
|
||||||
locationAndType.m_line = member->line();
|
CPlusPlus::Function *functionDefinition = m_symbolFinder.findMatchingDefinition(
|
||||||
locationAndType.m_column = member->column() - 1;
|
func, CppTools::CppModelManager::instance()->snapshot(), true);
|
||||||
|
if (functionDefinition) {
|
||||||
|
locationAndType.m_fileName = QString::fromUtf8(functionDefinition->fileName());
|
||||||
|
locationAndType.m_line = functionDefinition->line();
|
||||||
|
locationAndType.m_column = functionDefinition->column() - 1;
|
||||||
|
} else { // if we cannot find the definition use declaration as fallback
|
||||||
|
locationAndType.m_fileName = QString::fromUtf8(member->fileName());
|
||||||
|
locationAndType.m_line = member->line();
|
||||||
|
locationAndType.m_column = member->column() - 1;
|
||||||
|
}
|
||||||
if (specialFunctions.contains(name))
|
if (specialFunctions.contains(name))
|
||||||
locationAndType.m_type = TestTreeItem::TEST_SPECIALFUNCTION;
|
locationAndType.m_type = TestTreeItem::TEST_SPECIALFUNCTION;
|
||||||
else if (name.endsWith(QLatin1String("_data")))
|
else if (name.endsWith(QLatin1String("_data")))
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <cplusplus/Scope.h>
|
#include <cplusplus/Scope.h>
|
||||||
#include <cplusplus/SymbolVisitor.h>
|
#include <cplusplus/SymbolVisitor.h>
|
||||||
|
|
||||||
|
#include <cpptools/symbolfinder.h>
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/qmljsdocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
@@ -47,6 +49,7 @@ public:
|
|||||||
bool visit(CPlusPlus::Class *symbol);
|
bool visit(CPlusPlus::Class *symbol);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CppTools::SymbolFinder m_symbolFinder;
|
||||||
QString m_className;
|
QString m_className;
|
||||||
QMap<QString, TestCodeLocationAndType> m_privSlots;
|
QMap<QString, TestCodeLocationAndType> m_privSlots;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user