| 519 | } |
| 520 | |
| 521 | ClangProblem::Ptr ParseSession::createExternalProblem(int indexInTU, |
| 522 | CXDiagnostic diagnostic, |
| 523 | const KLocalizedString& descriptionTemplate, |
| 524 | int childProblemFinalLocationIndex) const |
| 525 | { |
| 526 | // Make a copy of the original (cached) problem since it is modified later |
| 527 | auto problem = ClangProblem::Ptr(new ClangProblem(*getOrCreateProblem(indexInTU, diagnostic))); |
| 528 | |
| 529 | // Insert a copy of the parent problem (without child problems) as the first |
| 530 | // child problem to preserve its location. |
| 531 | auto* problemCopy = new ClangProblem(); |
| 532 | problemCopy->setSource(problem->source()); |
| 533 | problemCopy->setFinalLocation(problem->finalLocation()); |
| 534 | problemCopy->setFinalLocationMode(problem->finalLocationMode()); |
| 535 | problemCopy->setDescription(problem->description()); |
| 536 | problemCopy->setExplanation(problem->explanation()); |
| 537 | problemCopy->setSeverity(problem->severity()); |
| 538 | |
| 539 | auto childProblems = problem->diagnostics(); |
| 540 | childProblems.prepend(IProblem::Ptr(problemCopy)); |
| 541 | problem->setDiagnostics(childProblems); |
| 542 | |
| 543 | // Override the problem's finalLocation with that of the child problem in this document. |
| 544 | // This is required to make the problem show up in the problem reporter for this |
| 545 | // file, since it filters by finalLocation. It will also lead the user to the correct |
| 546 | // location when clicking the problem and cause proper error highlighting. |
| 547 | int index = (childProblemFinalLocationIndex >= 0) ? |
| 548 | (1 + childProblemFinalLocationIndex) : |
| 549 | (childProblems.size() - 1); |
| 550 | problem->setFinalLocation(childProblems[index]->finalLocation()); |
| 551 | |
| 552 | problem->setDescription(descriptionTemplate.subs(problem->description()).toString()); |
| 553 | |
| 554 | return problem; |
| 555 | } |
| 556 | |
| 557 | QList<ClangProblem::Ptr> ParseSession::createRequestedHereProblems(int indexInTU, CXDiagnostic diagnostic, CXFile file) const |
| 558 | { |
nothing calls this directly
no test coverage detected