[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdev-ruby/gsoc] duchain/declarations: Cleaning the declaration classes
From: Miquel_Sabaté <mikisabate () gmail ! com>
Date: 2012-05-31 19:29:56
Message-ID: 20120531192956.A4C0CA60CE () git ! kde ! org
[Download RAW message or body]
Git commit 9268b89ab287c51556ee64b4339e1b6e2a962a27 by Miquel Sabaté.
Committed on 31/05/2012 at 21:21.
Pushed by mssola into branch 'gsoc'.
Cleaning the declaration classes
M +2 -39 duchain/declarations/classdeclaration.cpp
M +16 -2 duchain/declarations/classdeclaration.h
M +1 -1 duchain/declarations/methoddeclaration.h
M +0 -5 duchain/declarations/moduledeclaration.cpp
M +42 -5 duchain/declarations/moduledeclaration.h
http://commits.kde.org/kdev-ruby/9268b89ab287c51556ee64b4339e1b6e2a962a27
diff --git a/duchain/declarations/classdeclaration.cpp b/duchain/declarations/classdeclaration.cpp
index e4ed906..ce00c32 100644
--- a/duchain/declarations/classdeclaration.cpp
+++ b/duchain/declarations/classdeclaration.cpp
@@ -19,21 +19,15 @@
#include <duchain/declarations/classdeclaration.h>
-#include <language/duchain/identifier.h>
-#include <language/duchain/declaration.h>
-#include <language/duchain/appendedlist.h>
-#include <language/duchain/duchainregister.h>
namespace Ruby
{
-// REGISTER_DUCHAIN_ITEM(ClassDeclaration);
-
-
ClassDeclaration::ClassDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *ctx)
: ModuleDeclaration(range, ctx)
{
+ /* There's nothing to do here */
}
ClassDeclaration::ClassDeclaration(const ClassDeclaration &rhs)
@@ -45,7 +39,7 @@ ClassDeclaration::ClassDeclaration(const ClassDeclaration &rhs)
ClassDeclaration::ClassDeclaration(ModuleDeclarationData &data)
: ModuleDeclaration(data)
{
-
+ /* There's nothing to do here */
}
void ClassDeclaration::setBaseClass(KDevelop::IndexedType base)
@@ -67,37 +61,6 @@ KDevelop::Declaration * ClassDeclaration::clonePrivate() const
{
return new ClassDeclaration(*this);
}
-/*
-QString ClassDeclaration::toString() const
-{
- return "class " + identifier().toString();
-}*/
-/*
-void ClassDeclaration::clearModuleMixins()
-{
- bool wasInSymbolTable = inSymbolTable();
- setInSymbolTable(false);
- d_func_dynamic()->moduleMixinsList().clear();
- setInSymbolTable(wasInSymbolTable);
-}
-
-uint ClassDeclaration::moduleMixinsSize()
-{
- return d_func()->moduleMixinsSize();
-}
-
-const ModuleMixin * ClassDeclaration::moduleMixins() const
-{
- return d_func()->moduleMixins();
-}
-
-void ClassDeclaration::addModuleMixin(ModuleMixin module)
-{
- bool wasInSymbolTable = inSymbolTable();
- setInSymbolTable(false);
- d_func_dynamic()->moduleMixinsList().append(module);
- setInSymbolTable(wasInSymbolTable);
-}*/
} // End of namespace Ruby
diff --git a/duchain/declarations/classdeclaration.h b/duchain/declarations/classdeclaration.h
index ab79def..7714693 100644
--- a/duchain/declarations/classdeclaration.h
+++ b/duchain/declarations/classdeclaration.h
@@ -22,13 +22,20 @@
#define RUBY_CLASSDECLARATION_H
-#include "moduledeclaration.h"
#include <duchain/duchainexport.h>
+#include <duchain/declarations/moduledeclaration.h>
namespace Ruby
{
+/**
+ * @class ClassDeclaration
+ *
+ * This is class represents a class declaration. It's a subclass of the
+ * ModuleDeclaration. This way, it has access of the moduleMixins list from
+ * the ModuleDeclaration class.
+ */
class KDEVRUBYDUCHAIN_EXPORT ClassDeclaration : public ModuleDeclaration
{
public:
@@ -48,14 +55,22 @@ public:
*/
ClassDeclaration(ModuleDeclarationData &data);
+ /// Set the type @p base as the new base class for this class declaration.
void setBaseClass(KDevelop::IndexedType base);
+
+ /// Invalidate the current base class.
void clearBaseClass();
+
+ /// @returns the base class for this class declaration.
KDevelop::IndexedType baseClass() const;
enum { Identity = 46 /** The id of this Type. */ };
private:
+ /// Re-implemented from KDevelop::Declaration.
virtual KDevelop::Declaration * clonePrivate() const;
+
+private:
KDevelop::IndexedType m_baseClass;
};
@@ -63,4 +78,3 @@ private:
#endif // RUBY_CLASSDECLARATION_H
-
diff --git a/duchain/declarations/methoddeclaration.h b/duchain/declarations/methoddeclaration.h
index 65cc34f..ca6801c 100644
--- a/duchain/declarations/methoddeclaration.h
+++ b/duchain/declarations/methoddeclaration.h
@@ -22,8 +22,8 @@
#define R_METHOD_DECLARATION_H
-#include <language/duchain/functiondeclaration.h>
#include <duchain/duchainexport.h>
+#include <language/duchain/functiondeclaration.h>
namespace Ruby
diff --git a/duchain/declarations/moduledeclaration.cpp b/duchain/declarations/moduledeclaration.cpp
index 029b8b5..53ef8c1 100644
--- a/duchain/declarations/moduledeclaration.cpp
+++ b/duchain/declarations/moduledeclaration.cpp
@@ -53,11 +53,6 @@ ModuleDeclaration::ModuleDeclaration(const KDevelop::RangeInRevision &range, KDe
setContext(context);
}
-ModuleDeclaration::~ModuleDeclaration()
-{
-
-}
-
void ModuleDeclaration::clearModuleMixins()
{
bool wasInSymbolTable = inSymbolTable();
diff --git a/duchain/declarations/moduledeclaration.h b/duchain/declarations/moduledeclaration.h
index e58037a..865e04e 100644
--- a/duchain/declarations/moduledeclaration.h
+++ b/duchain/declarations/moduledeclaration.h
@@ -31,6 +31,7 @@
namespace Ruby
{
+/// Struct used in the appended list in the MethodDeclarationData.
struct KDEVRUBYDUCHAIN_EXPORT ModuleMixin {
KDevelop::IndexedType module;
bool included;
@@ -38,20 +39,30 @@ struct KDEVRUBYDUCHAIN_EXPORT ModuleMixin {
KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(ModuleDeclarationData, moduleMixins, ModuleMixin)
+/**
+ * @class ModuleDeclarationData
+ *
+ * Private data structure for ModuleDeclaration. It contains an appended list
+ * of module mix-ins.
+ */
class KDEVRUBYDUCHAIN_EXPORT ModuleDeclarationData : public KDevelop::DeclarationData
{
public:
+ /// Constructor.
ModuleDeclarationData()
{
initializeAppendedLists();
}
- ModuleDeclarationData(const ModuleDeclarationData &rhs) : KDevelop::DeclarationData(rhs)
+ /// Copy constructor.
+ ModuleDeclarationData(const ModuleDeclarationData &rhs)
+ : KDevelop::DeclarationData(rhs)
{
initializeAppendedLists();
copyListsFrom(rhs);
}
+ /// Destructor.
~ModuleDeclarationData()
{
freeAppendedLists();
@@ -62,25 +73,51 @@ public:
END_APPENDED_LISTS(ModuleDeclarationData, moduleMixins);
};
-
+/**
+ * @class ModuleDeclaration
+ *
+ * This class represents a module declaration. It defines methods to access to
+ * the list of module mixins.
+ */
class KDEVRUBYDUCHAIN_EXPORT ModuleDeclaration : public KDevelop::Declaration
{
public:
+ /**
+ * Constructor.
+ * @param range The range of this declaration.
+ * @param ctx The context of this declaration.
+ */
+ ModuleDeclaration(const KDevelop::RangeInRevision &range,
+ KDevelop::DUContext *context);
+
+ /// Copy constructor.
ModuleDeclaration(const ModuleDeclaration &rhs);
+
+ /**
+ * Copy constructor.
+ * @param data The data to be copied.
+ */
ModuleDeclaration(ModuleDeclarationData &data);
- ModuleDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *context);
- ~ModuleDeclaration();
+ /// Clean the list of module mix-ins.
void clearModuleMixins();
+
+ /// @returns the size of the list of module mix-ins.
uint moduleMixinsSize();
+
+ /// @returns the list of module mix-ins.
const ModuleMixin * moduleMixins() const;
+
+ /// Add a new module mix-in @p module to the list.
void addModuleMixin(ModuleMixin module);
+ /// Re-implemented from KDevelop::Declaration.
QString toString() const;
- enum { Identity = 44 };
+ enum { Identity = 44 /** The id of this Type. */ };
private:
+ /// Re-implemented from KDevelop::Declaration.
virtual KDevelop::Declaration * clonePrivate() const;
DUCHAIN_DECLARE_DATA(ModuleDeclaration)
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic