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

Method shouldStartCompletion

plugins/clang/codecompletion/model.cpp:167–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167bool ClangCodeCompletionModel::shouldStartCompletion(KTextEditor::View* view, const QString& inserted,
168 bool userInsertion, const KTextEditor::Cursor& position)
169{
170 const QString noCompletionAfter = QStringLiteral(";{}]) ");
171
172 if (inserted.isEmpty() || consistsOfWhitespace(inserted)) {
173 return false;
174 }
175 const auto lastChar = inserted.at(inserted.size() - 1);
176 if (noCompletionAfter.contains(lastChar)) {
177 return false;
178 }
179 const auto wordAtPosition = view->document()->wordAt(position);
180 if (!wordAtPosition.isEmpty() && wordAtPosition.at(0).isDigit()) {
181 return false;
182 }
183 // also show include path completion after dashes
184 if (userInsertion && lastChar == QLatin1Char('-') && includePathCompletionRequired(view->document()->line(position.line()))) {
185 return true;
186 }
187 if (userInsertion && inserted.endsWith(QLatin1String("::"))) {
188 return true;
189 }
190
191 return KDevelop::CodeCompletionModel::shouldStartCompletion(view, inserted, userInsertion, position);
192}
193
194KTextEditor::Range ClangCodeCompletionModel::completionRange(KTextEditor::View* view, const KTextEditor::Cursor& position)
195{

Callers

nothing calls this directly

Calls 10

consistsOfWhitespaceFunction · 0.85
isDigitMethod · 0.80
endsWithMethod · 0.80
isEmptyMethod · 0.45
atMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45
documentMethod · 0.45
lineMethod · 0.45

Tested by

no test coverage detected