[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform] language/duchain: Introduce Definitions::dump
From:       Kevin Funk <kfunk () kde ! org>
Date:       2014-07-03 13:15:54
Message-ID: E1X2gri-0007wJ-MN () scm ! kde ! org
[Download RAW message or body]

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/definitions.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 <david.nolden.kdevelop@art-master.de>
+   Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
+   Copyright 2014 Kevin Funk <kfunk@kde.org>
 
    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 <QHash>
 #include <QVector>
 
@@ -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 = item->declaration;
+    auto allDefinitions = 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<IndexedDeclaration> \
Definitions::definitions(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 <david.nolden.kdevelop@art-master.de>
+   Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
+   Copyright 2014 Kevin Funk <kfunk@kde.org>
 
    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<IndexedDeclaration> 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/duchaindumper.cpp
index d44c77a..f47939a 100644
--- a/language/duchain/duchaindumper.cpp
+++ b/language/duchain/duchaindumper.cpp
@@ -26,6 +26,7 @@
 
 #include <KDebug>
 
+#include "definitions.h"
 #include "ducontext.h"
 #include "topducontext.h"
 #include "declaration.h"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic