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

List:       kde-commits
Subject:    [kdev-ruby/new_duchain] /: Better support for dynamically created
From:       Alexander Dymo <adymo () kdevelop ! org>
Date:       2011-08-10 10:56:21
Message-ID: 20110810105621.87CA1A60AE () git ! kde ! org
[Download RAW message or body]

Git commit b9796df691dfa4d71c34b5f679998dd92c15a259 by Alexander Dymo.
Committed on 10/08/2011 at 12:45.
Pushed by dymo into branch 'new_duchain'.

Better support for dynamically created ruby debug area:
- have a function to return debug area number
- introduce debug() macro which will use that number automatically
- change all kDebug() calls to debug()

M  +0    -1    rubyhighlighting.cpp
M  +2    -1    parser/rubyastvisitor.cpp
A  +30   -0    rubydefs.h     [License: LGPL (v2+)]
M  +3    -4    rubylanguagesupport.cpp
M  +4    -3    rubyparsejob.cpp
M  +7    -6    duchain/contextbuilder.cpp

http://commits.kde.org/kdev-ruby/b9796df691dfa4d71c34b5f679998dd92c15a259

diff --git a/duchain/contextbuilder.cpp b/duchain/contextbuilder.cpp
index e0e4293..62d15a4 100644
--- a/duchain/contextbuilder.cpp
+++ b/duchain/contextbuilder.cpp
@@ -29,6 +29,7 @@
 #include "rubyducontext.h"
 #include "helpers.h"
 #include <KStandardDirs>
+#include <rubydefs.h>
 
 
 using namespace KDevelop;
@@ -54,13 +55,13 @@ ReferencedTopDUContext ContextBuilder::build(const IndexedString \
&url, RubyAst *  updateContext = DUChain::self()->chainForDocument(url);
     }
     if (updateContext) {
-        kDebug() << "Re-compiling" << url.str();
+        debug() << "Re-compiling" << url.str();
         DUChainWriteLocker lock(DUChain::lock());
         updateContext->clearImportedParentContexts();
         updateContext->parsingEnvironmentFile()->clearModificationRevisions();
         updateContext->clearProblems();
     } else
-        kDebug() << "Compiling";
+        debug() << "Compiling";
     return ContextBuilderBase::build(url, node, updateContext);
 }
 
@@ -106,7 +107,7 @@ void ContextBuilder::startVisiting(RubyAst *node)
             m_hasUnresolvedIdentifiers = true;
             DUChain::self()->updateContextForUrl(doc_url, \
TopDUContext::AllDeclarationsContextsAndUses);  } else {
-            kDebug() << "Adding builtins context";
+            debug() << "Adding builtins context";
             DUChainWriteLocker wlock(DUChain::lock());
             currentContext()->addImportedParentContext(internal);
             m_builtinsContext = TopDUContextPointer(internal);
@@ -160,14 +161,14 @@ void ContextBuilder::visitClassStatement(RubyAst *node)
     openContextForClassDefinition(node);
     RubyAstVisitor::visitClassStatement(node);
     closeContext();
-    kDebug() << "Closing class: " << getModuleName(node->tree);
+    debug() << "Closing class: " << getModuleName(node->tree);
 }
 
 void ContextBuilder::visitMethodStatement(RubyAst *node)
 {
 //     TODO
     lastMethodName = QualifiedIdentifier(getMethodName(node->tree));
-kDebug() << "Start Visiting function: " << lastMethodName;
+debug() << "Start Visiting function: " << lastMethodName;
     openContext(node, editorFindRange(node, node), DUContext::Function, \
lastMethodName);  RubyAstVisitor::visitMethodStatement(node);
     closeContext();
@@ -211,7 +212,7 @@ void ContextBuilder::openContextForClassDefinition(RubyAst *node)
     RangeInRevision range = editorFindRange(node, node);
     KDevelop::QualifiedIdentifier className(getModuleName(node->tree));
     DUChainWriteLocker wlock(DUChain::lock());
-kDebug() << "Open context for class: " << className;
+debug() << "Open context for class: " << className;
     openContext(node, range, DUContext::Class, className);
     currentContext()->setLocalScopeIdentifier(className);
     wlock.unlock();
diff --git a/parser/rubyastvisitor.cpp b/parser/rubyastvisitor.cpp
index a3fcf91..cf31bf4 100644
--- a/parser/rubyastvisitor.cpp
+++ b/parser/rubyastvisitor.cpp
@@ -18,6 +18,7 @@
  */
 
 #include "rubyastvisitor.h"
+#include <rubydefs.h>
 
 
 /* TODO: Under construction */
@@ -37,7 +38,7 @@ RubyAstVisitor::~RubyAstVisitor()
 
 void RubyAstVisitor::visitCode(RubyAst *node)
 {
-    kDebug() << "Visiting Code...";
+    debug() << "Visiting Code...";
     RubyAst *child = new RubyAst(node->tree, node->context);
 
     for (Node *n = node->tree; n != NULL; n = n->next) {
diff --git a/rubydefs.h b/rubydefs.h
new file mode 100644
index 0000000..1cb13f0
--- /dev/null
+++ b/rubydefs.h
@@ -0,0 +1,30 @@
+/* This file is part of KDevelop
+ *
+ * Copyright 2011 Alexander Dymo <adymo@kdevelop.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#ifndef RUBYDEFS_H
+#define RUBYDEFS_H
+
+static int debugArea()
+{
+    static int s_area = KDebug::registerArea("kdevelop (ruby support)");
+    return s_area;
+}
+#define debug() kDebug(debugArea())
+
+#endif
diff --git a/rubyhighlighting.cpp b/rubyhighlighting.cpp
index f00687d..0c102e2 100644
--- a/rubyhighlighting.cpp
+++ b/rubyhighlighting.cpp
@@ -20,7 +20,6 @@
 
 #include "rubyhighlighting.h"
 
-
 namespace Ruby
 {
 
diff --git a/rubylanguagesupport.cpp b/rubylanguagesupport.cpp
index d6fe011..721ad7f 100644
--- a/rubylanguagesupport.cpp
+++ b/rubylanguagesupport.cpp
@@ -46,6 +46,7 @@
 #include <language/backgroundparser/backgroundparser.h>
 
 //Ruby plugin
+#include <rubydefs.h>
 #include <rubylanguagesupport.h>
 #include <rubyparsejob.h>
 #include <rubyhighlighting.h>
@@ -82,8 +83,6 @@ LanguageSupport::LanguageSupport(QObject * parent,
     m_self = this;
     m_highlighting = new RubyHighlighting(this);
 
-    KDebug::registerArea("kdevelop (ruby support)");
-
     connect( core()->documentController(), SIGNAL( documentLoaded( \
KDevelop::IDocument* ) ),  this, SLOT( documentLoaded( KDevelop::IDocument* ) ) );
     connect( core()->documentController(), SIGNAL( documentClosed( \
KDevelop::IDocument* ) ), @@ -182,7 +181,7 @@ void \
LanguageSupport::documentActivated(KDevelop::IDocument * document)  
 void LanguageSupport::documentLoaded(KDevelop::IDocument * document)
 {
-    kDebug() << "loaded document";
+    debug() << "loaded document";
     core()->languageController()->backgroundParser()->addDocument(document->url());
 }
 
@@ -206,7 +205,7 @@ void LanguageSupport::projectClosing(KDevelop::IProject *project)
 
 void LanguageSupport::documentChanged(KDevelop::IDocument *document)
 {
-    kDebug() << "loaded document";
+    debug() << "loaded document";
     core()->languageController()->backgroundParser()->addDocument(document->url());
 }
 
diff --git a/rubyparsejob.cpp b/rubyparsejob.cpp
index 789e4a0..5fb6c58 100644
--- a/rubyparsejob.cpp
+++ b/rubyparsejob.cpp
@@ -30,6 +30,7 @@
 #include <language/interfaces/icodehighlighting.h>
 #include <language/backgroundparser/urlparselock.h>
 
+#include <rubydefs.h>
 #include <rubyparsejob.h>
 #include <rubylanguagesupport.h>
 #include <parser/rubyparser.h>
@@ -83,7 +84,7 @@ void ParseJob::run()
                 needsUpdate = false;
         }
         if (!(minimumFeatures() & TopDUContext::ForceUpdate || minimumFeatures() & \
                Resheduled) && !needsUpdate) {
-            kDebug() << "Already up to date" << document().str();
+            debug() << "Already up to date" << document().str();
             return;
         }
     }
@@ -135,7 +136,7 @@ void ParseJob::run()
             ICore::self()->languageController()->backgroundParser()->trackerForUrl(document())) \
{  ruby()->codeHighlighting()->highlightDUChain(m_duContext);
         }
-        kDebug() << "**** Parsing Succeeded ****";
+        debug() << "**** Parsing Succeeded ****";
     } else {
         kWarning() << "**** Parsing Failed ****";
         DUChainWriteLocker lock;
@@ -154,7 +155,7 @@ void ParseJob::run()
     }
     DUChainWriteLocker lock(DUChain::lock());
     foreach (ProblemPointer p, m_parser->m_problems) {
-        kDebug() << "Added problem to context";
+        debug() << "Added problem to context";
         m_duContext->addProblem(p);
     }
     setDuChain(m_duContext);


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

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