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

Method execute

plugins/clang/codecompletion/context.cpp:165–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163 }
164
165 void execute(KTextEditor::View* view, const KTextEditor::Range& word) override
166 {
167 QString replacement = m_returnType + QLatin1Char(' ') + m_display.replace(QRegularExpression(QStringLiteral("\\s*=\\s*0")), QString());
168
169 bool appendSpecifer = true;
170 if (const auto* project =
171 KDevelop::ICore::self()->projectController()->findProjectForUrl(view->document()->url())) {
172 const auto arguments = KDevelop::IDefinesAndIncludesManager::manager()->parserArguments(
173 project->filesForPath(IndexedString(view->document()->url().path())).first());
174 const auto match = QRegularExpression(QStringLiteral(R"(-std=c\+\+(\w+))")).match(arguments);
175
176 appendSpecifer = match.hasMatch(); // assume non-modern if no standard is specified
177 if (appendSpecifer) {
178 const auto standard = match.capturedView(1);
179 appendSpecifer = (standard != QLatin1String("98") && standard != QLatin1String("03"));
180 }
181 }
182
183 if (appendSpecifer) {
184 replacement.append(QLatin1String(" override;"));
185 } else {
186 replacement.append(QLatin1Char(';'));
187 }
188
189 DocumentChange overrideChange(IndexedString(view->document()->url()),
190 word,
191 QString{},
192 replacement);
193 overrideChange.m_ignoreOldText = true;
194 DocumentChangeSet changes;
195 changes.addChange(overrideChange);
196 changes.applyAllChanges();
197 }
198
199private:
200 QString m_returnType;

Callers

nothing calls this directly

Calls 15

managerFunction · 0.85
findProjectForUrlMethod · 0.80
projectControllerMethod · 0.80
hasMatchMethod · 0.80
addChangeMethod · 0.80
applyAllChangesMethod · 0.80
QStringClass · 0.50
IndexedStringClass · 0.50
replaceMethod · 0.45
urlMethod · 0.45
documentMethod · 0.45
parserArgumentsMethod · 0.45

Tested by

no test coverage detected