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

language/duchain

KDevelop::DUContext

KDevelop::DUContext Class Reference

A single context in source code, represented as a node in a directed acyclic graph. More...

#include <ducontext.h>

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

List of all members.

Classes

struct  Import
 Represents an imported parent context. More...
struct  SearchItem
 Represents multiple qualified identifiers in a way that is better to manipulate and allows applying namespace-aliases or -imports easily. More...

Public Types

enum  { Identity = 2 }
enum  ContextType {
  Global, Namespace, Class, Function,
  Template, Enum, Helper, Other
}
typedef KDevVarLengthArray
< Declaration *, 40 > 
DeclarationList
enum  SearchFlag {
  NoSearchFlags = 0, InImportedParentContext = 1, OnlyContainerTypes = 2, DontSearchInParent = 4,
  NoUndefinedTemplateParams = 8, DirectQualifiedLookup = 16, NoFiltering = 32, OnlyFunctions = 64,
  NoImportsCheck = 128
}

Public Member Functions

 DUContext (DUContextData &)
 DUContext (const SimpleRange &range, DUContext *parent=0, bool anonymous=false)
virtual ~DUContext ()
virtual void addImportedParentContext (DUContext *context, const SimpleCursor &position=SimpleCursor::invalid(), bool anonymous=false, bool temporary=false)
bool addIndirectImport (const DUContext::Import &import)
QList< QPair< Declaration
*, int > > 
allDeclarations (const SimpleCursor &position, const TopDUContext *topContext, bool searchInParents=true) const
QList< Declaration * > allLocalDeclarations (const Identifier &identifier) const
void changingIdentifier (Declaration *decl, const Identifier &from, const Identifier &to)
QVector< DUContext * > childContexts () const
void cleanIfNotEncountered (const QSet< DUChainBase * > &encountered)
virtual void clearImportedParentContexts ()
QVector< Declaration * > clearLocalDeclarations ()
void clearUseSmartRanges ()
virtual QWidget * createNavigationWidget (Declaration *decl=0, TopDUContext *topContext=0, const QString &htmlPrefix=QString(), const QString &htmlSuffix=QString()) const
int createUse (int declarationIndex, const SimpleRange &range, KTextEditor::SmartRange *smartRange, int insertBefore=-1)
void deleteChildContextsRecursively ()
void deleteLocalDeclarations ()
void deleteUse (int index)
virtual void deleteUses ()
int depth () const
bool equalScopeIdentifier (const DUContext *rhs) const
DUContext * findContext (const SimpleCursor &position, DUContext *parent=0) const
DUContext * findContextAt (const SimpleCursor &position, bool includeBorders=false) const
DUContext * findContextIncluding (const SimpleRange &range) const
QList< DUContext * > findContexts (ContextType contextType, const QualifiedIdentifier &identifier, const SimpleCursor &position=SimpleCursor::invalid(), const TopDUContext *source=0, SearchFlags flags=NoSearchFlags) const
Declaration * findDeclarationAt (const SimpleCursor &position) const
QList< Declaration * > findDeclarations (const Identifier &identifier, const SimpleCursor &position=SimpleCursor::invalid(), const TopDUContext *topContext=0, SearchFlags flags=NoSearchFlags) const
QList< Declaration * > findDeclarations (const QualifiedIdentifier &identifier, const SimpleCursor &position=SimpleCursor::invalid(), const AbstractType::Ptr &dataType=AbstractType::Ptr(), const TopDUContext *topContext=0, SearchFlags flags=NoSearchFlags) const
virtual bool findDeclarationsInternal (const SearchItem::PtrList &identifiers, const SimpleCursor &position, const AbstractType::Ptr &dataType, DeclarationList &ret, const TopDUContext *source, SearchFlags flags, uint depth) const
QList< Declaration * > findLocalDeclarations (const Identifier &identifier, const SimpleCursor &position=SimpleCursor::invalid(), const TopDUContext *topContext=0, const AbstractType::Ptr &dataType=AbstractType::Ptr(), SearchFlags flags=NoSearchFlags) const
int findUseAt (const SimpleCursor &position) const
QList< QualifiedIdentifier > fullyApplyAliases (KDevelop::QualifiedIdentifier id, const KDevelop::TopDUContext *source) const
virtual QVector< Import > importedParentContexts () const
virtual QVector< DUContext * > importers () const
virtual SimpleCursor importPosition (const DUContext *target) const
virtual bool imports (const DUContext *origin, const SimpleCursor &position=SimpleCursor::invalid()) const
KDevVarLengthArray
< IndexedDUContext > 
indexedImporters () const
IndexedQualifiedIdentifier indexedLocalScopeIdentifier () const
virtual bool inDUChain () const
bool inSymbolTable () const
bool isPropagateDeclarations () const
virtual QVector< Declaration * > localDeclarations (const TopDUContext *source=0) const
QualifiedIdentifier localScopeIdentifier () const
Declaration * owner () const
DUContext * parentContext () const
bool parentContextOf (DUContext *context) const
virtual void removeImportedParentContext (DUContext *context)
QualifiedIdentifier scopeIdentifier (bool includeClasses=false) const
void setInSymbolTable (bool inSymbolTable)
void setLocalScopeIdentifier (const QualifiedIdentifier &identifier)
void setOwner (Declaration *decl)
void setPropagateDeclarations (bool propagate)
void setType (ContextType type)
void setUseDeclaration (int useIndex, int declarationIndex)
void setUseSmartRange (int useIndex, KTextEditor::SmartRange *range)
virtual DUContext * specialize (IndexedInstantiationInformation specialization, const TopDUContext *topContext, int upDistance=0)
void squeeze ()
QVector
< KTextEditor::SmartRange * > 
takeUseRanges ()
virtual TopDUContext * topContext () const
ContextType type () const
QVector
< KTextEditor::SmartRange * > 
useRanges ()
const Use * uses () const
int usesCount () const
KTextEditor::SmartRange * useSmartRange (int useIndex)

Protected Member Functions

 DUContext (DUContext &useDataFrom)
 DUContext (DUContextData &dd, const SimpleRange &range, DUContext *parent=0, bool anonymous=false)
void applyAliases (const SearchItem::PtrList &identifiers, SearchItem::PtrList &targetIdentifiers, const SimpleCursor &position, bool canBeNamespace, bool onlyImports=false) const
virtual void applyUpwardsAliases (SearchItem::PtrList &identifiers, const TopDUContext *source) const
virtual void findContextsInternal (ContextType contextType, const SearchItem::PtrList &identifiers, const SimpleCursor &position, QList< DUContext * > &ret, const TopDUContext *source, SearchFlags flags=NoSearchFlags) const
virtual void findLocalDeclarationsInternal (const Identifier &identifier, const SimpleCursor &position, const AbstractType::Ptr &dataType, DeclarationList &ret, const TopDUContext *source, SearchFlags flags) const
virtual bool foundEnough (const DeclarationList &decls, SearchFlags flags) const
bool isAnonymous () const
virtual void mergeDeclarationsInternal (QList< QPair< Declaration *, int > > &definitions, const SimpleCursor &position, QHash< const DUContext *, bool > &hadContexts, const TopDUContext *source, bool searchInParents=true, int currentDepth=0) const
QualifiedIdentifier scopeIdentifierInternal (DUContext *context) const
virtual bool shouldSearchInParent (SearchFlags flags) const

Detailed Description

A single context in source code, represented as a node in a directed acyclic graph.

Access to context objects must be serialised by holding the chain lock, ie. DUChain::lock().

NOTE: A du-context can be freely edited as long as it's parent-context is zero. In the moment the parent-context is set, the context may only be edited when it is allowed to edited it's top-level context(

See also:
TopLevelContext::inDUChain()
Todo:
change child relationships to a linked list within the context?

Definition at line 210 of file ducontext.h.


Member Typedef Documentation

typedef KDevVarLengthArray<Declaration*, 40> KDevelop::DUContext::DeclarationList

This is a more complex interface to the declaration search engine.

Todo:
Should be protected, moved here temporarily until I have figured out why the gcc 4.1.3 fails in cppducontext.h:212, which should work (within kdevelop) Declaration search implementation

Always prefer findDeclarations(..) when possible. Advantage of this interface:

  • You can search multiple identifiers at one time. However, those should be aliased identifiers for one single item, because search might stop as soon as one item is found.
  • The source top-context is needed to correctly resolve template-parameters
    Parameters:
    position A valid position, if in doubt use textRange().end()
    depth Depth of the search in parents. This is used to prevent endless recursions in endless import loops.
    Warning:
    position Must be valid!
    Returns:
    whether the search was successful. If it is false, it had to be stopped for special reasons(like some flags)

Definition at line 776 of file ducontext.h.


Member Enumeration Documentation

enum KDevelop::DUContext::ContextType
Enumerator:
Global 

A context that declares functions, namespaces or classes.

Namespace 

A context that declares namespace members.

Class 

A context that declares class members.

Function 

A context that declares function-arguments.

Template 

A context that declares template-parameters.

Enum 

A context that contains a list of enumerators.

Helper 

A helper context.

This context is treated specially during search: when searching within the imports of a context, and that context's parent is a context of type DUContext::Helper, then the upwards search is continued into that helper(The decision happens in shouldSearchInParent)

Other 

Represents executable code, like for example within a compound-statement.

Definition at line 237 of file ducontext.h.

enum KDevelop::DUContext::SearchFlag
Enumerator:
NoSearchFlags 

Searching for everything.

InImportedParentContext 

Internal, do not use from outside.

OnlyContainerTypes 

Not implemented yet.

DontSearchInParent 

IF this flag is set, findDeclarations(.

.) will not search for the identifier in parent-contexts(which does not include imported parent-contexts)

NoUndefinedTemplateParams 

For languages that support templates(like C++).

If this is set, the search should fail as soon as undefined template-parameters are involved.

DirectQualifiedLookup 

When this flag is used, the searched qualified identifier should NOT be split up into it's components and looked up one by one.

Currently only plays a role in C++ specific parts.

NoFiltering 

Should be set when no filtering at all is wished, not even filtering that is natural for the underlying language(For example in C++, constructors are filtered out be default).

OnlyFunctions 

When this is given, only function-declarations are returned.

In case of C++, this also means that constructors can be retrieved, while normally they are filtered out.

NoImportsCheck 

With this parameter, a global search will return all matching items, from all contexts, not only from imported ones.

Definition at line 251 of file ducontext.h.


Constructor & Destructor Documentation

KDevelop::DUContext::DUContext ( const SimpleRange &  range,
DUContext *  parent = 0,
bool  anonymous = false 
) [explicit]

Constructor.

No convenience methods, as the initialisation order is important,

Parameters:
anonymous Whether the context should be added as an anonymous context to the parent. That way the context can never be found through any of the parent's member-functions.

If the parent is in the symbol table and the context is not anonymous, it will also be added to the symbol table. You nead a write-lock to the DUChain then

Definition at line 527 of file ducontext.cpp.

KDevelop::DUContext::~DUContext (  )  [virtual]

Destructor.

Will delete all child contexts which are defined within the same file as this context.

Definition at line 590 of file ducontext.cpp.

KDevelop::DUContext::DUContext ( DUContext &  useDataFrom  )  [protected]

Just uses the data from the given context(doesn't copy or change anything, and the data will not be deleted on this contexts destruction).

Definition at line 585 of file ducontext.cpp.


Member Function Documentation

void KDevelop::DUContext::addImportedParentContext ( DUContext *  context,
const SimpleCursor &  position = SimpleCursor::invalid(),
bool  anonymous = false,
bool  temporary = false 
) [virtual]

Adds an imported context.

Parameters:
anonymous If this is true, the import will not be registered at the imported context. This allows du-chain contexts importing without having a write-lock.
position Position where the context is imported. This is mainly important in C++ with included files.

If the context is already imported, only the position is updated.

Note:
Be sure to have set the text location first, so that the chain is sorted correctly.

Definition at line 958 of file ducontext.cpp.

bool KDevelop::DUContext::addIndirectImport ( const DUContext::Import &  import  ) 

Adds an imported context, which may be indirect.

Warning:
This is only allowed if this context is _NOT_ a top-context
When using this mechanism, this context will not be registered as importer to the other one.
The given import _must_ be indirect
Returns:
true if the import was already imported before, else false.

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.

Definition at line 940 of file ducontext.cpp.

QList< QPair< Declaration *, int > > KDevelop::DUContext::allDeclarations ( const SimpleCursor &  position,
const TopDUContext *  topContext,
bool  searchInParents = true 
) const

Return a list of all reachable declarations for a given cursor position in a given url.

Parameters:
location the text position to search for
topContext the top-context from where a completion is triggered. This is needed so delayed types(templates in C++) can be resolved in the correct context.
searchInParents should declarations from parent-contexts be listed? If false, only declarations from this and imported contexts will be returned.

The returned declarations are paired together with their inheritance-depth, which is the count of steps to into other contexts that were needed to find the declaration. Declarations reached through a namespace- or global-context are offsetted by 1000.

This also includes Declarations from sub-contexts that were propagated upwards using setPropagateDeclarations(true).

Returns:
the requested declarations, if any were active at that location. Declarations propagated into this context(
See also:
setPropagateDeclarations) are included.

Definition at line 1090 of file ducontext.cpp.

QList< Declaration * > KDevelop::DUContext::allLocalDeclarations ( const Identifier &  identifier  )  const

Return all declarations in this context that have the given identifier, without any filtering.

This includes declarations propagated from sub-contexts.

Definition at line 1063 of file ducontext.cpp.

void KDevelop::DUContext::applyAliases ( const SearchItem::PtrList &  identifiers,
SearchItem::PtrList &  targetIdentifiers,
const SimpleCursor &  position,
bool  canBeNamespace,
bool  onlyImports = false 
) const [protected]

Applies namespace-imports and namespace-aliases and returns possible absolute identifiers that need to be searched.

Parameters:
targetIdentifiers will be filled with all identifiers that should be searched for, instead of identifier.
onlyImports if this is true, namespace-aliases will not be respected, but only imports. This is faster.

Definition at line 1393 of file ducontext.cpp.

void KDevelop::DUContext::applyUpwardsAliases ( SearchItem::PtrList &  identifiers,
const TopDUContext *  source 
) const [protected, virtual]

Applies the aliases that need to be applied when moving the search from this context up to the parent-context.

The default-implementation adds a set of identifiers with the own local identifier prefixed, if this is a namespace. For C++, this is needed when searching out of a namespace, so the item can be found within that namespace in another place.

Definition at line 1447 of file ducontext.cpp.

void KDevelop::DUContext::changingIdentifier ( Declaration *  decl,
const Identifier &  from,
const Identifier &  to 
)

Used exclusively by Declaration, do not use this.

Definition at line 421 of file ducontext.cpp.

QVector< DUContext * > KDevelop::DUContext::childContexts (  )  const

Returns the list of immediate child contexts for this context.

Expensive.

Definition at line 639 of file ducontext.cpp.

void KDevelop::DUContext::cleanIfNotEncountered ( const QSet< DUChainBase * > &  encountered  ) 

Delete and remove all slaves(uses, declarations, definitions, contexts) that are not in the given set.

Definition at line 1738 of file ducontext.cpp.

void KDevelop::DUContext::clearImportedParentContexts (  )  [virtual]

Clear all imported parent contexts.

Reimplemented in KDevelop::TopDUContext.

Definition at line 1724 of file ducontext.cpp.

QVector< Declaration * > KDevelop::DUContext::clearLocalDeclarations (  ) 

Clears all local declarations.

Does not delete the declaration; the caller assumes ownership.

Definition at line 1212 of file ducontext.cpp.

void KDevelop::DUContext::clearUseSmartRanges (  ) 

Clears all smart ranges associated with uses.

Definition at line 1613 of file ducontext.cpp.

QWidget * KDevelop::DUContext::createNavigationWidget ( Declaration *  decl = 0,
TopDUContext *  topContext = 0,
const QString &  htmlPrefix = QString(),
const QString &  htmlSuffix = QString() 
) const [virtual]

Can be specialized by languages to create a navigation/information-widget.

Ideally, the widget would be based on KDevelop::QuickOpenEmbeddedWidgetInterface for user-interaction within the quickopen list.

The returned widget will be owned by the caller.

Parameters:
decl A member-declaration of this context the navigation-widget should be created for. Zero to create a widget for this context.
topContext Top-context from where the navigation-widget is triggered. In C++, this is needed to resolve forward-declarations.
htmlPrefix Html-formatted text that should be prepended before any information shown by this widget
htmlSuffux Html-formatted text that should be appended to any information shown by this widget

Can return zero, which the default-implementation currently always does.

Definition at line 1759 of file ducontext.cpp.

int KDevelop::DUContext::createUse ( int  declarationIndex,
const SimpleRange &  range,
KTextEditor::SmartRange *  smartRange,
int  insertBefore = -1 
)

Creates a new use of the declaration given through.

Parameters:
declarationIndex. The index must be retrieved through TopDUContext::indexForUsedDeclaration(..).
range The range of the use
smartRange The smart range, or zero if the document is not opened.
insertBefore A hint where in the vector of uses to insert the use. Must be correct so the order is preserved(ordered by position), or -1 to automatically choose the position.
Returns:
Local index of the created use

Todo:
do binary search

When this assertion triggers, then the updated context probably was not smart-converted before processing.

See also:
SmartConverter

Definition at line 1545 of file ducontext.cpp.

void KDevelop::DUContext::deleteChildContextsRecursively (  ) 

Clears and deletes all child contexts recursively.

This will not cross file boundaries.

Definition at line 1195 of file ducontext.cpp.

void KDevelop::DUContext::deleteLocalDeclarations (  ) 

Clears all local declarations.

Deletes these declarations, as the context has ownership.

Definition at line 1177 of file ducontext.cpp.

void KDevelop::DUContext::deleteUse ( int  index  ) 

Deletes the use number.

Parameters:
index . index is the position in the vector of uses, not a used declaration index.

Definition at line 1300 of file ducontext.cpp.

void KDevelop::DUContext::deleteUses (  )  [virtual]

Clear and delete all uses in this context.

Definition at line 1339 of file ducontext.cpp.

int KDevelop::DUContext::depth (  )  const

Calculate the depth of this context, from the top level context in the file.

Definition at line 518 of file ducontext.cpp.

bool KDevelop::DUContext::equalScopeIdentifier ( const DUContext *  rhs  )  const

Returns true if this context has the same scope identifier as the given one.

This is much more efficient than computing the identifiers through scopeIdentifier(..) and comparing them

Definition at line 1230 of file ducontext.cpp.

DUContext * KDevelop::DUContext::findContext ( const SimpleCursor &  position,
DUContext *  parent = 0 
) const

Searches for the most specific context for the given cursor position in the given url.

Parameters:
location the text position to search for
parent the parent context to search from (this is mostly an internal detail, but if you only want to search in a subbranch of the chain, you may specify the parent here)
Returns:
the requested context if one was found, otherwise null.

Definition at line 1031 of file ducontext.cpp.

DUContext * KDevelop::DUContext::findContextAt ( const SimpleCursor &  position,
bool  includeBorders = false 
) const

Find the context which most specifically covers position.

Parameters:
includeRightBorder When this is true, contexts will also be found that have the position on their right border. The search is recursive, so the most specific context is found.

Definition at line 1639 of file ducontext.cpp.

DUContext * KDevelop::DUContext::findContextIncluding ( const SimpleRange &  range  )  const

Find the context which most specifically covers range.

Definition at line 1671 of file ducontext.cpp.

QList< DUContext * > KDevelop::DUContext::findContexts ( ContextType  contextType,
const QualifiedIdentifier &  identifier,
const SimpleCursor &  position = SimpleCursor::invalid(),
const TopDUContext *  source = 0,
SearchFlags  flags = NoSearchFlags 
) const

Searches for the context with the given type and identifier.

Parameters:
contextType type of context to locate; usually Namespace or Class.
identifier identifier of the context which is being searched for.
position cursor position to search from, or invalid to search the whole context.
Returns:
the requested context if one was found, otherwise null.
Warning:
this may return contexts which are not in this tree, you may need to lock them too...
this function is not as far developed as findDeclarations(..), and does not respect all of the details so always use findDeclarations(..) instead when possible!

Definition at line 1381 of file ducontext.cpp.

void KDevelop::DUContext::findContextsInternal ( ContextType  contextType,
const SearchItem::PtrList &  identifiers,
const SimpleCursor &  position,
QList< DUContext * > &  ret,
const TopDUContext *  source,
SearchFlags  flags = NoSearchFlags 
) const [protected, virtual]

Context search implementation.

Todo:
This doesn't seem quite correct: Local Contexts aren't found anywhere Step 1: Apply namespace-aliases and -imports

Step 2: Give identifiers that are not marked as explicitly-global to imported contexts(explicitly global ones are treatead in TopDUContext)

Step 3: Continue search in parent

Definition at line 1475 of file ducontext.cpp.

Declaration * KDevelop::DUContext::findDeclarationAt ( const SimpleCursor &  position  )  const

Find a child declaration that has a rang that covers the given position The search is local, not recursive.

Definition at line 1657 of file ducontext.cpp.

QList< Declaration * > KDevelop::DUContext::findDeclarations ( const Identifier &  identifier,
const SimpleCursor &  position = SimpleCursor::invalid(),
const TopDUContext *  topContext = 0,
SearchFlags  flags = NoSearchFlags 
) const

Searches for and returns a declaration with a given identifier in this context, which is currently active at the given text position.

Parameters:
identifier the identifier of the definition to search for
topContext the top-context from where a completion is triggered. This is needed so delayed types(templates in C++) can be resolved in the correct context.
location the text position to search for
Returns:
the requested declaration if one was found, otherwise null.
Warning:
this may return declarations which are not in this tree, you may need to lock them too...

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1289 of file ducontext.cpp.

QList< Declaration * > KDevelop::DUContext::findDeclarations ( const QualifiedIdentifier &  identifier,
const SimpleCursor &  position = SimpleCursor::invalid(),
const AbstractType::Ptr &  dataType = AbstractType::Ptr(),
const TopDUContext *  topContext = 0,
SearchFlags  flags = NoSearchFlags 
) const

Searches for and returns a declaration with a given identifier in this context, which is currently active at the given text position, with the given type dataType.

In fact, only items are returned that are declared BEFORE that position.

Parameters:
identifier the identifier of the definition to search for
location the text position to search for
topContext the top-context from where a completion is triggered. This is needed so delayed types(templates in C++) can be resolved in the correct context.
type the type to match, or null for no type matching.
Returns:
the requested declaration if one was found, otherwise null.
Warning:
this may return declarations which are not in this tree, you may need to lock them too...

Definition at line 920 of file ducontext.cpp.

bool KDevelop::DUContext::findDeclarationsInternal ( const SearchItem::PtrList &  identifiers,
const SimpleCursor &  position,
const AbstractType::Ptr &  dataType,
DeclarationList &  ret,
const TopDUContext *  source,
SearchFlags  flags,
uint  depth 
) const [virtual]

Step 1: Apply namespace-aliases and -imports

Step 2: Give identifiers that are not marked as explicitly-global to imported contexts(explicitly global ones are treatead in TopDUContext)

Step 3: Continue search in parent-context

Definition at line 827 of file ducontext.cpp.

QList< Declaration * > KDevelop::DUContext::findLocalDeclarations ( const Identifier &  identifier,
const SimpleCursor &  position = SimpleCursor::invalid(),
const TopDUContext *  topContext = 0,
const AbstractType::Ptr &  dataType = AbstractType::Ptr(),
SearchFlags  flags = NoSearchFlags 
) const

Returns the type of any identifier defined in this context, or null if one is not found.

Does not search imported parent-contexts(like base-classes).

Definition at line 704 of file ducontext.cpp.

void KDevelop::DUContext::findLocalDeclarationsInternal ( const Identifier &  identifier,
const SimpleCursor &  position,
const AbstractType::Ptr &  dataType,
DeclarationList &  ret,
const TopDUContext *  source,
SearchFlags  flags 
) const [protected, virtual]

Todo:
This is C++-specific
Todo:
Eventually do efficient iteration-free filtering

Definition at line 723 of file ducontext.cpp.

int KDevelop::DUContext::findUseAt ( const SimpleCursor &  position  )  const

Find the use which encompasses position, if one exists.

Returns:
The local index of the use, or -1

Definition at line 1685 of file ducontext.cpp.

bool KDevelop::DUContext::foundEnough ( const DeclarationList &  decls,
SearchFlags  flags 
) const [protected, virtual]

After one scope was searched, this function is asked whether more results should be collected.

Override it, for example to collect overloaded functions. The default-implementation returns true as soon as decls is not empty.

Definition at line 820 of file ducontext.cpp.

QList< QualifiedIdentifier > KDevelop::DUContext::fullyApplyAliases ( KDevelop::QualifiedIdentifier  id,
const KDevelop::TopDUContext *  source 
) const

Returns the qualified identifier id with all aliases (for example namespace imports) applied Example: If the namespace 'Foo' is imported, and id is 'Bar', then the returned list is 'Bar' and 'FooBar'.

Definition at line 894 of file ducontext.cpp.

QVector< DUContext::Import > KDevelop::DUContext::importedParentContexts (  )  const [virtual]

Returns the list of imported parent contexts for this context.

Warning:
The list may contain objects that are not valid any more(data() returns zero),
See also:
addImportedParentContext)
Warning:
The import structure may contain loops if this is a TopDUContext, so be careful when traversing the tree. Expensive.

Reimplemented in KDevelop::TopDUContext.

Definition at line 1372 of file ducontext.cpp.

QVector< DUContext * > KDevelop::DUContext::importers (  )  const [virtual]

Returns the list of contexts importing this context.

Very expensive, since the importers top-contexts need to be loaded.

Reimplemented in KDevelop::TopDUContext.

Definition at line 1012 of file ducontext.cpp.

SimpleCursor KDevelop::DUContext::importPosition ( const DUContext *  target  )  const [virtual]

If the given context is directly imported into this one, and addImportedParentContext(.

.) was called with a valid cursor, this will return that position. Else an invalid cursor is returned.

Definition at line 1361 of file ducontext.cpp.

bool KDevelop::DUContext::imports ( const DUContext *  origin,
const SimpleCursor &  position = SimpleCursor::invalid() 
) const [virtual]

Returns true if this context imports.

Parameters:
origin at any depth, else false.

Definition at line 933 of file ducontext.cpp.

KDevVarLengthArray< IndexedDUContext > KDevelop::DUContext::indexedImporters (  )  const

Cheap, because nothing needs to be loaded.

Definition at line 1000 of file ducontext.cpp.

IndexedQualifiedIdentifier KDevelop::DUContext::indexedLocalScopeIdentifier (  )  const

Same as localScopeIdentifier, but faster.

Definition at line 1269 of file ducontext.cpp.

bool KDevelop::DUContext::inDUChain (  )  const [virtual]

Returns true if this declaration is accessible through the du-chain, and thus cannot be edited without a du-chain write lock.

Reimplemented in KDevelop::TopDUContext.

Definition at line 1349 of file ducontext.cpp.

bool KDevelop::DUContext::inSymbolTable (  )  const

Returns whether this context is listed in the symbol table (Namespaces and classes).

Definition at line 1701 of file ducontext.cpp.

bool KDevelop::DUContext::isAnonymous (  )  const [protected]

Whether this context, or any of its parent contexts, has been inserted anonymously into the du-chain(.

See also:
DUContext::DUContext)

Definition at line 558 of file ducontext.cpp.

QVector< Declaration * > KDevelop::DUContext::localDeclarations ( const TopDUContext *  source = 0  )  const [virtual]

Returns all local declarations.

Parameters:
source A source-context that is needed to instantiate template-declarations in some cases. If it is zero, that signalizes that missing members should not be instantiated.

Definition at line 1103 of file ducontext.cpp.

QualifiedIdentifier KDevelop::DUContext::localScopeIdentifier (  )  const

Scope identifier, used to qualify the identifiers occurring in each context.

This is the part relative to the parent context.

Definition at line 1262 of file ducontext.cpp.

void KDevelop::DUContext::mergeDeclarationsInternal ( QList< QPair< Declaration *, int > > &  definitions,
const SimpleCursor &  position,
QHash< const DUContext *, bool > &  hadContexts,
const TopDUContext *  source,
bool  searchInParents = true,
int  currentDepth = 0 
) const [protected, virtual]

Merges definitions and their inheritance-depth up all branches of the definition-use chain into one hash.

This includes declarations propagated from sub-contexts.

Parameters:
hadUrls is used to count together all contexts that already were visited, so they are not visited again.

Only respect the position if the parent-context is not a class(

Todo:
this is language-dependent)

Definition at line 1119 of file ducontext.cpp.

Declaration * KDevelop::DUContext::owner (  )  const

If this context was opened by a declaration or definition, this returns that item.

The returned declaration/definition will have this context set as internalContext()

Definition at line 649 of file ducontext.cpp.

DUContext * KDevelop::DUContext::parentContext (  )  const

Returns the immediate parent context of this context.

Definition at line 674 of file ducontext.cpp.

bool KDevelop::DUContext::parentContextOf ( DUContext *  context  )  const

Iterates the tree to see if the provided context is a subcontext of this context.

Returns:
true if context is a subcontext, otherwise false.

Definition at line 1050 of file ducontext.cpp.

void KDevelop::DUContext::removeImportedParentContext ( DUContext *  context  )  [virtual]

Removes a child context.

Definition at line 978 of file ducontext.cpp.

QualifiedIdentifier KDevelop::DUContext::scopeIdentifier ( bool  includeClasses = false  )  const

Calculate the fully qualified scope identifier.

Definition at line 1220 of file ducontext.cpp.

QualifiedIdentifier KDevelop::DUContext::scopeIdentifierInternal ( DUContext *  context  )  const [protected]

Logic for calculating the fully qualified scope name.

void KDevelop::DUContext::setInSymbolTable ( bool  inSymbolTable  ) 

Move this object into/out of the symbol table.

You need to have a duchain write lock, unless this is a TopDUContext.

Definition at line 1706 of file ducontext.cpp.

void KDevelop::DUContext::setLocalScopeIdentifier ( const QualifiedIdentifier &  identifier  ) 

Scope identifier, used to qualify the identifiers occurring in each context This must not be called once this context has children.

Definition at line 1251 of file ducontext.cpp.

void KDevelop::DUContext::setOwner ( Declaration *  decl  ) 

Sets the declaration/definition, and also updates it's internal context(they are strictly paired together) The declaration has to be part of the same top-context.

Definition at line 654 of file ducontext.cpp.

void KDevelop::DUContext::setPropagateDeclarations ( bool  propagate  ) 

If this is set to true, all declarations that are added to this context will also be visible in the parent-context.

They will be visible in the parent using findDeclarations(..), and findLocalDeclarations, but will not be in the list of localDeclarations(...).

Definition at line 681 of file ducontext.cpp.

void KDevelop::DUContext::setUseDeclaration ( int  useIndex,
int  declarationIndex 
)

Assigns the declaration represented by.

Parameters:
declarationIndex to the use with index
useIndex 

Definition at line 1632 of file ducontext.cpp.

void KDevelop::DUContext::setUseSmartRange ( int  useIndex,
KTextEditor::SmartRange *  range 
)

Assigns the given SmartRange to the given use.

If one use gets a smart range, all uses need to get a smart range. The ownership of the range is given to this context.

Definition at line 1589 of file ducontext.cpp.

bool KDevelop::DUContext::shouldSearchInParent ( SearchFlags  flags  )  const [protected, virtual]

This is called whenever the search needs to do the decision whether it should be continued in the parent context.

It is not called when the DontSearchInParent flag is set. Else this should be overridden to do language-specific logic. The default implementation returns false if the flag InImportedParentContext is set.

Definition at line 1526 of file ducontext.cpp.

DUContext * KDevelop::DUContext::specialize ( IndexedInstantiationInformation  specialization,
const TopDUContext *  topContext,
int  upDistance = 0 
) [virtual]

Retrieve the context which is specialized with the given specialization as seen from the given topContext.

Parameters:
specialization the specialization index (see DeclarationId)
topContext the top context to search from
upDistance upwards distance in the context-structure of the given specialization-info. This allows specializing children.

Definition at line 1357 of file ducontext.cpp.

void KDevelop::DUContext::squeeze (  ) 

Call this after parsing is finished. It will optimize the internal vectors to reduce memory-usage.

Definition at line 1764 of file ducontext.cpp.

QVector< KTextEditor::SmartRange * > KDevelop::DUContext::takeUseRanges (  ) 

Takes the smart-ranges away from the uses, without deleting them.

Definition at line 1320 of file ducontext.cpp.

TopDUContext * KDevelop::DUContext::topContext (  )  const [virtual]

Find the top context.

Reimplemented from KDevelop::DUChainBase.

Reimplemented in KDevelop::TopDUContext.

Definition at line 1754 of file ducontext.cpp.

QVector< KTextEditor::SmartRange * > KDevelop::DUContext::useRanges (  ) 

Returns the smart-ranges associated to the uses.

Definition at line 1333 of file ducontext.cpp.

const Use * KDevelop::DUContext::uses (  )  const

Uses: A "Use" represents any position in a document where a Declaration is used literally.

For efficiency, since there can be many many uses, they are managed efficiently by TopDUContext and DUContext. In TopDUContext, the used declarations are registered and assigned a "Declaration-Index" while calling TopDUContext::indexForUsedDeclaration. From such a declaration-index, the declaration can be retrieved back by calling TopDUContext::usedDeclarationForIndex.

The actual uses are stored within DUContext, where each use consists of a range and the declaration-index of the used declaration.

To save memory, smart-ranges are only attached to the uses when the document is actually loaded. Uses need to be ordered by their appearance. Return a vector of all uses which occur in this context. When the uses have smart-ranges attached, those are synced in the moment that uses() is called, so you should call this immediately before using the returned ranges, and you should hold the smart-lock while calling this if you want to compare the ranges, so you can be sure they aren't changed in the meantime. To get the actual declarations, use TopDUContext::usedDeclarationForIndex(..) with the declarationIndex.

Definition at line 1532 of file ducontext.cpp.

int KDevelop::DUContext::usesCount (  )  const

Returns the count of uses that can be accessed through uses().

Definition at line 1540 of file ducontext.cpp.

KTextEditor::SmartRange * KDevelop::DUContext::useSmartRange ( int  useIndex  ) 

Returns the SmartRange assigned to the given use, or zero.

Definition at line 1575 of file ducontext.cpp.


The documentation for this class was generated from the following files:
  • ducontext.h
  • ducontext.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