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

List:       kde-commits
Subject:    [kdev-ruby] duchain/builders: Module declarations are now almost the same as the class declarations
From:       Miquel_Sabaté <mikisabate () gmail ! com>
Date:       2012-02-29 22:34:07
Message-ID: 20120229223407.51433A60BB () git ! kde ! org
[Download RAW message or body]

Git commit 8e84df787fa1f456a2cf14af644905799368512a by Miquel Sabaté.
Committed on 29/02/2012 at 23:27.
Pushed by mssola into branch 'master'.

Module declarations are now almost the same as the class declarations

M  +2    -3    duchain/builders/contextbuilder.cpp
M  +21   -6    duchain/builders/declarationbuilder.cpp

http://commits.kde.org/kdev-ruby/8e84df787fa1f456a2cf14af644905799368512a

diff --git a/duchain/builders/contextbuilder.cpp b/duchain/builders/contextbuilder.cpp
index e892149..896f44b 100644
--- a/duchain/builders/contextbuilder.cpp
+++ b/duchain/builders/contextbuilder.cpp
@@ -151,9 +151,8 @@ KDevelop::QualifiedIdentifier ContextBuilder::identifierForNode(NameAst *name)
 
 void ContextBuilder::visitModuleStatement(RubyAst *node)
 {
-    openContextForClassDefinition(node);
-    RubyAstVisitor::visitModuleStatement(node);
-    closeContext();
+    node->tree = node->tree->l;
+    visitBody(node);
 }
 
 // TODO : what about singleton classes?
diff --git a/duchain/builders/declarationbuilder.cpp b/duchain/builders/declarationbuilder.cpp
index 24750d0..75f0d96 100644
--- a/duchain/builders/declarationbuilder.cpp
+++ b/duchain/builders/declarationbuilder.cpp
@@ -101,14 +101,29 @@ void DeclarationBuilder::visitClassStatement(RubyAst *node)
 
 void DeclarationBuilder::visitModuleStatement(RubyAst* node)
 {
+    DUChainWriteLocker lock(DUChain::lock());
+    RangeInRevision range = getNameRange(node);
+    QualifiedIdentifier id = identifierForNode(new NameAst(node));
+
     setComment(getComment(node));
-    openClassDeclaration(node, false);
-    RubyAstVisitor::visitModuleStatement(node);
+    /* TODO: should this get a ModuleDeclaration or so? */
+    ClassDeclaration *decl = openDeclaration<ClassDeclaration>(id, range);
+    decl->setKind(KDevelop::Declaration::Type);
+    decl->clearBaseClasses();
+    decl->setClassType(ClassDeclarationData::Interface);
+
+    StructureType::Ptr type = StructureType::Ptr(new StructureType());
+    type->setDeclaration(decl);
+    decl->setType(type);
+    openType(type);
+
+    openContextForClassDefinition(node);
+    decl->setInternalContext(currentContext());
+    lock.unlock();
+    DeclarationBuilderBase::visitModuleStatement(node);
+    lock.lock();
+    closeContext();
 
-    {
-        DUChainWriteLocker wlock(DUChain::lock());
-        closeContext();
-    }
     closeType();
     closeDeclaration();
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

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