• 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
persistentsymboltable.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2008 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KDEVPLATFORM_PERSISTENTSYMBOLTABLE_H
20 #define KDEVPLATFORM_PERSISTENTSYMBOLTABLE_H
21 
22 #include <util/convenientfreelist.h>
23 #include <language/util/setrepository.h>
24 #include <language/languageexport.h>
25 #include "indexeddeclaration.h"
26 #include "ducontext.h"
27 #include "topducontext.h"
28 
29 namespace KDevelop {
30 class Declaration;
31 class IndexedDeclaration;
32 class IndexedDUContext;
33 class DeclarationId;
34 class TopDUContext;
35 class IndexedQualifiedIdentifier;
36 class PersistentSymbolTablePrivate;
37 
39 class KDEVPLATFORMLANGUAGE_EXPORT IndexedDeclarationHandler
40 {
41 public:
42  inline static int leftChild(const IndexedDeclaration& m_data)
43  {
44  return (( int )(m_data.dummyData().first)) - 1;
45  }
46  inline static void setLeftChild(IndexedDeclaration& m_data, int child)
47  {
48  m_data.setDummyData(qMakePair(( uint )(child + 1), m_data.dummyData().second));
49  }
50  inline static int rightChild(const IndexedDeclaration& m_data)
51  {
52  return (( int )m_data.dummyData().second) - 1;
53  }
54  inline static void setRightChild(IndexedDeclaration& m_data, int child)
55  {
56  m_data.setDummyData(qMakePair(m_data.dummyData().first, ( uint )(child + 1)));
57  }
58  inline static void createFreeItem(IndexedDeclaration& data)
59  {
60  data = IndexedDeclaration();
61  data.setIsDummy(true);
62  data.setDummyData(qMakePair(0u, 0u)); //Since we subtract 1, this equals children -1, -1
63  }
64  //Copies this item into the given one
65  inline static void copyTo(const IndexedDeclaration& m_data, IndexedDeclaration& data)
66  {
67  data = m_data;
68  }
69 
70  inline static bool isFree(const IndexedDeclaration& m_data)
71  {
72  return m_data.isDummy();
73  }
74 
75  inline static bool equals(const IndexedDeclaration& m_data, const IndexedDeclaration& rhs)
76  {
77  return m_data == rhs;
78  }
79 };
80 
81 struct DeclarationTopContextExtractor
82 {
83  inline static IndexedTopDUContext extract(const IndexedDeclaration& decl)
84  {
85  return decl.indexedTopContext();
86  }
87 };
88 
89 struct DUContextTopContextExtractor
90 {
91  inline static IndexedTopDUContext extract(const IndexedDUContext& ctx)
92  {
93  return ctx.indexedTopContext();
94  }
95 };
96 
97 struct KDEVPLATFORMLANGUAGE_EXPORT RecursiveImportCacheRepository
98 {
99  static Utils::BasicSetRepository* repository();
100 };
101 
105 class KDEVPLATFORMLANGUAGE_EXPORT PersistentSymbolTable
106 {
107 public:
109  PersistentSymbolTable();
111  ~PersistentSymbolTable();
112 
115  void addDeclaration(const IndexedQualifiedIdentifier& id, const IndexedDeclaration& declaration);
116 
119  void removeDeclaration(const IndexedQualifiedIdentifier& id, const IndexedDeclaration& declaration);
120 
126  void declarations(const IndexedQualifiedIdentifier& id, uint& count, const IndexedDeclaration*& declarations) const;
127 
128  using Declarations = ConstantConvenientEmbeddedSet<IndexedDeclaration, IndexedDeclarationHandler>;
129 
134  Declarations declarations(const IndexedQualifiedIdentifier& id) const;
135 
136  using CachedIndexedRecursiveImports =
137  Utils::StorableSet<IndexedTopDUContext, IndexedTopDUContextIndexConversion, RecursiveImportCacheRepository,
138  true>;
139 
140  using FilteredDeclarationIterator =
141  ConvenientEmbeddedSetTreeFilterIterator<IndexedDeclaration, IndexedDeclarationHandler, IndexedTopDUContext,
142  CachedIndexedRecursiveImports, DeclarationTopContextExtractor>;
146  FilteredDeclarationIterator filteredDeclarations(const IndexedQualifiedIdentifier& id,
147  const TopDUContext::IndexedRecursiveImports& visibility) const;
148 
149  static PersistentSymbolTable& self();
150 
151  //Very expensive: Checks for problems in the symbol table
152  void dump(const QTextStream& out);
153 
154  //Clears the internal cache. Should be called regularly to save memory
155  //The duchain must be read-locked
156  void clearCache();
157 
158 private:
159  // cannot use QScopedPointer yet, see comment in ~PersistentSymbolTable()
160  class PersistentSymbolTablePrivate* const d_ptr;
161  Q_DECLARE_PRIVATE(PersistentSymbolTable)
162 };
163 }
164 
165 #endif
KDevelop::IndexedTopDUContext
Allows simple indirect access to top-contexts with on-demand loading.
Definition: indexedtopducontext.h:35
KDevelop::IndexedDeclaration::indexedTopContext
IndexedTopDUContext indexedTopContext() const
Definition: indexeddeclaration.h:96
KDevelop::DUContextTopContextExtractor::extract
static IndexedTopDUContext extract(const IndexedDUContext &ctx)
Definition: persistentsymboltable.h:91
KDevelop::IndexedDeclarationHandler::setLeftChild
static void setLeftChild(IndexedDeclaration &m_data, int child)
Definition: persistentsymboltable.h:46
KDevelop::PersistentSymbolTable::FilteredDeclarationIterator
ConvenientEmbeddedSetTreeFilterIterator< IndexedDeclaration, IndexedDeclarationHandler, IndexedTopDUContext, CachedIndexedRecursiveImports, DeclarationTopContextExtractor > FilteredDeclarationIterator
Definition: persistentsymboltable.h:142
KDevelop::IndexedDeclaration::setDummyData
void setDummyData(QPair< uint, uint > data)
Definition: indexeddeclaration.h:140
KDevelop::IndexedDeclarationHandler::equals
static bool equals(const IndexedDeclaration &m_data, const IndexedDeclaration &rhs)
Definition: persistentsymboltable.h:75
KDevelop::RecursiveImportCacheRepository
Definition: persistentsymboltable.h:97
KDevelop::IndexedDeclarationHandler::createFreeItem
static void createFreeItem(IndexedDeclaration &data)
Definition: persistentsymboltable.h:58
KDevelop::IndexedDeclaration::setIsDummy
void setIsDummy(bool dummy)
The following functions allow storing 2 integers in this object and marking it as a dummy,...
Definition: indexeddeclaration.h:111
KDevelop::TopDUContext::IndexedRecursiveImports
Utils::StorableSet< IndexedTopDUContext, IndexedTopDUContextIndexConversion, RecursiveImportRepository, true > IndexedRecursiveImports
Definition: topducontext.h:290
topducontext.h
KDevelop::IndexedQualifiedIdentifier
A helper-class to store an identifier by index in a type-safe way.
Definition: identifier.h:95
KDevelop::IndexedDeclarationHandler::setRightChild
static void setRightChild(IndexedDeclaration &m_data, int child)
Definition: persistentsymboltable.h:54
KDevelop::IndexedDeclaration
Represents a declaration only by its global indices.
Definition: indexeddeclaration.h:33
KDevelop::IndexedDeclaration::dummyData
QPair< uint, uint > dummyData() const
Definition: indexeddeclaration.h:129
KDevelop::IndexedDeclarationHandler
Definition: persistentsymboltable.h:39
KDevelop::IndexedDeclaration::isDummy
bool isDummy() const
Definition: indexeddeclaration.h:122
QTextStream
KDevelop::DeclarationTopContextExtractor
Definition: persistentsymboltable.h:81
KDevelop::IndexedDeclarationHandler::rightChild
static int rightChild(const IndexedDeclaration &m_data)
Definition: persistentsymboltable.h:50
KDevelop::DUContextTopContextExtractor
Definition: persistentsymboltable.h:89
KDevelop::IndexedDeclarationHandler::isFree
static bool isFree(const IndexedDeclaration &m_data)
Definition: persistentsymboltable.h:70
KDevelop::IndexedDUContext::indexedTopContext
IndexedTopDUContext indexedTopContext() const
Definition: indexedducontext.cpp:48
KDevelop::IndexedDeclarationHandler::copyTo
static void copyTo(const IndexedDeclaration &m_data, IndexedDeclaration &data)
Definition: persistentsymboltable.h:65
KDevelop::PersistentSymbolTable
Global symbol-table that is stored to disk, and allows retrieving declarations that currently are not...
Definition: persistentsymboltable.h:105
KDevelop::IndexedTopDUContextIndexConversion
Definition: indexedtopducontext.h:135
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
indexeddeclaration.h
KDevelop::DeclarationTopContextExtractor::extract
static IndexedTopDUContext extract(const IndexedDeclaration &decl)
Definition: persistentsymboltable.h:83
KDevelop::PersistentSymbolTable::Declarations
ConstantConvenientEmbeddedSet< IndexedDeclaration, IndexedDeclarationHandler > Declarations
Definition: persistentsymboltable.h:128
ducontext.h
KDevelop::IndexedDeclarationHandler::leftChild
static int leftChild(const IndexedDeclaration &m_data)
Definition: persistentsymboltable.h:42
KDevelop::PersistentSymbolTable::CachedIndexedRecursiveImports
Utils::StorableSet< IndexedTopDUContext, IndexedTopDUContextIndexConversion, RecursiveImportCacheRepository, true > CachedIndexedRecursiveImports
Definition: persistentsymboltable.h:138
KDevelop::IndexedDUContext
Represents a context only by its global indices.
Definition: indexedducontext.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:37:28 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