| 473 | } |
| 474 | |
| 475 | ClangFixits fixUnknownDeclaration( const QualifiedIdentifier& identifier, const KDevelop::Path& file, const KDevelop::DocumentRange& docrange ) |
| 476 | { |
| 477 | ClangFixits fixits; |
| 478 | |
| 479 | const CursorInRevision cursor{docrange.start().line(), docrange.start().column()}; |
| 480 | |
| 481 | const auto possibleIdentifiers = findPossibleQualifiedIdentifiers(identifier, file, cursor); |
| 482 | const auto matchingDeclarations = findMatchingDeclarations(possibleIdentifiers); |
| 483 | |
| 484 | if (ClangSettingsManager::self()->assistantsSettings().forwardDeclare) { |
| 485 | const auto& forwardDeclareFixits = forwardDeclarations(matchingDeclarations, file); |
| 486 | for (const auto& fixit : forwardDeclareFixits) { |
| 487 | fixits << fixit; |
| 488 | if (fixits.size() == maxSuggestions) { |
| 489 | return fixits; |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | const auto includefiles = includeFiles(identifier, matchingDeclarations, file); |
| 495 | if (includefiles.isEmpty()) { |
| 496 | // return early as the computation of the include paths is quite expensive |
| 497 | return fixits; |
| 498 | } |
| 499 | |
| 500 | const auto includepaths = includePaths( file ); |
| 501 | clangDebug() << "found include paths for" << file << ":" << includepaths; |
| 502 | |
| 503 | /* create fixits for candidates */ |
| 504 | for( const auto& includeFile : includefiles ) { |
| 505 | const auto fixit = directiveForFile( includeFile, includepaths, file /* UP */ ); |
| 506 | if (!fixit.range.isValid()) { |
| 507 | clangDebug() << "unable to create directive for" << includeFile << "in" << file.toLocalFile(); |
| 508 | continue; |
| 509 | } |
| 510 | |
| 511 | fixits << fixit; |
| 512 | |
| 513 | if (fixits.size() == maxSuggestions) { |
| 514 | return fixits; |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | return fixits; |
| 519 | } |
| 520 | |
| 521 | QString symbolFromDiagnosticSpelling(const QString& str) |
| 522 | { |
no test coverage detected