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

List:       kde-commits
Subject:    KDE/kdevelop/languages/cpp/cppduchain
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2008-03-31 22:13:55
Message-ID: 1207001635.058259.7692.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 792373 by zwabel:

Add a mechanism to debug mutual manipulation of kate smart-ranges, and add \
debug-output when a context-range is bad(end < start)



 M  +25 -1     contextbuilder.cpp  
 M  +6 -0      contextbuilder.h  


--- trunk/KDE/kdevelop/languages/cpp/cppduchain/contextbuilder.cpp #792372:792373
@@ -552,7 +552,8 @@
 DUContext* ContextBuilder::openContextInternal(const KDevelop::SimpleRange& range, \
DUContext::ContextType type, const QualifiedIdentifier& identifier)  {
   DUContext* ret = 0L;
-
+  if(range.start > range.end)
+    kDebug(9007) << "Bad context-range" << range.textRange();
   {
     DUChainReadLocker readLock(DUChain::lock());
 
@@ -589,10 +590,19 @@
       readLock.unlock();
       DUChainWriteLocker writeLock(DUChain::lock());
 
+#ifdef DEBUG_CONTEXT_RANGES
+      checkRanges();
+#endif
+      
       ret = new CppDUContext<DUContext>(m_editor->currentUrl(), SimpleRange(range), \
                m_contextStack.isEmpty() ? 0 : currentContext());
       ret->setSmartRange(m_editor->createRange(range.textRange()), \
DocumentRangeObject::Own);  ret->setType(type);
 
+#ifdef DEBUG_CONTEXT_RANGES
+      m_contextRanges[ret] = range;
+      checkRanges();
+#endif
+      
       if (!identifier.isEmpty()) {
         ret->setLocalScopeIdentifier(identifier);
 
@@ -619,6 +629,20 @@
   return ret;
 }
 
+#ifdef DEBUG_CONTEXT_RANGES
+void ContextBuilder::checkRanges()
+{
+  for(QHash<KDevelop::DUContext*, KDevelop::SimpleRange>::iterator it = \
m_contextRanges.begin(); it != m_contextRanges.end(); ) { +    if(it.key()->range() \
!= *it) { +      kDebug(9007) << "Range of" << \
it.key()->scopeIdentifier(true).toString() << "changed from" << (*it).textRange() << \
"to" << it.key()->range().textRange() << "at\n" << kBacktrace(); +      it = \
m_contextRanges.erase(it); //Remove it so we see each change only once +    }else{
+      ++it;
+    }
+  }
+}
+#endif
+
 void ContextBuilder::openContext(DUContext* newContext)
 {
   m_contextStack.push(newContext);
--- trunk/KDE/kdevelop/languages/cpp/cppduchain/contextbuilder.h #792372:792373
@@ -32,6 +32,8 @@
 #include <ksharedptr.h>
 #include "cppduchainexport.h"
 
+//Uncomment this to debug what happens to context ranges when new ones are inserted
+//#define DEBUG_CONTEXT_RANGES
 
 namespace KDevelop
 {
@@ -220,6 +222,10 @@
 
   inline int& nextContextIndex() { return m_nextContextStack.top(); }
 
+#ifdef DEBUG_CONTEXT_RANGES
+  void checkRanges();
+  QHash<KDevelop::DUContext*, KDevelop::SimpleRange> m_contextRanges;
+#endif
 
   QList<KDevelop::DUContext*> m_importedParentContexts;
 };


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

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