[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevplatform/language/duchain
From: David Nolden <david.nolden.kde () art-master ! de>
Date: 2008-10-31 23:04:23
Message-ID: 1225494263.052751.15564.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 878333 by zwabel:
- Make the inheriter-computation respect when there is multiple parsed versions of \
the same class.
- Move some useful functions to DUChainUtils
M +38 -0 duchainutils.cpp
M +9 -1 duchainutils.h
M +3 -28 navigation/abstractdeclarationnavigationcontext.cpp
--- trunk/KDE/kdevplatform/language/duchain/duchainutils.cpp #878332:878333
@@ -39,6 +39,7 @@
#include "classmemberdeclaration.h"
#include "functiondefinition.h"
#include "specializationstore.h"
+#include "persistentsymboltable.h"
using namespace KDevelop;
using namespace KTextEditor;
@@ -374,3 +375,40 @@
}
return 0;
}
+
+///For a class, returns all classes that inherit it
+QList<Declaration*> DUChainUtils::getInheriters(const Declaration* decl, bool \
collectVersions) +{
+ QList<Declaration*> ret;
+
+ if(decl->internalContext() && decl->internalContext()->type() == DUContext::Class)
+ foreach(DUContext* importer, decl->internalContext()->importers())
+ if(importer->type() == DUContext::Class && importer->owner())
+ ret << importer->owner();
+
+ if(collectVersions && decl->inSymbolTable()) {
+ uint count;
+ const IndexedDeclaration* allDeclarations;
+ PersistentSymbolTable::self().declarations(decl->qualifiedIdentifier(), count, \
allDeclarations); + for(int a = 0; a < count; ++a) {
+ if(allDeclarations[a].data() && allDeclarations[a].data() != decl) {
+ ret += getInheriters(allDeclarations[a].data(), false);
+ }
+ }
+ }
+
+ return ret;
+}
+
+QList<Declaration*> DUChainUtils::getOverriders(const Declaration* currentClass, \
const Declaration* overriddenDeclaration) { + QList<Declaration*> ret;
+
+ if(currentClass != overriddenDeclaration->context()->owner() && \
currentClass->internalContext()) + ret += \
currentClass->internalContext()->findLocalDeclarations(overriddenDeclaration->identifier(), \
SimpleCursor::invalid(), currentClass->topContext(), \
overriddenDeclaration->abstractType()); +
+ foreach(Declaration* inheriter, getInheriters(currentClass))
+ ret += getOverriders(inheriter, overriddenDeclaration);
+
+ return ret;
+}
+
--- trunk/KDE/kdevplatform/language/duchain/duchainutils.h #878332:878333
@@ -38,6 +38,7 @@
class SimpleCursor;
class HashedString;
class TopDUContext;
+class IndexedDUContext;
/**
* A namespace which contains convenience utilities for navigating definition-use \
chains. @@ -70,7 +71,14 @@
KDEVPLATFORMLANGUAGE_EXPORT void collectItems( DUContext* context, \
DUChainItemFilter& filter );
KDEVPLATFORMLANGUAGE_EXPORT DUContext* getArgumentContext(Declaration* decl);
-
+
+ ///If the given declaration is a class, this gets all classes that inherit this \
one + ///@param collectVersions If this is true, the persistent symbol table is used \
to first find all registered + /// versions of this class, and \
then get the inheriters from them all together. This is neded for C++. + \
KDEVPLATFORMLANGUAGE_EXPORT QList<Declaration*> getInheriters(const Declaration* \
decl, bool collectVersions = true); +
+ ///Gets all functions that override the function @param overriddenDeclaration, \
starting the search at @param currentClass + KDEVPLATFORMLANGUAGE_EXPORT \
QList<Declaration*> getOverriders(const Declaration* currentClass, const Declaration* \
overriddenDeclaration); }
}
--- trunk/KDE/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp \
#878332:878333 @@ -34,6 +34,7 @@
#include "../types/pointertype.h"
#include "../types/referencetype.h"
#include "../types/typeutils.h"
+#include "../persistentsymboltable.h"
namespace KDevelop {
AbstractDeclarationNavigationContext::AbstractDeclarationNavigationContext( \
DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, \
AbstractNavigationContext* previousContext) @@ -267,32 +268,6 @@
m_currentText += "<br />";
}
-///For a class, returns all classes that inherit it
-///@todo Respect different parsed versions of headers here. The same class may have \
multiple Declarations.
-QList<Declaration*> getInheriters(const Declaration* decl)
-{
- QList<Declaration*> ret;
-
- if(decl->internalContext() && decl->internalContext()->type() == DUContext::Class)
- foreach(DUContext* importer, decl->internalContext()->importers())
- if(importer->type() == DUContext::Class && importer->owner())
- ret << importer->owner();
-
- return ret;
-}
-
-QList<Declaration*> getOverriders(const Declaration* currentClass, const \
Declaration* overriddenDeclaration) {
- QList<Declaration*> ret;
-
- if(currentClass != overriddenDeclaration->context()->owner() && \
currentClass->internalContext())
- ret += currentClass->internalContext()->findLocalDeclarations(overriddenDeclaration->identifier(), \
SimpleCursor::invalid(), currentClass->topContext(), \
overriddenDeclaration->abstractType());
-
- foreach(Declaration* inheriter, getInheriters(currentClass))
- ret += getOverriders(inheriter, overriddenDeclaration);
-
- return ret;
-}
-
void AbstractDeclarationNavigationContext::htmlAdditionalNavigation()
{
///Check if the function overrides or hides another one
@@ -338,7 +313,7 @@
if(classFunDecl->isVirtual()) {
Declaration* classDecl = m_declaration->context()->owner();
if(classDecl) {
- QList<Declaration*> overriders = getOverriders(classDecl, classFunDecl);
+ QList<Declaration*> overriders = DUChainUtils::getOverriders(classDecl, \
classFunDecl);
if(!overriders.isEmpty()) {
m_currentText += i18n("Overridden in") + " ";
@@ -358,7 +333,7 @@
}
///Show all classes that inherit this one
- QList<Declaration*> inheriters = getInheriters(m_declaration.data());
+ QList<Declaration*> inheriters = \
DUChainUtils::getInheriters(m_declaration.data()); if(!inheriters.isEmpty()) {
m_currentText += i18n("Inherited by") + " ";
bool first = true;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic