[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdev-ruby/gsoc] duchain: Fixing some issues around the new implementation of the ClassDeclaration c
From: Miquel_Sabaté <mikisabate () gmail ! com>
Date: 2012-05-31 19:29:56
Message-ID: 20120531192956.98A5CA60CB () git ! kde ! org
[Download RAW message or body]
Git commit 1510c85e49c18e7c981c4880de9f52bcf52d8755 by Miquel Sabaté.
Committed on 31/05/2012 at 21:02.
Pushed by mssola into branch 'gsoc'.
Fixing some issues around the new implementation of the ClassDeclaration class
M +2 -8 duchain/builders/declarationbuilder.cpp
M +47 -5 duchain/declarations/classdeclaration.cpp
M +5 -27 duchain/declarations/classdeclaration.h
M +1 -2 duchain/declarations/moduledeclaration.h
M +3 -0 duchain/expressionvisitor.cpp
M +1 -0 duchain/tests/duchain.cpp
http://commits.kde.org/kdev-ruby/1510c85e49c18e7c981c4880de9f52bcf52d8755
diff --git a/duchain/builders/declarationbuilder.cpp \
b/duchain/builders/declarationbuilder.cpp index 6e567b0..e3427b7 100644
--- a/duchain/builders/declarationbuilder.cpp
+++ b/duchain/builders/declarationbuilder.cpp
@@ -424,11 +424,8 @@ void DeclarationBuilder::visitInclude(RubyAst *node)
RubyAst *module = new RubyAst(node->tree->r, node->context);
ModuleDeclaration *decl = getModuleDeclaration(module);
- // Register module mix-in
- registerModuleMixin(decl->indexedType(), true);
-
- // Include the instance methods
if (decl) {
+ registerModuleMixin(decl->indexedType(), true);
QList<MethodDeclaration *> iMethods = getDeclaredMethods(decl);
foreach (MethodDeclaration *md, iMethods) {
if (!md->isClassMethod()) {
@@ -449,11 +446,8 @@ void DeclarationBuilder::visitExtend(RubyAst *node)
RubyAst *module = new RubyAst(node->tree->r, node->context);
ModuleDeclaration *decl = getModuleDeclaration(module);
- // Register module mix-in
- registerModuleMixin(decl->indexedType(), false);
-
- // Include the class methods
if (decl) {
+ registerModuleMixin(decl->indexedType(), false);
QList<MethodDeclaration *> eMethods = getDeclaredMethods(decl);
foreach (MethodDeclaration *md, eMethods) {
if (md->isClassMethod()) {
diff --git a/duchain/declarations/classdeclaration.cpp \
b/duchain/declarations/classdeclaration.cpp index 4045f1a..e4ed906 100644
--- a/duchain/declarations/classdeclaration.cpp
+++ b/duchain/declarations/classdeclaration.cpp
@@ -19,21 +19,27 @@
#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)
{
-
}
ClassDeclaration::ClassDeclaration(const ClassDeclaration &rhs)
: ModuleDeclaration(rhs)
{
-
+ m_baseClass = rhs.baseClass();
}
ClassDeclaration::ClassDeclaration(ModuleDeclarationData &data)
@@ -44,18 +50,54 @@ ClassDeclaration::ClassDeclaration(ModuleDeclarationData &data)
void ClassDeclaration::setBaseClass(KDevelop::IndexedType base)
{
- d_func_dynamic()->baseClass = base;
+ m_baseClass = base;
}
void ClassDeclaration::clearBaseClass()
{
- d_func_dynamic()->baseClass = KDevelop::IndexedType(0);
+ m_baseClass = KDevelop::IndexedType(0);
}
KDevelop::IndexedType ClassDeclaration::baseClass() const
{
- return d_func()->baseClass;
+ return m_baseClass;
+}
+
+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 b3d10cb..ab79def 100644
--- a/duchain/declarations/classdeclaration.h
+++ b/duchain/declarations/classdeclaration.h
@@ -22,34 +22,13 @@
#define RUBY_CLASSDECLARATION_H
-#include <duchain/declarations/moduledeclaration.h>
+#include "moduledeclaration.h"
#include <duchain/duchainexport.h>
namespace Ruby
{
-class KDEVRUBYDUCHAIN_EXPORT ClassDeclarationData : public ModuleDeclarationData
-{
-public:
- /// Constructor.
- ClassDeclarationData() : ModuleDeclarationData()
- {
- /* There's nothing to do here */
- }
-
- /**
- * Copy constructor.
- * @param rhs data to copy.
- */
- ClassDeclarationData(const ClassDeclarationData &rhs) : \
ModuleDeclarationData(rhs)
- {
-
- }
-
- KDevelop::IndexedType baseClass;
-};
-
class KDEVRUBYDUCHAIN_EXPORT ClassDeclaration : public ModuleDeclaration
{
public:
@@ -70,15 +49,14 @@ public:
ClassDeclaration(ModuleDeclarationData &data);
void setBaseClass(KDevelop::IndexedType base);
-
void clearBaseClass();
+ KDevelop::IndexedType baseClass() const;
- KDevelop::IndexedType baseClass() const;
-
- enum { Identity = 45 /** The id of this Type. */ };
+ enum { Identity = 46 /** The id of this Type. */ };
private:
- DUCHAIN_DECLARE_DATA(ClassDeclaration)
+ virtual KDevelop::Declaration * clonePrivate() const;
+ KDevelop::IndexedType m_baseClass;
};
} // End of namespace Ruby
diff --git a/duchain/declarations/moduledeclaration.h \
b/duchain/declarations/moduledeclaration.h index 812350f..e58037a 100644
--- a/duchain/declarations/moduledeclaration.h
+++ b/duchain/declarations/moduledeclaration.h
@@ -87,8 +87,7 @@ private:
} // End of namespace Ruby
-
-Q_DECLARE_TYPEINFO(Ruby::ModuleMixin, Q_MOVABLE_TYPE); // TODO: check this
+Q_DECLARE_TYPEINFO(Ruby::ModuleMixin, Q_MOVABLE_TYPE);
#endif /* MODULE_DECLARATION_H */
diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp
index 113fc0a..4a7bdf8 100644
--- a/duchain/expressionvisitor.cpp
+++ b/duchain/expressionvisitor.cpp
@@ -62,6 +62,7 @@ void ExpressionVisitor::visitName(RubyAst *node)
{
if (!node->tree) // TODO: clean, it shouldn't happen, but it does :(
return;
+ DUChainReadLocker lock(DUChain::lock());
QualifiedIdentifier id = getIdentifier(node);
const CursorInRevision cursor = m_editor->findPosition(node->tree, \
EditorIntegrator::FrontEdge);
QList<Declaration *> decls = m_ctx->findDeclarations(id.first(), cursor, 0, \
DUContext::DontSearchInParent); @@ -167,6 +168,7 @@ void \
ExpressionVisitor::visitHash(RubyAst *node)
void ExpressionVisitor::visitArrayValue(RubyAst *node)
{
+ DUChainReadLocker lock(DUChain::lock());
RubyAstVisitor::visitArrayValue(node);
RubyAst *child = new RubyAst(node->tree->l, node->context);
QualifiedIdentifier id = getIdentifier(child);
@@ -315,6 +317,7 @@ void ExpressionVisitor::visitCaseStatement(RubyAst *node)
TypePtr<AbstractType> ExpressionVisitor::getBuiltinsType(const QString &desc, \
DUContext *ctx) {
+ DUChainReadLocker lock(DUChain::lock());
QList<Declaration *> decls = \
ctx->topContext()->findDeclarations(QualifiedIdentifier(desc)); Declaration *dec = \
(decls.isEmpty()) ? NULL : decls.first();
AbstractType::Ptr type = dec ? dec->abstractType() : AbstractType::Ptr(NULL);
diff --git a/duchain/tests/duchain.cpp b/duchain/tests/duchain.cpp
index 020c8e5..fa91469 100644
--- a/duchain/tests/duchain.cpp
+++ b/duchain/tests/duchain.cpp
@@ -34,6 +34,7 @@
#include <duchain/types/classtype.h>
#include <duchain/declarations/methoddeclaration.h>
#include <duchain/declarations/classdeclaration.h>
+#include <duchain/declarations/moduledeclaration.h>
QTEST_MAIN(Ruby::TestDUChain)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic