MCPcopy Create free account
hub / github.com/KDE/kdevelop / EnvironmentInformationRequest

Class EnvironmentInformationRequest

kdevplatform/language/duchain/duchain.cpp:122–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120};
121
122class EnvironmentInformationRequest
123{
124public:
125
126 ///This constructor should only be used for lookup
127 EnvironmentInformationRequest(uint topContextIndex) : m_file(nullptr)
128 , m_index(topContextIndex)
129 {
130 }
131
132 EnvironmentInformationRequest(const ParsingEnvironmentFile* file) : m_file(file)
133 , m_index(file->indexedTopContext().index())
134 {
135 }
136
137 enum {
138 AverageSize = 32 //This should be the approximate average size of an Item
139 };
140
141 unsigned int hash() const
142 {
143 return m_index;
144 }
145
146 uint itemSize() const
147 {
148 return sizeof(EnvironmentInformationItem) + DUChainItemSystem::self().dynamicSize(*m_file->d_func());
149 }
150
151 void createItem(EnvironmentInformationItem* item) const
152 {
153 new (item) EnvironmentInformationItem(m_index, DUChainItemSystem::self().dynamicSize(*m_file->d_func()));
154 Q_ASSERT(m_file->d_func()->m_dynamic);
155 auto* data =
156 reinterpret_cast<DUChainBaseData*>(reinterpret_cast<char*>(item) + sizeof(EnvironmentInformationItem));
157 DUChainItemSystem::self().copy(*m_file->d_func(), *data, true);
158 Q_ASSERT(data->m_range == m_file->d_func()->m_range);
159 Q_ASSERT(data->classId == m_file->d_func()->classId);
160 Q_ASSERT(data->m_dynamic == false);
161 }
162
163 static void destroy(EnvironmentInformationItem* item, KDevelop::AbstractItemRepository&)
164 {
165 item->~EnvironmentInformationItem();
166 //We don't need to call the destructor, because that's done in DUChainBase::makeDynamic()
167 //We just need to make sure that every environment-file is dynamic when it's deleted
168// DUChainItemSystem::self().callDestructor((DUChainBaseData*)(((char*)item) + sizeof(EnvironmentInformationItem)));
169 }
170
171 static bool persistent(const EnvironmentInformationItem*)
172 {
173 //Cleanup done separately
174 return true;
175 }
176
177 bool equals(const EnvironmentInformationItem* item) const
178 {
179 return m_index == item->m_topContext;

Callers 1

loadInformationMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected