• 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
duchain.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2006-2008 Hamish Rodda <[email protected]>
3  Copyright 2007-2008 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 #ifndef KDEVPLATFORM_DUCHAIN_H
21 #define KDEVPLATFORM_DUCHAIN_H
22 
23 #include <QObject>
24 
25 #include "topducontext.h"
26 #include "parsingenvironment.h"
27 
28 #include <interfaces/isessionlock.h>
29 
30 class QUrl;
31 
32 namespace KDevelop {
33 class IDocument;
34 class TopDUContext;
35 class DUChainLock;
36 
37 class ParsingEnvironmentManager;
38 class ParsingEnvironment;
39 class ParsingEnvironmentFile;
40 using ParsingEnvironmentFilePointer = QExplicitlySharedDataPointer<ParsingEnvironmentFile>;
41 class Definitions;
42 class Uses;
43 
54 class KDEVPLATFORMLANGUAGE_EXPORT DUChain
55  : public QObject
56 {
57  Q_OBJECT
58 
59 public:
64  static void initialize();
65 
69  QList<TopDUContext*> allChains() const;
70 
88  void updateContextForUrl(const IndexedString& document, TopDUContext::Features minFeatures,
89  QObject* notifyReady = nullptr, int priority = 1) const;
90 
102  KDevelop::ReferencedTopDUContext waitForUpdate(const KDevelop::IndexedString& document,
103  KDevelop::TopDUContext::Features minFeatures,
104  bool proxyContext = false);
105 
113  TopDUContext* chainForDocument(const QUrl& document, bool proxyContext = false) const;
114  TopDUContext* chainForDocument(const IndexedString& document, bool proxyContext = false) const;
115 
120  QList<TopDUContext*> chainsForDocument(const QUrl& document) const;
121 
127  QList<TopDUContext*> chainsForDocument(const IndexedString& document) const;
128 
136  TopDUContext* chainForDocument(const QUrl& document, const ParsingEnvironment* environment,
137  bool proxyContext = false) const;
138 
148  TopDUContext* chainForDocument(const IndexedString& document, const ParsingEnvironment* environment,
149  bool proxyContext = false) const;
150 
163  ParsingEnvironmentFilePointer environmentFileForDocument(const IndexedString& document,
164  const ParsingEnvironment* environment,
165  bool proxyContext = false) const;
166 
167  ParsingEnvironmentFilePointer environmentFileForDocument(IndexedTopDUContext topContext) const;
168 
172  QList<ParsingEnvironmentFilePointer> allEnvironmentFiles(const IndexedString& document);
173 
177  inline TopDUContext* chainForIndex(uint index)
178  {
179  if (m_deleted)
180  return nullptr;
181 
182  {
183  QMutexLocker lock(&chainsByIndexLock);
184 
185  if (chainsByIndex.size() > index) {
186  TopDUContext* top = chainsByIndex[index];
187  if (top)
188  return top;
189  }
190  }
191 
192  //Load the top-context
193  return loadChain(index);
194  }
195 
197  IndexedString urlForIndex(uint index) const;
198 
200  QList<QUrl> documents() const;
201 
204  QList<IndexedString> indexedDocuments() const;
205 
209  void addDocumentChain(TopDUContext* chain);
210 
212  static bool deleted();
213 
215  static DUChain* self();
216 
218  static Definitions* definitions();
219 
221  static Uses* uses();
222 
223  static QString repositoryPathForSession(const KDevelop::ISessionLock::Ptr& session);
224 
235  static DUChainLock* lock();
236 
238  bool isInMemory(uint topContextIndex) const;
239 
243  void updateContextEnvironment(TopDUContext* context, ParsingEnvironmentFile* file);
244 
246  static uint newTopContextIndex();
247 
250  void disablePersistentStorage(bool disable = true);
251 
254  void storeToDisk();
255 
260  bool compareToDisk();
261 
262 Q_SIGNALS:
264  void declarationSelected(const KDevelop::DeclarationPointer& decl);
265 
271  void updateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& topContext);
272 
273 public Q_SLOTS:
275  void removeDocumentChain(KDevelop::TopDUContext* document);
277  void emitDeclarationSelected(const KDevelop::DeclarationPointer& decl);
278 
284  void emitUpdateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& topContext);
285 
289  void shutdown();
290 
291 private Q_SLOTS:
292  void documentActivated(KDevelop::IDocument* doc);
293  void documentLoadedPrepare(KDevelop::IDocument* document);
294  void documentRenamed(KDevelop::IDocument* document);
295  void documentClosed(KDevelop::IDocument*);
296 
297 private:
298  TopDUContext* loadChain(uint index);
299  //These two are exported here so that the extremely frequently called chainForIndex(..) can be inlined
300  static bool m_deleted;
301  static std::vector<TopDUContext*> chainsByIndex;
302  static QMutex chainsByIndexLock;
303 
307  void refCountUp(TopDUContext* top);
308 
311  void refCountDown(TopDUContext* top);
312 
313  void addToEnvironmentManager(TopDUContext* chain);
314  void removeFromEnvironmentManager(TopDUContext* chain);
315  DUChain();
316  ~DUChain() override;
317 
318  friend class DUChainPrivate;
319  friend class ReferencedTopDUContext;
320 };
321 }
322 
323 #endif // KDEVPLATFORM_DUCHAIN_H
KDevelop::IndexedTopDUContext
Allows simple indirect access to top-contexts with on-demand loading.
Definition: indexedtopducontext.h:35
QMutex
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
QUrl
KDevelop::ReferencedTopDUContext
KDevelop can unload unused top-context at any time.
Definition: topducontext.h:59
KDevelop::Definitions
Global mapping of one Declaration-Ids to multiple Definitions, protected through DUChainLock.
Definition: definitions.h:40
KDevelop::DUChainPointer< Declaration >
QList
topducontext.h
KDevelop::DUChainLock
Customized read/write locker for the definition-use chain.
Definition: duchainlock.h:53
QExplicitlySharedDataPointer
Definition: topducontext.h:28
QObject
QString
KDevelop::ParsingEnvironment
Use this as base-class to define new parsing-environments.
Definition: parsingenvironment.h:79
KDevelop::TopDUContext
The top context in a definition-use chain for one source file.
Definition: topducontext.h:113
KDevelop::ParsingEnvironmentFile
This represents all information about a specific parsed file that is needed to match the file to a pa...
Definition: parsingenvironment.h:118
KDevelop::Uses
Global mapping of Declaration-Ids to top-contexts, protected through DUChainLock.
Definition: uses.h:37
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
QMutexLocker
parsingenvironment.h
KDevelop::DUChain
Holds references to all top level source file contexts.
Definition: duchain.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Apr 14 2021 23:30:27 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