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

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
indexedducontext.cpp
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2006 Hamish Rodda <[email protected]>
3  Copyright 2007-2009 David Nolden <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18  */
19 
20 #include "indexedducontext.h"
21 
22 #include "ducontext.h"
23 #include "ducontextdata.h"
24 #include "ducontextdynamicdata.h"
25 #include "topducontext.h"
26 #include "duchain.h"
27 #include "topducontextdynamicdata.h"
28 
29 using namespace KDevelop;
30 
31 IndexedDUContext::IndexedDUContext(uint topContext, uint contextIndex)
32  : m_topContext(topContext)
33  , m_contextIndex(contextIndex)
34 {
35 }
36 
37 IndexedDUContext::IndexedDUContext(DUContext* ctx)
38 {
39  if (ctx) {
40  m_topContext = ctx->topContext()->ownIndex();
41  m_contextIndex = ctx->m_dynamicData->m_indexInTopContext;
42  } else {
43  m_topContext = 0;
44  m_contextIndex = 0;
45  }
46 }
47 
48 IndexedTopDUContext IndexedDUContext::indexedTopContext() const
49 {
50  if (isDummy()) {
51  return IndexedTopDUContext();
52  }
53  return IndexedTopDUContext(m_topContext);
54 }
55 
56 DUContext* IndexedDUContext::context() const
57 {
58  if (isDummy())
59  return nullptr;
60 // ENSURE_CHAIN_READ_LOCKED
61  if (!m_topContext)
62  return nullptr;
63 
64  TopDUContext* ctx = DUChain::self()->chainForIndex(m_topContext);
65  if (!ctx)
66  return nullptr;
67 
68  if (!m_contextIndex)
69  return ctx;
70 
71  return ctx->m_dynamicData->contextForIndex(m_contextIndex);
72 }
KDevelop::DUContextDynamicData::m_indexInTopContext
uint m_indexInTopContext
Definition: ducontextdynamicdata.h:78
KDevelop::IndexedTopDUContext
Allows simple indirect access to top-contexts with on-demand loading.
Definition: indexedtopducontext.h:35
KDevelop::DUChain::chainForIndex
TopDUContext * chainForIndex(uint index)
Returns the top-context that has the given index assigned, or zero if it doesn't exist.
Definition: duchain.h:177
KDevelop::TopDUContext::ownIndex
uint ownIndex() const
Definition: topducontext.cpp:537
KDevelop::TopDUContextDynamicData::contextForIndex
DUContext * contextForIndex(uint index) const
Definition: topducontextdynamicdata.cpp:836
ducontextdynamicdata.h
KDevelop::IndexedDUContext::context
DUContext * context() const
Duchain must be read locked.
Definition: indexedducontext.cpp:56
topducontext.h
KDevelop::DUContext::topContext
TopDUContext * topContext() const override
Find the top context.
Definition: ducontext.cpp:1499
ducontextdata.h
KDevelop::TopDUContext
The top context in a definition-use chain for one source file.
Definition: topducontext.h:113
KDevelop::IndexedDUContext::indexedTopContext
IndexedTopDUContext indexedTopContext() const
Definition: indexedducontext.cpp:48
KDevelop::IndexedDUContext::IndexedDUContext
IndexedDUContext(DUContext *decl)
Definition: indexedducontext.cpp:37
topducontextdynamicdata.h
duchain.h
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::IndexedDUContext::isDummy
bool isDummy() const
Definition: indexedducontext.h:104
KDevelop::DUContext
A single context in source code, represented as a node in a directed acyclic graph.
Definition: ducontext.h:72
ducontext.h
KDevelop::TopDUContext::m_dynamicData
class TopDUContextDynamicData * m_dynamicData
Definition: topducontext.h:381
indexedducontext.h
KDevelop::DUChain::self
static DUChain * self()
Returns the global static instance.
Definition: duchain.cpp:1230
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