| 116 | } |
| 117 | |
| 118 | ClassNode* DocumentClassesFolder::findClassNode(const IndexedQualifiedIdentifier& a_id) |
| 119 | { |
| 120 | // Make sure that the classes node is populated, otherwise |
| 121 | // the lookup will not work. |
| 122 | performPopulateNode(); |
| 123 | |
| 124 | ClassIdentifierIterator iter = m_openFilesClasses.get<ClassIdentifierIndex>().find(a_id); |
| 125 | if (iter == m_openFilesClasses.get<ClassIdentifierIndex>().end()) |
| 126 | return nullptr; |
| 127 | |
| 128 | // If the node is invisible - make it visible by going over the identifiers list. |
| 129 | if (iter->nodeItem == nullptr) { |
| 130 | QualifiedIdentifier qualifiedIdentifier = a_id.identifier(); |
| 131 | |
| 132 | // Ignore zero length identifiers. |
| 133 | if (qualifiedIdentifier.count() == 0) |
| 134 | return nullptr; |
| 135 | |
| 136 | ClassNode* closestNode = nullptr; |
| 137 | int closestNodeIdLen = qualifiedIdentifier.count(); |
| 138 | |
| 139 | // First find the closest visible class node by reverse iteration over the id list. |
| 140 | while ((closestNodeIdLen > 0) && (closestNode == nullptr)) { |
| 141 | // Omit one from the end. |
| 142 | --closestNodeIdLen; |
| 143 | |
| 144 | // Find the closest class. |
| 145 | closestNode = findClassNode(qualifiedIdentifier.mid(0, closestNodeIdLen)); |
| 146 | } |
| 147 | |
| 148 | if (closestNode != nullptr) { |
| 149 | // Start iterating forward from this node by exposing each class. |
| 150 | // By the end of this loop, closestNode should hold the actual node. |
| 151 | while (closestNode && (closestNodeIdLen < qualifiedIdentifier.count())) { |
| 152 | // Try the next Id. |
| 153 | ++closestNodeIdLen; |
| 154 | closestNode = closestNode->findSubClass(qualifiedIdentifier.mid(0, closestNodeIdLen)); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | return closestNode; |
| 159 | } |
| 160 | |
| 161 | return iter->nodeItem; |
| 162 | } |
| 163 | |
| 164 | void DocumentClassesFolder::closeDocument(const IndexedString& a_file) |
| 165 | { |
no test coverage detected