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

List:       kde-commits
Subject:    KDE/kdevplatform/language/duchain/builders
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2008-07-09 2:22:15
Message-ID: 1215570135.346042.30279.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 829755 by zwabel:

Add injectContext and closeInjectedContext function, that allow inserting a context \
with a custom range, and closing it again without cleaning it up, and without setting \
it as lastContext.



 M  +39 -16    abstractcontextbuilder.h  


--- trunk/KDE/kdevplatform/language/duchain/builders/abstractcontextbuilder.h \
#829754:829755 @@ -392,20 +392,6 @@
   }
 
   /**
-   * Open a newly created or previously existing context.
-   *
-   * The open context is put on the context stack, and becomes the new
-   * currentContext().
-   *
-   * \param newContext Context to open.
-   */
-  virtual void openContext( DUContext* newContext )
-  {
-    m_contextStack.push( newContext );
-    m_nextContextStack.push( 0 );
-  }
-
-  /**
    * Open a context, and create / update it if necessary.
    *
    * \param rangeNode The range which encompasses the context.
@@ -513,11 +499,46 @@
       return currentContext();
     }
   }
+  
+  /**
+   * Open a newly created or previously existing context.
+   *
+   * The open context is put on the context stack, and becomes the new
+   * currentContext().
+   * 
+   * \warning When you call this, you also have to open a range! If you want to \
re-use +   * the range associated to the context, use injectContext
+   * 
+   * \param newContext Context to open.
+   */
+  virtual void openContext( DUContext* newContext )
+  {
+    m_contextStack.push( newContext );
+    m_nextContextStack.push( 0 );
+  }
+  
+  /**
+   * This can be used to temporarily change the current context.
+   * \param range The range that will be used as new current range, or zero(then the \
range associated to the context is used) +   * */
+  void injectContext( DUContext* ctx, KTextEditor::SmartRange* range = 0 ) {
+    openContext( ctx );
+    m_editor->setCurrentRange( range ? range : ctx->smartRange() );
+  }
+  
+  /**
+   * Use this to close the context previously injected with injectContext.
+   * */
+  void closeInjectedContext() {
+    m_contextStack.pop();
+    m_nextContextStack.pop();
+    if(m_editor->smart())
+      m_editor->exitCurrentRange();
+  }
 
   /**
    * Close the current DUContext.  When recompiling, this function will remove any
    * contexts that were not encountered in this passing run.
-   *
    * \note The DUChain write lock is already held here.
    */
   virtual void closeContext()
@@ -528,9 +549,10 @@
       if(m_compilingContexts)
         currentContext()->cleanIfNotEncountered( m_encountered );
       setEncountered( currentContext() );
+      
+      m_lastContext = currentContext();
     }
 
-    m_lastContext = currentContext();
     m_contextStack.pop();
     m_nextContextStack.pop();
     if(m_editor->smart())
@@ -714,6 +736,7 @@
   }
 
 private:
+  
   Identifier m_identifier;
   QualifiedIdentifier m_qIdentifier;
   EditorIntegrator* m_editor;


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

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