• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

language/duchain

KDevelop::DUChain

KDevelop::DUChain Class Reference

Holds references to all top level source file contexts. More...

#include <duchain.h>

Inheritance diagram for KDevelop::DUChain:
Inheritance graph
[legend]

List of all members.

Public Slots

void emitDeclarationSelected (DeclarationPointer decl)
void removeDocumentChain (TopDUContext *document)

Signals

void declarationSelected (DeclarationPointer decl)

Public Member Functions

Q_SCRIPTABLE void addDocumentChain (TopDUContext *chain)
Q_SCRIPTABLE QList
< TopDUContext * > 
allChains () const
Q_SCRIPTABLE QList
< ParsingEnvironmentFilePointer > 
allEnvironmentFiles (const IndexedString &document)
Q_SCRIPTABLE TopDUContext * chainForDocument (const IndexedString &document, const ParsingEnvironment *environment, bool onlyProxyContexts=false, bool noProxyContexts=false) const
Q_SCRIPTABLE TopDUContext * chainForDocument (const KUrl &document, const ParsingEnvironment *environment, bool onlyProxyContexts=false, bool noProxyContexts=false) const
Q_SCRIPTABLE TopDUContext * chainForDocument (const IndexedString &document) const
Q_SCRIPTABLE TopDUContext * chainForDocument (const KUrl &document) const
Q_SCRIPTABLE TopDUContext * chainForIndex (uint index) const
Q_SCRIPTABLE QList
< TopDUContext * > 
chainsForDocument (const IndexedString &document) const
Q_SCRIPTABLE QList
< TopDUContext * > 
chainsForDocument (const KUrl &document) const
bool compareToDisk ()
void disablePersistentStorage ()
Q_SCRIPTABLE QList< KUrl > documents () const
Q_SCRIPTABLE
ParsingEnvironmentFilePointer 
environmentFileForDocument (IndexedTopDUContext topContext) const
Q_SCRIPTABLE
ParsingEnvironmentFilePointer 
environmentFileForDocument (const IndexedString &document, const ParsingEnvironment *environment, bool onlyProxyContexts=false, bool noProxyContexts=false) const
void finalCleanup ()
Q_SCRIPTABLE bool isInMemory (uint topContextIndex) const
void storeToDisk ()
Q_SCRIPTABLE void updateContextEnvironment (TopDUContext *context, ParsingEnvironmentFile *file)
Q_SCRIPTABLE void updateContextForUrl (const IndexedString &document, TopDUContext::Features minFeatures, QObject *notifyReady=0) const
Q_SCRIPTABLE IndexedString urlForIndex (uint index) const
KDevelop::ReferencedTopDUContext waitForUpdate (const IndexedString &document, TopDUContext::Features minFeatures, bool wantProxyContext=false)

Static Public Member Functions

static Q_SCRIPTABLE void branchAdded (DUContext *context)
static Q_SCRIPTABLE void branchModified (DUContext *context)
static Q_SCRIPTABLE void branchRemoved (DUContext *context)
static Q_SCRIPTABLE Definitions * definitions ()
static Q_SCRIPTABLE bool deleted ()
static Q_SCRIPTABLE DUChainLock * lock ()
static uint newTopContextIndex ()
static Q_SCRIPTABLE
DUChainObserver * 
notifier ()
static Q_SCRIPTABLE DUChain * self ()
static Uses * uses ()

Detailed Description

Holds references to all top level source file contexts.

The DUChain is a global static class which manages the definition-use chains. It performs the following functions:

  • registers chains with addDocumentChain() and deregisters with removeDocumentChain()
  • allows querying for existing chains
  • watches text editors, registering and deregistering them with the BackgroundParser when files are opened and closed.

Definition at line 55 of file duchain.h.


Member Function Documentation

void KDevelop::DUChain::addDocumentChain ( TopDUContext *  chain  ) 

Registers a new definition-use chain for the given document.

Definition at line 1097 of file duchain.cpp.

QList< TopDUContext * > KDevelop::DUChain::allChains (  )  const

Return a list of all chains available.

Definition at line 1061 of file duchain.cpp.

QList< ParsingEnvironmentFilePointer > KDevelop::DUChain::allEnvironmentFiles ( const IndexedString &  document  ) 

Returns the list of the environment-infos of all versions of the given document.

Definition at line 1309 of file duchain.cpp.

void KDevelop::DUChain::branchAdded ( DUContext *  context  )  [static]

Notify that a branch was added to context.

Definition at line 1337 of file duchain.cpp.

void KDevelop::DUChain::branchModified ( DUContext *  context  )  [static]

Notify that a branch was modified within context.

Definition at line 1342 of file duchain.cpp.

void KDevelop::DUChain::branchRemoved ( DUContext *  context  )  [static]

Notify that a branch was removed from context.

Definition at line 1347 of file duchain.cpp.

TopDUContext * KDevelop::DUChain::chainForDocument ( const IndexedString &  document,
const ParsingEnvironment *  environment,
bool  onlyProxyContexts = false,
bool  noProxyContexts = false 
) const

Find a chain that fits into the given environment.

If no fitting chain is found, 0 is returned. When no fitting chain is in memory, one may be loaded from disk.

Parameters:
onlyProxyContexts If this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set.

Prefer this over the KUrl version.

Definition at line 1320 of file duchain.cpp.

TopDUContext * KDevelop::DUChain::chainForDocument ( const KUrl &  document,
const ParsingEnvironment *  environment,
bool  onlyProxyContexts = false,
bool  noProxyContexts = false 
) const

Find a chain that fits into the given environment.

If no fitting chain is found, 0 is returned. When no fitting chain is in memory, one may be loaded from disk.

Parameters:
onlyProxyContexts If this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set.

Definition at line 1287 of file duchain.cpp.

TopDUContext * KDevelop::DUChain::chainForDocument ( const KUrl &  document  )  const

Return any chain for the given document If available, the version accepting IndexedString should be used instead of this, for performance reasons.

When no fitting chain is in memory, one may be loaded from disk.

Definition at line 1172 of file duchain.cpp.

TopDUContext * KDevelop::DUChain::chainForIndex ( uint  index  )  const

Returns the top-context that has the given index assigned, or zero if it doesn't exist.

See also:
TopDUContext::ownIndex The duchain must be read-locked when this is called

Definition at line 1195 of file duchain.cpp.

QList< TopDUContext * > KDevelop::DUChain::chainsForDocument ( const IndexedString &  document  )  const

Return all chains for the given document that are currently in memory.

This does not load any chains from disk. Should be preferred over the KUrl version.

Definition at line 1267 of file duchain.cpp.

QList< TopDUContext * > KDevelop::DUChain::chainsForDocument ( const KUrl &  document  )  const

Return all chains for the given document that are currently in memory.

This does not load any chains from disk.

Definition at line 1262 of file duchain.cpp.

bool KDevelop::DUChain::compareToDisk (  ) 

Compares the whole duchain and all its repositories in the current state to disk When the comparison fails, debug-output will show why The duchain must not be locked when calling this.

Returns:
true If the current memory state equals the disk state, else false

Step 1: Compare the repositories

Definition at line 1660 of file duchain.cpp.

void KDevelop::DUChain::declarationSelected ( DeclarationPointer  decl  )  [signal]

Is emitted when the declaration has been selected somewhere in the user-interface, for example in the completion-list.

Definitions * KDevelop::DUChain::definitions (  )  [static]

Returns the structure that manages mapping between definitions and declarations.

Definition at line 1520 of file duchain.cpp.

bool KDevelop::DUChain::deleted (  )  [static]

Returns true if the global duchain instance has already been deleted.

Definition at line 1568 of file duchain.cpp.

void KDevelop::DUChain::disablePersistentStorage (  ) 

If you call this, the persistent disk-storage structure will stay unaffected, and no duchain cleanup will be done.

Call this from within tests.

Definition at line 1632 of file duchain.cpp.

QList< KUrl > KDevelop::DUChain::documents (  )  const

Only used for debugging at the moment.

Definition at line 1352 of file duchain.cpp.

void KDevelop::DUChain::emitDeclarationSelected ( DeclarationPointer  decl  )  [slot]

Emits the declarationSelected signal, so other parties can notice it.

Definition at line 1583 of file duchain.cpp.

ParsingEnvironmentFilePointer KDevelop::DUChain::environmentFileForDocument ( const IndexedString &  document,
const ParsingEnvironment *  environment,
bool  onlyProxyContexts = false,
bool  noProxyContexts = false 
) const

Find the environment-file of a chain that fits into the given environment.

If no fitting chain is found, 0 is returned. When no fitting chain is in memory, one may be loaded from disk.

This should be preferred over chainForDocument when only the environment-info is needed, because the TopDUContext is not loaded in this function.

Parameters:
onlyProxyContexts If this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set.

Prefer this over the KUrl version.

Definition at line 1291 of file duchain.cpp.

void KDevelop::DUChain::finalCleanup (  ) 

Does a big cleanup of the repositories, removing all items that are not needed any more for disk-persistency The duchain must not be locked when calling this.

Warning:
Only do this right after startup, or after shutdown, in a moment where indexed repository items are not needed any more, since the reference-counting mechanisms only respect disk persistency. All items that are not disk-referenced are invalidated during this step, which will lead to inconsistency, crashes, etc. when done in the wrong moment.

Definition at line 1645 of file duchain.cpp.

bool KDevelop::DUChain::isInMemory ( uint  topContextIndex  )  const

Returns whether the top-context with the given index is currently loaded in memory.

Definition at line 1176 of file duchain.cpp.

DUChainLock * KDevelop::DUChain::lock (  )  [static]

Retrieve the read write lock for the entire definition-use chain.

To call non-const methods, you must be holding a write lock.

Evaluations made prior to holding a lock (including which objects exist) must be verified once the lock is held, as they may have changed or been deleted.

Threadsafe:

Definition at line 1056 of file duchain.cpp.

uint KDevelop::DUChain::newTopContextIndex (  )  [static]

Allocates a new identity for a new top-context, no lock needed. The returned value is never zero.

Definition at line 1555 of file duchain.cpp.

DUChainObserver * KDevelop::DUChain::notifier (  )  [static]

Returns the object which emits signals regarding duchain changes.

Definition at line 1332 of file duchain.cpp.

void KDevelop::DUChain::removeDocumentChain ( TopDUContext *  document  )  [slot]

Removes the given top-context from the duchain, and deletes it.

This assertion fails if you call removeDocumentChain(..) on a document that has not been added to the du-chain

Definition at line 1084 of file duchain.cpp.

DUChain * KDevelop::DUChain::self (  )  [static]

Returns the global static instance.

Definition at line 1051 of file duchain.cpp.

void KDevelop::DUChain::storeToDisk (  ) 

Stores the whole duchain and all its repositories in the current state to disk The duchain must not be locked in any way.

Definition at line 1636 of file duchain.cpp.

void KDevelop::DUChain::updateContextEnvironment ( TopDUContext *  context,
ParsingEnvironmentFile *  file 
)

Changes the environment attached to the given top-level context, and updates the management-structures to reflect that.

Definition at line 1071 of file duchain.cpp.

void KDevelop::DUChain::updateContextForUrl ( const IndexedString &  document,
TopDUContext::Features  minFeatures,
QObject *  notifyReady = 0 
) const

Makes sure the standard-context for the given url is up-to-date.

This may trigger a parsing in background, so a QObject can be given that will be notified asyonchronously once the update is ready. If the context is already up to date, the given QObject is notified directly.

Parameters:
document Document to update
features The requested features. If you want to force a full update of the context, give TopDUContext::ForceUpdate. If you want to force an update including all imports, use TopDUContext::ForceUpdateRecursive.
notifyReady An optional pointer to a QObject that should contain a slot "void updateReady(KDevelop::IndexedString url, KDevelop::ReferencedTopDUContext topContext)". The notification is guaranteed to be called once for each call to updateContextForUrl. The given top-context may be invalid if the update failed. A queued connection is used if a re-parse has to be done.

Start a parse-job for the given document

Definition at line 1619 of file duchain.cpp.

IndexedString KDevelop::DUChain::urlForIndex ( uint  index  )  const

Returns the url for the given top-context index if available. This does have some cost, so avoid it when possible.

Definition at line 1183 of file duchain.cpp.

Uses * KDevelop::DUChain::uses (  )  [static]

Returns the structure that manages mapping between declarations, and which top level contexts contain uses of them.

Definition at line 1515 of file duchain.cpp.

KDevelop::ReferencedTopDUContext KDevelop::DUChain::waitForUpdate ( const IndexedString &  document,
TopDUContext::Features  minFeatures,
bool  wantProxyContext = false 
)

Convenience-function similar to updateContextForUrl that blocks this thread until the update of the given document is ready, and returns the top-context.

Parameters:
document The document to update
features The requested features. If you want to force a full update of the context, give TopDUContext::ForceUpdate. If you want to force an update including all imports, use TopDUContext::ForceUpdateRecursive.
Returns:
The up-to-date top-context, or zero if the update failed
Warning:
The duchain must _not_ be locked when this is called!

Todo:
When we don't do this, the backgroundparser doesn't process anything. The background-parser should be moved into an own thread, so we wouldn't need to do this.

Definition at line 1587 of file duchain.cpp.


The documentation for this class was generated from the following files:
  • duchain.h
  • duchain.cpp

language/duchain

Skip menu "language/duchain"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal