[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdev-ruby/gsoc] duchain: Re-implemented the ClassDeclaration class.
From: Miquel_Sabaté <mikisabate () gmail ! com>
Date: 2012-05-31 19:29:56
Message-ID: 20120531192956.827BCA60C4 () git ! kde ! org
[Download RAW message or body]
Git commit 90a0d0e997b3df80e08a31d4f5897eb4737dc2e4 by Miquel Sabaté.
Committed on 31/05/2012 at 14:13.
Pushed by mssola into branch 'gsoc'.
Re-implemented the ClassDeclaration class.
The ClassDeclaration class is now a subclass of the new ModuleDeclaration
class. The reason behind this is that the ClassDeclaration needs to access to
the moduleMixins list too. Furthermore, all the inherited stuff from
KDevelop::ClassDeclaration was not necessary either.
M +2 -8 duchain/builders/declarationbuilder.cpp
M +18 -9 duchain/declarations/classdeclaration.cpp
M +49 -9 duchain/declarations/classdeclaration.h
M +3 -6 duchain/navigation/declarationnavigationcontext.cpp
http://commits.kde.org/kdev-ruby/90a0d0e997b3df80e08a31d4f5897eb4737dc2e4
diff --git a/duchain/builders/declarationbuilder.cpp \
b/duchain/builders/declarationbuilder.cpp index bfd403a..d6a5957 100644
--- a/duchain/builders/declarationbuilder.cpp
+++ b/duchain/builders/declarationbuilder.cpp
@@ -84,8 +84,7 @@ void DeclarationBuilder::visitClassStatement(RubyAst *node)
setComment(getComment(node));
ClassDeclaration *decl = openDeclaration<ClassDeclaration>(id, range);
decl->setKind(KDevelop::Declaration::Type);
- decl->clearBaseClasses();
- decl->setClassType(ClassDeclarationData::Class);
+ decl->clearBaseClass();
m_accessPolicyStack.push(Declaration::Public);
lastClassModule = decl;
insideClassModule = true;
@@ -108,11 +107,7 @@ void DeclarationBuilder::visitClassStatement(RubyAst *node)
appendProblem(node->tree, i18n("TypeError: wrong argument type \
(expected Class)")); else {
currentContext()->addImportedParentContext(realClass->internalContext());
- BaseClassInstance base;
- base.baseClass = realClass->indexedType();
- base.access = KDevelop::Declaration::Public;
- base.virtualInheritance = false;
- decl->addBaseClass(base);
+ decl->setBaseClass(realClass->indexedType());
}
}
}
@@ -432,7 +427,6 @@ void DeclarationBuilder::visitInclude(RubyAst *node)
// Register module mix-in
if (lastClassModule) {
ModuleDeclaration *current = dynamic_cast<ModuleDeclaration \
*>(lastClassModule);
- // TODO: accept classes
if (current) {
ModuleMixin mixin;
mixin.included = true;
diff --git a/duchain/declarations/classdeclaration.cpp \
b/duchain/declarations/classdeclaration.cpp index dd4c997..d8beb58 100644
--- a/duchain/declarations/classdeclaration.cpp
+++ b/duchain/declarations/classdeclaration.cpp
@@ -18,34 +18,43 @@
*/
-#include "classdeclaration.h"
+#include <duchain/declarations/classdeclaration.h>
namespace Ruby
{
-RubyClassDeclaration::RubyClassDeclaration(const KDevelop::RangeInRevision &range, \
KDevelop::DUContext *ctx)
- : KDevelop::ClassDeclaration(range, ctx)
+ClassDeclaration::ClassDeclaration(const KDevelop::RangeInRevision &range, \
KDevelop::DUContext *ctx) + : ModuleDeclaration(range, ctx)
{
}
-RubyClassDeclaration::RubyClassDeclaration(const KDevelop::ClassDeclaration &rhs)
- : KDevelop::ClassDeclaration(rhs)
+ClassDeclaration::ClassDeclaration(const ClassDeclaration &rhs)
+ : ModuleDeclaration(rhs)
{
}
-RubyClassDeclaration::RubyClassDeclaration(KDevelop::ClassDeclarationData &data)
- : KDevelop::ClassDeclaration(data)
+ClassDeclaration::ClassDeclaration(ModuleDeclarationData &data)
+ : ModuleDeclaration(data)
{
}
-RubyClassDeclaration::RubyClassDeclaration(KDevelop::ClassDeclarationData &data, \
const KDevelop::RangeInRevision &range, KDevelop::DUContext *ctx)
- : KDevelop::ClassDeclaration(data, range, ctx)
+void ClassDeclaration::setBaseClass(KDevelop::IndexedType base)
{
+ m_baseClass = base;
+}
+void ClassDeclaration::clearBaseClass()
+{
+ m_baseClass = KDevelop::IndexedType(0);
+}
+
+KDevelop::IndexedType ClassDeclaration::baseClass() const
+{
+ return m_baseClass;
}
} // End of namespace Ruby
diff --git a/duchain/declarations/classdeclaration.h \
b/duchain/declarations/classdeclaration.h index 3ede52d..04fd48e 100644
--- a/duchain/declarations/classdeclaration.h
+++ b/duchain/declarations/classdeclaration.h
@@ -22,26 +22,66 @@
#define RUBY_CLASSDECLARATION_H
-#include <language/duchain/classdeclaration.h>
+#include <duchain/declarations/moduledeclaration.h>
#include <duchain/duchainexport.h>
namespace Ruby
{
-
-class KDEVRUBYDUCHAIN_EXPORT RubyClassDeclaration : public \
KDevelop::ClassDeclaration +
+class KDEVRUBYDUCHAIN_EXPORT ClassDeclarationData : public ModuleDeclarationData
{
public:
- RubyClassDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext \
*ctx);
- RubyClassDeclaration(const ClassDeclaration &rhs);
- RubyClassDeclaration(KDevelop::ClassDeclarationData &data);
- RubyClassDeclaration(KDevelop::ClassDeclarationData &data, const \
KDevelop::RangeInRevision &range, KDevelop::DUContext *ctx); + /// Constructor.
+ ClassDeclarationData() : ModuleDeclarationData()
+ {
+ /* There's nothing to do here */
+ }
+
+ /**
+ * Copy constructor.
+ * @param rhs data to copy.
+ */
+ ClassDeclarationData(const ClassDeclarationData &rhs) : \
ModuleDeclarationData(rhs) + {
+
+ }
};
-typedef RubyClassDeclaration ClassDeclaration;
+class KDEVRUBYDUCHAIN_EXPORT ClassDeclaration : public ModuleDeclaration
+{
+public:
+ /**
+ * Constructor.
+ * @param range The range of this declaration.
+ * @param ctx The context of this declaration.
+ */
+ ClassDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext \
*ctx); +
+ /// Copy constructor.
+ ClassDeclaration(const ClassDeclaration &rhs);
+
+ /**
+ * Copy constructor.
+ * @param data The data to be copied.
+ */
+ ClassDeclaration(ModuleDeclarationData &data);
+
+ void setBaseClass(KDevelop::IndexedType base);
+
+ void clearBaseClass();
+
+ KDevelop::IndexedType baseClass() const;
+
+ enum { Identity = 45 /** The id of this Type. */ };
+
+private:
+ DUCHAIN_DECLARE_DATA(ClassDeclaration)
+ KDevelop::IndexedType m_baseClass;
+};
} // End of namespace Ruby
-#endif // CLASSDECLARATION_H
+#endif // RUBY_CLASSDECLARATION_H
diff --git a/duchain/navigation/declarationnavigationcontext.cpp \
b/duchain/navigation/declarationnavigationcontext.cpp index 37bbcaf..d71e473 100644
--- a/duchain/navigation/declarationnavigationcontext.cpp
+++ b/duchain/navigation/declarationnavigationcontext.cpp
@@ -54,16 +54,13 @@ void DeclarationNavigationContext::htmlClass()
if (classDecl) {
/* Write class type */
- if (classDecl->classType() == ClassDeclarationData::Interface)
- modifyHtml() += "module ";
- else
- modifyHtml() += "class ";
+ modifyHtml() += "class ";
/* Write identifier */
eventuallyMakeTypeLinks(m_declaration->abstractType());
/* Write inheritance */
- if (classDecl->baseClassesSize() > 0) {
- AbstractType::Ptr base = \
classDecl->baseClasses()->baseClass.abstractType(); + if \
(classDecl->baseClass()) { + AbstractType::Ptr base = \
classDecl->baseClass().abstractType(); modifyHtml() += " is a subclass of ";
eventuallyMakeTypeLinks(base);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic