| 181 | } |
| 182 | |
| 183 | bool DocumentClassesFolder::updateDocument(const KDevelop::IndexedString& a_file) |
| 184 | { |
| 185 | uint codeModelItemCount = 0; |
| 186 | const CodeModelItem* codeModelItems; |
| 187 | CodeModel::self().items(a_file, codeModelItemCount, codeModelItems); |
| 188 | |
| 189 | // List of declared namespaces in this file. |
| 190 | QSet<QualifiedIdentifier> declaredNamespaces; |
| 191 | |
| 192 | // List of removed classes - it initially contains all the known classes, we'll eliminate them |
| 193 | // one by one later on when we encounter them in the document. |
| 194 | QMap<IndexedQualifiedIdentifier, FileIterator> removedClasses; |
| 195 | { |
| 196 | std::pair<FileIterator, FileIterator> range = m_openFilesClasses.get<FileIndex>().equal_range(a_file); |
| 197 | for (FileIterator iter = range.first; |
| 198 | iter != range.second; |
| 199 | ++iter) { |
| 200 | removedClasses.insert(iter->classIdentifier, iter); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | bool documentChanged = false; |
| 205 | |
| 206 | for (uint codeModelItemIndex = 0; codeModelItemIndex < codeModelItemCount; ++codeModelItemIndex) { |
| 207 | const CodeModelItem& item = codeModelItems[codeModelItemIndex]; |
| 208 | |
| 209 | // Don't insert unknown or forward declarations into the class browser |
| 210 | if (item.kind == CodeModelItem::Unknown || (item.kind & CodeModelItem::ForwardDeclaration)) |
| 211 | continue; |
| 212 | |
| 213 | KDevelop::QualifiedIdentifier id = item.id.identifier(); |
| 214 | |
| 215 | // Don't add empty identifiers. |
| 216 | if (id.count() == 0) |
| 217 | continue; |
| 218 | |
| 219 | // If it's a namespace, create it in the list. |
| 220 | if (item.kind & CodeModelItem::Namespace) { |
| 221 | // This should create the namespace folder and add it to the cache. |
| 222 | namespaceFolder(id); |
| 223 | |
| 224 | // Add to the locally created namespaces. |
| 225 | declaredNamespaces.insert(id); |
| 226 | } else if (item.kind & CodeModelItem::Class) { |
| 227 | // Ignore empty unnamed classes. |
| 228 | if (id.last().toString().isEmpty()) |
| 229 | continue; |
| 230 | |
| 231 | // See if it matches our filter? |
| 232 | if (isClassFiltered(id)) |
| 233 | continue; |
| 234 | |
| 235 | // Is this a new class or an existing class? |
| 236 | const auto classIt = removedClasses.find(id); |
| 237 | if (classIt != removedClasses.end()) { |
| 238 | // It already exist - remove it from the known classes and continue. |
| 239 | removedClasses.erase(classIt); |
| 240 | continue; |
nothing calls this directly
no test coverage detected