From kde-commits Thu Jul 03 13:15:54 2014 From: Kevin Funk Date: Thu, 03 Jul 2014 13:15:54 +0000 To: kde-commits Subject: [kdevplatform] language/duchain: Introduce Definitions::dump Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=140439336716406 Git commit 74bc6a56e2c30a521485d5e0c6f89bc1102900e8 by Kevin Funk. Committed on 03/07/2014 at 13:13. Pushed by kfunk into branch 'master'. Introduce Definitions::dump This reveals another issue in kdev-clang: Function definitions' ids are not fully qualified. Hence FunctionDefinition::definition fails when looking up an identifier in a namespace. M +42 -2 language/duchain/definitions.cpp M +7 -1 language/duchain/definitions.h M +1 -0 language/duchain/duchaindumper.cpp http://commits.kde.org/kdevplatform/74bc6a56e2c30a521485d5e0c6f89bc1102900e8 diff --git a/language/duchain/definitions.cpp b/language/duchain/definition= s.cpp index bea0a18..3888f54 100644 --- a/language/duchain/definitions.cpp +++ b/language/duchain/definitions.cpp @@ -1,5 +1,6 @@ /* This file is part of KDevelop - Copyright 2008 David Nolden + Copyright 2008 David Nolden + Copyright 2014 Kevin Funk = This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -16,11 +17,14 @@ Boston, MA 02110-1301, USA. */ = +#include "appendedlist.h" #include "definitions.h" +#include "declaration.h" #include "declarationid.h" #include "duchainpointer.h" -#include "appendedlist.h" +#include "indexedstring.h" #include "repositories/itemrepository.h" + #include #include = @@ -99,6 +103,35 @@ class DefinitionsRequestItem { const DefinitionsItem& m_item; }; = +class DefinitionsVisitor +{ +public: + DefinitionsVisitor(Definitions* _definitions, const QTextStream& _out) + : definitions(_definitions) + , out(_out) + { + } + + bool operator()(const DefinitionsItem* item) + { + QDebug qout(out.device()); + auto id =3D item->declaration; + auto allDefinitions =3D definitions->definitions(id); + + qout << "Definitions for" << id.qualifiedIdentifier() << endl; + FOREACH_ARRAY(const IndexedDeclaration& decl, allDefinitions) { + if(decl.data()) { + qout << " " << decl.data()->qualifiedIdentifier() << "in" << decl.= data()->url().byteArray() << "at" << decl.data()->rangeInCurrentRevision() = << endl; + } + } + + return true; + } + +private: + const Definitions* definitions; + const QTextStream& out; +}; = class DefinitionsPrivate { @@ -187,5 +220,12 @@ KDevVarLengthArray Definitions::de= finitions(const Declaratio return ret; } = +void Definitions::dump(const QTextStream& out) +{ + QMutexLocker lock(d->m_definitions.mutex()); + DefinitionsVisitor v(this, out); + d->m_definitions.visitAllItems(v); +} + } = diff --git a/language/duchain/definitions.h b/language/duchain/definitions.h index a53e82a..35f3090 100644 --- a/language/duchain/definitions.h +++ b/language/duchain/definitions.h @@ -1,5 +1,6 @@ /* This file is part of KDevelop - Copyright 2008 David Nolden + Copyright 2008 David Nolden + Copyright 2014 Kevin Funk = This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -22,6 +23,8 @@ #ifndef KDEVPLATFORM_DEFINITIONS_H #define KDEVPLATFORM_DEFINITIONS_H = +class QTextStream; + namespace KDevelop { = class Declaration; @@ -48,6 +51,9 @@ namespace KDevelop { ///Gets all the known definitions assigned to @param id. KDevVarLengthArray definitions(const DeclarationId= & id) const; = + /// Dump contents of the definitions repository to stream @p out + void dump(const QTextStream& out); + private: class DefinitionsPrivate* d; }; diff --git a/language/duchain/duchaindumper.cpp b/language/duchain/duchaind= umper.cpp index d44c77a..f47939a 100644 --- a/language/duchain/duchaindumper.cpp +++ b/language/duchain/duchaindumper.cpp @@ -26,6 +26,7 @@ = #include = +#include "definitions.h" #include "ducontext.h" #include "topducontext.h" #include "declaration.h"