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

Method updateClassDeclarations

kdevplatform/language/classmodel/classmodelnode.cpp:135–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135bool 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

Callers

nothing calls this directly

Calls 15

localDeclarationsMethod · 0.80
internalContextMethod · 0.45
isForwardDeclarationMethod · 0.45
findMethod · 0.45
ownIndexMethod · 0.45
endMethod · 0.45
isFunctionDeclarationMethod · 0.45
toStringMethod · 0.45
nameMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
removeSelfMethod · 0.45

Tested by

no test coverage detected