• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/language/duchain

  • KDevelop
  • DUChain
Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
KDevelop::DUChain Class Reference

#include <duchain.h>

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

Public Slots

void emitDeclarationSelected (const KDevelop::DeclarationPointer &decl)
 
void emitUpdateReady (const KDevelop::IndexedString &url, const KDevelop::ReferencedTopDUContext &topContext)
 
void removeDocumentChain (KDevelop::TopDUContext *document)
 
void shutdown ()
 

Signals

void declarationSelected (const KDevelop::DeclarationPointer &decl)
 
void updateReady (const KDevelop::IndexedString &url, const KDevelop::ReferencedTopDUContext &topContext)
 

Public Member Functions

void addDocumentChain (TopDUContext *chain)
 
QList< TopDUContext * > allChains () const
 
QList< ParsingEnvironmentFilePointer > allEnvironmentFiles (const IndexedString &document)
 
TopDUContext * chainForDocument (const IndexedString &document, bool proxyContext=false) const
 
TopDUContext * chainForDocument (const IndexedString &document, const ParsingEnvironment *environment, bool proxyContext=false) const
 
TopDUContext * chainForDocument (const QUrl &document, bool proxyContext=false) const
 
TopDUContext * chainForDocument (const QUrl &document, const ParsingEnvironment *environment, bool proxyContext=false) const
 
TopDUContext * chainForIndex (uint index)
 
QList< TopDUContext * > chainsForDocument (const IndexedString &document) const
 
QList< TopDUContext * > chainsForDocument (const QUrl &document) const
 
bool compareToDisk ()
 
void disablePersistentStorage (bool disable=true)
 
QList< QUrl > documents () const
 
ParsingEnvironmentFilePointer environmentFileForDocument (const IndexedString &document, const ParsingEnvironment *environment, bool proxyContext=false) const
 
ParsingEnvironmentFilePointer environmentFileForDocument (IndexedTopDUContext topContext) const
 
QList< IndexedString > indexedDocuments () const
 
bool isInMemory (uint topContextIndex) const
 
void storeToDisk ()
 
void updateContextEnvironment (TopDUContext *context, ParsingEnvironmentFile *file)
 
void updateContextForUrl (const IndexedString &document, TopDUContext::Features minFeatures, QObject *notifyReady=nullptr, int priority=1) const
 
IndexedString urlForIndex (uint index) const
 
KDevelop::ReferencedTopDUContext waitForUpdate (const KDevelop::IndexedString &document, KDevelop::TopDUContext::Features minFeatures, bool proxyContext=false)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Static Public Member Functions

static Definitions * definitions ()
 
static bool deleted ()
 
static void initialize ()
 
static DUChainLock * lock ()
 
static uint newTopContextIndex ()
 
static QString repositoryPathForSession (const KDevelop::ISessionLock::Ptr &session)
 
static DUChain * self ()
 
static Uses * uses ()
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

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 54 of file duchain.h.

Member Function Documentation

◆ addDocumentChain()

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

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

Definition at line 1320 of file duchain.cpp.

◆ allChains()

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

Return a list of all chains available.

Definition at line 1288 of file duchain.cpp.

◆ allEnvironmentFiles()

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 1515 of file duchain.cpp.

◆ chainForDocument() [1/4]

TopDUContext* KDevelop::DUChain::chainForDocument ( const IndexedString &  document,
bool  proxyContext = false 
) const

◆ chainForDocument() [2/4]

TopDUContext * KDevelop::DUChain::chainForDocument ( const IndexedString &  document,
const ParsingEnvironment *  environment,
bool  proxyContext = 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
proxyContextIf this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set. Else, only content-contexts will be returned.

Prefer this over the QUrl version.

Note
The duchain must be at least read-locked locked when this is called!

Definition at line 1528 of file duchain.cpp.

◆ chainForDocument() [3/4]

TopDUContext * KDevelop::DUChain::chainForDocument ( const QUrl &  document,
bool  proxyContext = false 
) 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.

Note
The duchain must be at least read-locked locked when this is called!

Definition at line 1389 of file duchain.cpp.

◆ chainForDocument() [4/4]

TopDUContext * KDevelop::DUChain::chainForDocument ( const QUrl &  document,
const ParsingEnvironment *  environment,
bool  proxyContext = 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
proxyContextIf this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set. Else, only content-contexts will be returned.
Note
The duchain must be at least read-locked locked when this is called!

Definition at line 1485 of file duchain.cpp.

◆ chainForIndex()

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

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 This function is inlined because it is called in a very high frequency

Definition at line 177 of file duchain.h.

◆ chainsForDocument() [1/2]

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 QUrl version.

Definition at line 1464 of file duchain.cpp.

◆ chainsForDocument() [2/2]

QList< TopDUContext * > KDevelop::DUChain::chainsForDocument ( const QUrl &  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 1459 of file duchain.cpp.

◆ compareToDisk()

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 1874 of file duchain.cpp.

◆ declarationSelected

void KDevelop::DUChain::declarationSelected ( const KDevelop::DeclarationPointer &  decl)
signal

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

◆ definitions()

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

Returns the structure that manages mapping between definitions and declarations.

Definition at line 1694 of file duchain.cpp.

◆ deleted()

bool KDevelop::DUChain::deleted ( )
static

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

Definition at line 1776 of file duchain.cpp.

◆ disablePersistentStorage()

void KDevelop::DUChain::disablePersistentStorage ( bool  disable = true)

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 1859 of file duchain.cpp.

◆ documents()

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

Only used for debugging at the moment.

Definition at line 1541 of file duchain.cpp.

◆ emitDeclarationSelected

void KDevelop::DUChain::emitDeclarationSelected ( const KDevelop::DeclarationPointer &  decl)
slot

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

Definition at line 1796 of file duchain.cpp.

◆ emitUpdateReady

void KDevelop::DUChain::emitUpdateReady ( const KDevelop::IndexedString &  url,
const KDevelop::ReferencedTopDUContext &  topContext 
)
slot

Call this after you have modified the DUChain data associated with the file url.

This triggers an emit of the updateReady signal.

Definition at line 1804 of file duchain.cpp.

◆ environmentFileForDocument() [1/2]

ParsingEnvironmentFilePointer KDevelop::DUChain::environmentFileForDocument ( const IndexedString &  document,
const ParsingEnvironment *  environment,
bool  proxyContext = 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
proxyContextIf this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set. Else, only content-contexts will be returned.

Prefer this over the QUrl version.

Note
The duchain must be at least read-locked locked when this is called!

Definition at line 1491 of file duchain.cpp.

◆ environmentFileForDocument() [2/2]

ParsingEnvironmentFilePointer KDevelop::DUChain::environmentFileForDocument ( IndexedTopDUContext  topContext) const

Definition at line 1520 of file duchain.cpp.

◆ indexedDocuments()

QList< IndexedString > KDevelop::DUChain::indexedDocuments ( ) const

Only used for debugging at the moment Prefer that over the QUrl version for performance reasons.

Definition at line 1554 of file duchain.cpp.

◆ initialize()

void KDevelop::DUChain::initialize ( )
static

Initializes common static item repositories.

Must be called once for multi threaded applications to work reliably.

Definition at line 1250 of file duchain.cpp.

◆ isInMemory()

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

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

Definition at line 1394 of file duchain.cpp.

◆ lock()

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 1283 of file duchain.cpp.

◆ newTopContextIndex()

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 1750 of file duchain.cpp.

◆ removeDocumentChain

void KDevelop::DUChain::removeDocumentChain ( KDevelop::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 1305 of file duchain.cpp.

◆ repositoryPathForSession()

QString KDevelop::DUChain::repositoryPathForSession ( const KDevelop::ISessionLock::Ptr &  session)
static

Definition at line 1241 of file duchain.cpp.

◆ self()

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

Returns the global static instance.

Definition at line 1230 of file duchain.cpp.

◆ shutdown

void KDevelop::DUChain::shutdown ( )
slot

Shutdown and cleanup the DUChain.

Definition at line 1715 of file duchain.cpp.

◆ storeToDisk()

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 1864 of file duchain.cpp.

◆ updateContextEnvironment()

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 1294 of file duchain.cpp.

◆ updateContextForUrl()

void KDevelop::DUChain::updateContextForUrl ( const IndexedString &  document,
TopDUContext::Features  minFeatures,
QObject *  notifyReady = nullptr,
int  priority = 1 
) 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 asynchronously once the update is ready. If the context is already up to date, the given QObject is notified directly.

Parameters
documentDocument to update
minFeaturesThe 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.
notifyReadyAn 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. The duchain will not be locked when updateReady is called.
priorityAn optional priority for the job. The lower the value, the higher it's priority.
Note
The duchain must not be locked when this is called!

Start a parse-job for the given document

Definition at line 1839 of file duchain.cpp.

◆ updateReady

void KDevelop::DUChain::updateReady ( const KDevelop::IndexedString &  url,
const KDevelop::ReferencedTopDUContext &  topContext 
)
signal

This signal is emitted whenever the DUChain data associated with url was updated.

You can connect to this signal to get notified when the DUChain for a given file was updated.

◆ urlForIndex()

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 1399 of file duchain.cpp.

◆ uses()

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 1689 of file duchain.cpp.

◆ waitForUpdate()

KDevelop::ReferencedTopDUContext KDevelop::DUChain::waitForUpdate ( const KDevelop::IndexedString &  document,
KDevelop::TopDUContext::Features  minFeatures,
bool  proxyContext = 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
documentThe document to update
minFeaturesThe 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
Note
The duchain must not be locked when this is called!

Definition at line 1812 of file duchain.cpp.


The documentation for this class was generated from the following files:
  • duchain.h
  • duchain.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 09:40:52 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

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

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal