| 133 | } |
| 134 | |
| 135 | bool ClassNode::updateClassDeclarations() |
| 136 | { |
| 137 | bool hadChanges = false; |
| 138 | SubIdentifiersMap existingIdentifiers = m_subIdentifiers; |
| 139 | |
| 140 | auto* klass = dynamic_cast<ClassDeclaration*>(declaration()); |
| 141 | |
| 142 | if (klass) { |
| 143 | const auto localDeclarations = klass->internalContext()->localDeclarations(); |
| 144 | for (Declaration* decl : localDeclarations) { |
| 145 | // Ignore forward declarations. |
| 146 | if (decl->isForwardDeclaration()) |
| 147 | continue; |
| 148 | |
| 149 | // Don't add existing declarations. |
| 150 | const auto identifierIt = existingIdentifiers.find(decl->ownIndex()); |
| 151 | if (identifierIt != existingIdentifiers.end()) { |
| 152 | existingIdentifiers.erase(identifierIt); |
| 153 | continue; |
| 154 | } |
| 155 | |
| 156 | Node* newNode = nullptr; |
| 157 | |
| 158 | if (EnumerationType::Ptr enumType = decl->type<EnumerationType>()) |
| 159 | newNode = new EnumNode(decl, m_model); |
| 160 | else if (decl->isFunctionDeclaration()) |
| 161 | newNode = new FunctionNode(decl, m_model); |
| 162 | else if (auto* classDecl = dynamic_cast<ClassDeclaration*>(decl)) |
| 163 | newNode = new ClassNode(classDecl, m_model); |
| 164 | else if (auto* memDecl = dynamic_cast<ClassMemberDeclaration*>(decl)) |
| 165 | newNode = new ClassMemberNode(memDecl, m_model); |
| 166 | else |
| 167 | { |
| 168 | // Debug - for reference. |
| 169 | qCDebug(LANGUAGE) << "class: " << klass->toString() << "name: " << decl->toString() << |
| 170 | " - unknown declaration type: " << typeid(*decl).name(); |
| 171 | } |
| 172 | |
| 173 | if (newNode) { |
| 174 | addNode(newNode); |
| 175 | |
| 176 | // Also remember the identifier. |
| 177 | m_subIdentifiers.insert(decl->ownIndex(), newNode); |
| 178 | |
| 179 | hadChanges = true; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // Remove old existing identifiers |
| 185 | for (SubIdentifiersMap::iterator iter = existingIdentifiers.begin(); |
| 186 | iter != existingIdentifiers.end(); |
| 187 | ++iter) { |
| 188 | iter.value()->removeSelf(); |
| 189 | m_subIdentifiers.remove(iter.key()); |
| 190 | hadChanges = true; |
| 191 | } |
| 192 |
nothing calls this directly
no test coverage detected