Commit afcb9283 authored by Christian Stenger's avatar Christian Stenger
Browse files

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: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent c405a4bc
......@@ -68,11 +68,19 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
if (const auto func = type->asFunctionType()) {
if (func->isSlot() && member->isPrivate()) {
const QString name = o.prettyName(func->name());
// TODO use definition of function instead of declaration!
TestCodeLocationAndType locationAndType;
locationAndType.m_fileName = QLatin1String(member->fileName());
locationAndType.m_line = member->line();
locationAndType.m_column = member->column() - 1;
CPlusPlus::Function *functionDefinition = m_symbolFinder.findMatchingDefinition(
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))
locationAndType.m_type = TestTreeItem::TEST_SPECIALFUNCTION;
else if (name.endsWith(QLatin1String("_data")))
......
......@@ -27,6 +27,8 @@
#include <cplusplus/Scope.h>
#include <cplusplus/SymbolVisitor.h>
#include <cpptools/symbolfinder.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmljsdocument.h>
......@@ -47,6 +49,7 @@ public:
bool visit(CPlusPlus::Class *symbol);
private:
CppTools::SymbolFinder m_symbolFinder;
QString m_className;
QMap<QString, TestCodeLocationAndType> m_privSlots;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment