forked from qt-creator/qt-creator
Add system include path to HeaderPath and merge ProjectPartHeaderPath
System include paths are appended after other includes by the compiler. So we should set them as system includes and not as normal includes. Otherwise we change the include order. Headers in system include paths are not cluttering the screen with unwanted warning and by the way improve performance too. ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them. Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -36,7 +36,7 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(
|
||||
int position,
|
||||
const QString &fileName,
|
||||
TextEditor::AssistReason reason,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
const CPlusPlus::LanguageFeatures &features)
|
||||
: AssistInterface(textEditorWidget->document(), position, fileName, reason)
|
||||
, m_communicator(communicator)
|
||||
@@ -51,7 +51,7 @@ bool ClangCompletionAssistInterface::objcEnabled() const
|
||||
return true; // TODO:
|
||||
}
|
||||
|
||||
const CppTools::ProjectPartHeaderPaths &ClangCompletionAssistInterface::headerPaths() const
|
||||
const ProjectExplorer::HeaderPaths &ClangCompletionAssistInterface::headerPaths() const
|
||||
{
|
||||
return m_headerPaths;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ CPlusPlus::LanguageFeatures ClangCompletionAssistInterface::languageFeatures() c
|
||||
return m_languageFeatures;
|
||||
}
|
||||
|
||||
void ClangCompletionAssistInterface::setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths)
|
||||
void ClangCompletionAssistInterface::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
m_headerPaths = headerPaths;
|
||||
}
|
||||
|
||||
@@ -41,21 +41,21 @@ public:
|
||||
int position,
|
||||
const QString &fileName,
|
||||
TextEditor::AssistReason reason,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
const CPlusPlus::LanguageFeatures &features);
|
||||
|
||||
BackendCommunicator &communicator() const;
|
||||
bool objcEnabled() const;
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths() const;
|
||||
const ProjectExplorer::HeaderPaths &headerPaths() const;
|
||||
CPlusPlus::LanguageFeatures languageFeatures() const;
|
||||
const TextEditor::TextEditorWidget *textEditorWidget() const;
|
||||
|
||||
void setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths); // For tests
|
||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths); // For tests
|
||||
|
||||
private:
|
||||
BackendCommunicator &m_communicator;
|
||||
QStringList m_options;
|
||||
CppTools::ProjectPartHeaderPaths m_headerPaths;
|
||||
ProjectExplorer::HeaderPaths m_headerPaths;
|
||||
CPlusPlus::LanguageFeatures m_languageFeatures;
|
||||
const TextEditor::TextEditorWidget *m_textEditorWidget;
|
||||
};
|
||||
|
||||
@@ -465,16 +465,16 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
|
||||
}
|
||||
|
||||
// Make completion for all relevant includes
|
||||
CppTools::ProjectPartHeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const CppTools::ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
CppTools::ProjectPartHeaderPath::IncludePath);
|
||||
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
ProjectExplorer::IncludePathType::User);
|
||||
if (!headerPaths.contains(currentFilePath))
|
||||
headerPaths.append(currentFilePath);
|
||||
|
||||
const ::Utils::MimeType mimeType = ::Utils::mimeTypeForName("text/x-c++hdr");
|
||||
const QStringList suffixes = mimeType.suffixes();
|
||||
|
||||
foreach (const CppTools::ProjectPartHeaderPath &headerPath, headerPaths) {
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
|
||||
QString realPath = headerPath.path;
|
||||
if (!directoryPrefix.isEmpty()) {
|
||||
realPath += QLatin1Char('/');
|
||||
|
||||
@@ -92,13 +92,11 @@ public:
|
||||
TextEditor::ProposalModelPtr proposalModel;
|
||||
};
|
||||
|
||||
static const CppTools::ProjectPartHeaderPaths toHeaderPaths(const QStringList &paths)
|
||||
static const ProjectExplorer::HeaderPaths toHeaderPaths(const QStringList &paths)
|
||||
{
|
||||
using namespace CppTools;
|
||||
|
||||
ProjectPartHeaderPaths result;
|
||||
ProjectExplorer::HeaderPaths result;
|
||||
foreach (const QString &path, paths)
|
||||
result << ProjectPartHeaderPath(path, ProjectPartHeaderPath::IncludePath);
|
||||
result.push_back({path, ProjectExplorer::IncludePathType::User});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user