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

Function fixUnknownDeclaration

plugins/clang/duchain/unknowndeclarationproblem.cpp:475–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475ClangFixits 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
521QString symbolFromDiagnosticSpelling(const QString& str)
522{

Callers 1

solutionAssistantMethod · 0.85

Calls 14

findMatchingDeclarationsFunction · 0.85
forwardDeclarationsFunction · 0.85
includeFilesFunction · 0.85
includePathsFunction · 0.85
directiveForFileFunction · 0.85
assistantsSettingsMethod · 0.80
toLocalFileMethod · 0.80
lineMethod · 0.45
startMethod · 0.45
columnMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected