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

Method applyChanges

kdevplatform/language/codegen/basicrefactoring.cpp:145–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145DocumentChangeSet::ChangeResult BasicRefactoring::applyChanges(const QString& oldName, const QString& newName,
146 DocumentChangeSet& changes, DUContext* context,
147 int usedDeclarationIndex)
148{
149 if (usedDeclarationIndex == std::numeric_limits<int>::max())
150 return DocumentChangeSet::ChangeResult::successfulResult();
151
152 for (int a = 0; a < context->usesCount(); ++a) {
153 const Use& use(context->uses()[a]);
154 if (use.m_declarationIndex != usedDeclarationIndex)
155 continue;
156 if (use.m_range.isEmpty()) {
157 qCDebug(LANGUAGE) << "found empty use";
158 continue;
159 }
160 DocumentChangeSet::ChangeResult result =
161 changes.addChange(DocumentChange(context->url(), context->transformFromLocalRevision(use.m_range), oldName,
162 newName));
163 if (!result)
164 return result;
165 }
166
167 const auto childContexts = context->childContexts();
168 for (DUContext* child : childContexts) {
169 DocumentChangeSet::ChangeResult result = applyChanges(oldName, newName, changes, child, usedDeclarationIndex);
170 if (!result)
171 return result;
172 }
173
174 return DocumentChangeSet::ChangeResult::successfulResult();
175}
176
177DocumentChangeSet::ChangeResult BasicRefactoring::applyChangesToDeclarations(const QString& oldName,
178 const QString& newName,

Callers

nothing calls this directly

Calls 6

addChangeMethod · 0.80
childContextsMethod · 0.80
usesCountMethod · 0.45
isEmptyMethod · 0.45
urlMethod · 0.45

Tested by

no test coverage detected