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

List:       kde-commits
Subject:    KDE/kdevplatform/language/duchain
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2009-02-25 17:50:36
Message-ID: 1235584236.336759.17641.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 931716 by zwabel:

Allow adding indirect imports to contexts


 M  +21 -15    ducontext.cpp  
 M  +8 -0      ducontext.h  


--- trunk/KDE/kdevplatform/language/duchain/ducontext.cpp #931715:931716
@@ -889,11 +889,26 @@
   return m_dynamicData->imports(origin, topContext(), 4);
 }
 
+void DUContext::addIndirectImport(const DUContext::Import& import) {
+  ENSURE_CAN_WRITE
+  DUCHAIN_D_DYNAMIC(DUContext);
 
+  for(unsigned int a = 0; a < d->m_importedContextsSize(); ++a) {
+    if(d->m_importedContexts()[a] == import) {
+      d->m_importedContextsList()[a].position = import.position;
+      return;
+    }
+  }
+
+  ///Do not sort the imported contexts by their own line-number, it makes no sense.
+  ///Contexts added first, aka template-contexts, should stay in first place, so \
they are searched first. +
+  d->m_importedContextsList().append(import);
+}
+
 void DUContext::addImportedParentContext( DUContext * context, const SimpleCursor& \
position, bool anonymous, bool /*temporary*/ )  {
   ENSURE_CAN_WRITE
-  DUCHAIN_D_DYNAMIC(DUContext);
 
   if(context == this) {
     kDebug() << "Tried to import self";
@@ -901,24 +916,12 @@
   }
   
   Import import(context, position);
+  addIndirectImport(import);
 
-  for(unsigned int a = 0; a < d->m_importedContextsSize(); ++a) {
-    if(d->m_importedContexts()[a] == import) {
-      d->m_importedContextsList()[a].position = position;
-      return;
-    }
-  }
-
   if( !anonymous && import.isBackwardMapped() ) {
     ENSURE_CAN_WRITE_(context)
     context->m_dynamicData->addImportedChildContext(this);
   }
-
-  ///Do not sort the imported contexts by their own line-number, it makes no sense.
-  ///Contexts added first, aka template-contexts, should stay in first place, so \
                they are searched first.
-
-  d->m_importedContextsList().append(import);
-
   //DUChain::contextChanged(this, DUChainObserver::Addition, \
DUChainObserver::ImportedParentContexts, context);  }
 
@@ -1845,9 +1848,12 @@
   }
 }
 
+DUContext::Import::Import(const DeclarationId& id, const SimpleCursor& _position) : \
position(_position) { +  m_declaration = id;
+}
+
 DUContext* DUContext::Import::context(const TopDUContext* topContext) const {
   if(m_declaration.isValid()) {
-    Q_ASSERT(m_declaration.isDirect());
     Declaration* decl = m_declaration.getDeclaration(topContext);
     if(decl)
       return decl->internalContext();
--- trunk/KDE/kdevplatform/language/duchain/ducontext.h #931715:931716
@@ -345,6 +345,7 @@
   struct KDEVPLATFORMLANGUAGE_EXPORT Import {
     ///DUChain must be read-locked when this is called
     Import(DUContext* context = 0, const SimpleCursor& position = \
SimpleCursor::invalid()); +    Import(const DeclarationId& id, const SimpleCursor& \
position = SimpleCursor::invalid());  bool operator==(const Import& rhs) const {
       return m_context == rhs.m_context && m_declaration == rhs.m_declaration;
     }
@@ -407,6 +408,13 @@
   virtual void addImportedParentContext(DUContext* context, const SimpleCursor& \
position = SimpleCursor::invalid(), bool anonymous = false, bool temporary = false);  \
  /**
+   * Adds an imported context, which may be indirect.
+   * @warning This is only allowed if this context is _NOT_ a top-context
+   * @warning When using this mechanism, this context will not be registered as \
importer to the other one. +   */
+  void addIndirectImport(const DUContext::Import& import);
+
+  /**
    * Removes a child context.
    */
   virtual void removeImportedParentContext(DUContext* context);


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

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