Changeset View
Changeset View
Standalone View
Standalone View
plugins/clang/duchain/parsesession.cpp
Show All 26 Lines | |||||
27 | #include "clangdiagnosticevaluator.h" | 27 | #include "clangdiagnosticevaluator.h" | ||
28 | #include "todoextractor.h" | 28 | #include "todoextractor.h" | ||
29 | #include "clanghelpers.h" | 29 | #include "clanghelpers.h" | ||
30 | #include "clangindex.h" | 30 | #include "clangindex.h" | ||
31 | #include "clangparsingenvironment.h" | 31 | #include "clangparsingenvironment.h" | ||
32 | #include "util/clangdebug.h" | 32 | #include "util/clangdebug.h" | ||
33 | #include "util/clangtypes.h" | 33 | #include "util/clangtypes.h" | ||
34 | #include "util/clangutils.h" | 34 | #include "util/clangutils.h" | ||
35 | #include "headerguardassistant.h" | ||||
35 | 36 | | |||
36 | #include <language/duchain/duchainlock.h> | 37 | #include <language/duchain/duchainlock.h> | ||
37 | #include <language/duchain/duchain.h> | 38 | #include <language/duchain/duchain.h> | ||
39 | #include <language/codegen/coderepresentation.h> | ||||
38 | 40 | | |||
39 | #include <KShell> | 41 | #include <KShell> | ||
40 | 42 | | |||
41 | #include <QDir> | 43 | #include <QDir> | ||
42 | #include <QFileInfo> | 44 | #include <QFileInfo> | ||
43 | #include <QMimeDatabase> | 45 | #include <QMimeDatabase> | ||
44 | #include <QMimeType> | 46 | #include <QMimeType> | ||
45 | 47 | | |||
▲ Show 20 Lines • Show All 424 Lines • ▼ Show 20 Line(s) | |||||
470 | #if CINDEX_VERSION_MINOR > 30 | 472 | #if CINDEX_VERSION_MINOR > 30 | ||
471 | // note that the below warning is triggered on every reparse when there is a precompiled preamble | 473 | // note that the below warning is triggered on every reparse when there is a precompiled preamble | ||
472 | // see also TestDUChain::testReparseIncludeGuard | 474 | // see also TestDUChain::testReparseIncludeGuard | ||
473 | const QString path = QDir(ClangString(clang_getFileName(file)).toString()).canonicalPath(); | 475 | const QString path = QDir(ClangString(clang_getFileName(file)).toString()).canonicalPath(); | ||
474 | const IndexedString indexedPath(path); | 476 | const IndexedString indexedPath(path); | ||
475 | if (ClangHelpers::isHeader(path) && !clang_isFileMultipleIncludeGuarded(unit(), file) | 477 | if (ClangHelpers::isHeader(path) && !clang_isFileMultipleIncludeGuarded(unit(), file) | ||
476 | && !clang_Location_isInSystemHeader(clang_getLocationForOffset(d->m_unit, file, 0))) | 478 | && !clang_Location_isInSystemHeader(clang_getLocationForOffset(d->m_unit, file, 0))) | ||
477 | { | 479 | { | ||
478 | ProblemPointer problem(new Problem); | 480 | QExplicitlySharedDataPointer<StaticAssistantProblem> problem(new StaticAssistantProblem); | ||
479 | problem->setSeverity(IProblem::Warning); | 481 | problem->setSeverity(IProblem::Warning); | ||
480 | problem->setDescription(i18n("Header is not guarded against multiple inclusions")); | 482 | problem->setDescription(i18n("Header is not guarded against multiple inclusions")); | ||
481 | problem->setExplanation(i18n("The given header is not guarded against multiple inclusions, " | 483 | problem->setExplanation(i18n("The given header is not guarded against multiple inclusions, " | ||
482 | "either with the conventional #ifndef/#define/#endif macro guards or with #pragma once.")); | 484 | "either with the conventional #ifndef/#define/#endif macro guards or with #pragma once.")); | ||
483 | problem->setFinalLocation({indexedPath, KTextEditor::Range()}); | 485 | const KTextEditor::Range problemRange(0, 0, KDevelop::createCodeRepresentation(indexedPath)->lines(), 0); | ||
486 | problem->setFinalLocation(DocumentRange{indexedPath, problemRange}); | ||||
484 | problem->setSource(IProblem::Preprocessor); | 487 | problem->setSource(IProblem::Preprocessor); | ||
488 | problem->setSolutionAssistant(KDevelop::IAssistant::Ptr(new HeaderGuardAssistant(d->m_unit, file))); | ||||
485 | problems << problem; | 489 | problems << problem; | ||
486 | // TODO: Easy to add an assistant here that adds the guards -- any takers? | | |||
487 | } | 490 | } | ||
488 | #endif | 491 | #endif | ||
489 | 492 | | |||
490 | return problems; | 493 | return problems; | ||
491 | } | 494 | } | ||
492 | 495 | | |||
493 | CXTranslationUnit ParseSession::unit() const | 496 | CXTranslationUnit ParseSession::unit() const | ||
494 | { | 497 | { | ||
Show All 40 Lines |