forked from qt-creator/qt-creator
Rework the parsing and fixing detection of changes
Additionally * fixed some deletion of pointers * const correctness * small refactorings for readability * better separation of responsibilities
This commit is contained in:
committed by
Christian Stenger
parent
eca8e2faba
commit
345b4de47a
@@ -18,9 +18,13 @@
|
||||
|
||||
#include "testvisitor.h"
|
||||
|
||||
#include <cplusplus/FullySpecifiedType.h>
|
||||
#include <cplusplus/LookupContext.h>
|
||||
#include <cplusplus/Overview.h>
|
||||
#include <cplusplus/Symbols.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
|
||||
#include <QList>
|
||||
|
||||
@@ -57,7 +61,7 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
|
||||
|
||||
if (auto func = type->asFunctionType()) {
|
||||
if (func->isSlot() && member->isPrivate()) {
|
||||
QString name = o.prettyName(func->name());
|
||||
const QString name = o.prettyName(func->name());
|
||||
if (!ignoredFunctions.contains(name) && !name.endsWith(QLatin1String("_data"))) {
|
||||
TestCodeLocation location;
|
||||
location.m_fileName = QLatin1String(member->fileName());
|
||||
@@ -71,5 +75,54 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
|
||||
return true;
|
||||
}
|
||||
|
||||
TestAstVisitor::TestAstVisitor(CPlusPlus::Document::Ptr doc)
|
||||
: ASTVisitor(doc->translationUnit()),
|
||||
m_currentDoc(doc)
|
||||
{
|
||||
}
|
||||
|
||||
TestAstVisitor::~TestAstVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
bool TestAstVisitor::visit(CPlusPlus::CallAST *ast)
|
||||
{
|
||||
if (!m_currentScope || m_currentDoc.isNull())
|
||||
return false;
|
||||
|
||||
if (auto expressionAST = ast->base_expression) {
|
||||
if (auto idExpressionAST = expressionAST->asIdExpression()) {
|
||||
if (auto qualifiedNameAST = idExpressionAST->name->asQualifiedName()) {
|
||||
const CPlusPlus::Overview o;
|
||||
const QString prettyName = o.prettyName(qualifiedNameAST->name);
|
||||
if (prettyName == QLatin1String("QTest::qExec")) {
|
||||
if (auto expressionListAST = ast->expression_list) {
|
||||
// first argument is the one we need
|
||||
if (auto argumentExpressionAST = expressionListAST->value) {
|
||||
CPlusPlus::TypeOfExpression toe;
|
||||
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
|
||||
toe.init(m_currentDoc, cppMM->snapshot());
|
||||
QList<CPlusPlus::LookupItem> toeItems
|
||||
= toe(argumentExpressionAST, m_currentDoc, m_currentScope);
|
||||
|
||||
if (toeItems.size()) {
|
||||
if (auto pointerType = toeItems.first().type()->asPointerType())
|
||||
m_className = o.prettyType(pointerType->elementType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TestAstVisitor::visit(CPlusPlus::CompoundStatementAST *ast)
|
||||
{
|
||||
m_currentScope = ast->symbol->asScope();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
Reference in New Issue
Block a user