| 436 | } |
| 437 | |
| 438 | void DAPDebugger::addBreakpoint(const QString &filePath, int lineNumber) |
| 439 | { |
| 440 | const auto &bps = d->breakpointModel.breakpointList(); |
| 441 | bool ret = std::any_of(bps.cbegin(), bps.cend(), |
| 442 | [&](const BreakpointItem &bp) { |
| 443 | return filePath == bp.filePath() && lineNumber == bp.lineNumber(); |
| 444 | }); |
| 445 | if (ret) |
| 446 | return; |
| 447 | |
| 448 | // update model here. |
| 449 | Internal::Breakpoint bp; |
| 450 | bp.filePath = filePath; |
| 451 | bp.fileName = QFileInfo(filePath).fileName(); |
| 452 | bp.lineNumber = lineNumber; |
| 453 | d->breakpointModel.insertBreakpoint(bp); |
| 454 | |
| 455 | // send to backend. |
| 456 | dap::array<IBreakpointData> rawBreakpoints; |
| 457 | IBreakpointData bpData; |
| 458 | bpData.id = QUuid::createUuid().toString().toStdString(); |
| 459 | bpData.lineNumber = lineNumber; |
| 460 | bpData.enabled = true; // TODO(mozart):get from editor. |
| 461 | rawBreakpoints.push_back(bpData); |
| 462 | |
| 463 | if (d->runState == kStopped || d->runState == kRunning) { |
| 464 | debugService->addBreakpoints(filePath, rawBreakpoints, d->currentSession); |
| 465 | } else { |
| 466 | debugService->addBreakpoints(filePath, rawBreakpoints, undefined); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | void DAPDebugger::removeBreakpoint(const QString &filePath, int lineNumber) |
| 471 | { |
no test coverage detected