diff --git a/languages/clang/duchain/clangproblem.h b/languages/clang/duchain/clangproblem.h --- a/languages/clang/duchain/clangproblem.h +++ b/languages/clang/duchain/clangproblem.h @@ -75,8 +75,18 @@ */ ClangFixits allFixits() const; + /** + * Path to the compilation unit that lead to the diagnostic. This is + * different from @ref finalLocation when the diagnostic appears in a + * header file. + * + * @return the path to the compilation unit. + */ + KDevelop::IndexedString compilationUnit() const; + private: ClangFixits m_fixits; + KDevelop::IndexedString m_compilationUnit; }; diff --git a/languages/clang/duchain/clangproblem.cpp b/languages/clang/duchain/clangproblem.cpp --- a/languages/clang/duchain/clangproblem.cpp +++ b/languages/clang/duchain/clangproblem.cpp @@ -158,6 +158,8 @@ diagnostics << ProblemPointer(problem.data()); } setDiagnostics(diagnostics); + + m_compilationUnit = ClangString(clang_getTranslationUnitSpelling(unit)).toIndexed(); } IAssistant::Ptr ClangProblem::solutionAssistant() const @@ -192,6 +194,11 @@ return result; } +KDevelop::IndexedString ClangProblem::compilationUnit() const +{ + return m_compilationUnit; +} + ClangFixitAssistant::ClangFixitAssistant(const ClangFixits& fixits) : m_title(tr("Fix-it Hints")) , m_fixits(fixits) diff --git a/languages/clang/duchain/missingincludepathproblem.cpp b/languages/clang/duchain/missingincludepathproblem.cpp --- a/languages/clang/duchain/missingincludepathproblem.cpp +++ b/languages/clang/duchain/missingincludepathproblem.cpp @@ -110,7 +110,8 @@ KDevelop::IAssistant::Ptr MissingIncludePathProblem::solutionAssistant() const { - return KDevelop::IAssistant::Ptr(new MissingIncludePathAssistant(description(), finalLocation().document)); + return KDevelop::IAssistant::Ptr(new MissingIncludePathAssistant( + description(), compilationUnit())); } #include "missingincludepathproblem.moc"