MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / scheduleRequest

Method scheduleRequest

QodeAssistClient.cpp:339–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339void QodeAssistClient::scheduleRequest(TextEditor::TextEditorWidget *editor)
340{
341 if (m_runningRequests.contains(editor)) {
342 if (Settings::codeCompletionSettings().cancelOnInput())
343 cancelRunningRequest(editor);
344 else
345 return;
346 }
347
348 auto it = m_scheduledRequests.find(editor);
349 if (it == m_scheduledRequests.end()) {
350 auto timer = new QTimer(this);
351 timer->setSingleShot(true);
352 connect(timer, &QTimer::timeout, this, [this, editor]() {
353 if (!editor || m_runningRequests.contains(editor))
354 return;
355 if (editor->textCursor().position()
356 != m_scheduledRequests[editor]->property("cursorPosition").toInt())
357 return;
358 requestCompletions(editor);
359 });
360 connect(editor, &TextEditorWidget::destroyed, this, [this, editor]() {
361 delete m_scheduledRequests.take(editor);
362 cancelRunningRequest(editor);
363 });
364 it = m_scheduledRequests.insert(editor, timer);
365 }
366
367 it.value()->setProperty("cursorPosition", editor->textCursor().position());
368 it.value()->start(Settings::codeCompletionSettings().startSuggestionTimer());
369}
370void QodeAssistClient::handleCompletions(
371 const GetCompletionRequest::Response &response, TextEditor::TextEditorWidget *editor)
372{

Callers

nothing calls this directly

Calls 3

valueMethod · 0.80
startMethod · 0.80
positionMethod · 0.45

Tested by

no test coverage detected