aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-02-14 16:08:12 +0100
committerMarco Bubke <marco.bubke@qt.io>2019-02-18 14:30:02 +0000
commit337155a6488ec0d0857c6f51cf4f449232996d65 (patch)
tree1d46a309e24b780944e523e1dbe50a07ddf5f56d /src
parentfbadbd3b0d40d19bc0b8a7303cb0dc0d1d031eb0 (diff)
CppTools: Add project directory filter to HeaderPathFilter
For the indexer we want to filter every not builtin include search path to as system include search path which is not inside of the project or build directory. Change-Id: I33663a1f3eb53ec39d5b16a8ca64b57d1b57bd9c Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cpptools/headerpathfilter.cpp19
-rw-r--r--src/plugins/cpptools/headerpathfilter.h14
2 files changed, 30 insertions, 3 deletions
diff --git a/src/plugins/cpptools/headerpathfilter.cpp b/src/plugins/cpptools/headerpathfilter.cpp
index 342ee773b7..b514c468d7 100644
--- a/src/plugins/cpptools/headerpathfilter.cpp
+++ b/src/plugins/cpptools/headerpathfilter.cpp
@@ -48,6 +48,11 @@ void HeaderPathFilter::process()
tweakHeaderPaths();
}
+bool HeaderPathFilter::isProjectHeaderPath(const QString &path) const
+{
+ return path.startsWith(projectDirectory) || path.startsWith(buildDirectory);
+}
+
void HeaderPathFilter::filterHeaderPath(const ProjectExplorer::HeaderPath &headerPath)
{
if (headerPath.path.isEmpty())
@@ -62,7 +67,10 @@ void HeaderPathFilter::filterHeaderPath(const ProjectExplorer::HeaderPath &heade
systemHeaderPaths.push_back(headerPath);
break;
case HeaderPathType::User:
- userHeaderPaths.push_back(headerPath);
+ if (isProjectHeaderPath(headerPath.path))
+ userHeaderPaths.push_back(headerPath);
+ else
+ systemHeaderPaths.push_back(headerPath);
break;
}
}
@@ -133,4 +141,13 @@ void HeaderPathFilter::tweakHeaderPaths()
}
}
+QString HeaderPathFilter::ensurePathWithSlashEnding(const QString &path)
+{
+ QString pathWithSlashEnding = path;
+ if (!pathWithSlashEnding.isEmpty() && *pathWithSlashEnding.rbegin() != '/')
+ pathWithSlashEnding.push_back('/');
+
+ return pathWithSlashEnding;
+}
+
} // namespace CppTools
diff --git a/src/plugins/cpptools/headerpathfilter.h b/src/plugins/cpptools/headerpathfilter.h
index ccb5c709c0..8b4e771994 100644
--- a/src/plugins/cpptools/headerpathfilter.h
+++ b/src/plugins/cpptools/headerpathfilter.h
@@ -34,11 +34,15 @@ class CPPTOOLS_EXPORT HeaderPathFilter
public:
HeaderPathFilter(const ProjectPart &projectPart,
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes,
- const QString &clangVersion = QString(),
- const QString &clangResourceDirectory = QString())
+ const QString &clangVersion = {},
+ const QString &clangResourceDirectory = {},
+ const QString &projectDirectory = {},
+ const QString &buildDirectory = {})
: projectPart{projectPart}
, clangVersion{clangVersion}
, clangResourceDirectory{clangResourceDirectory}
+ , projectDirectory(ensurePathWithSlashEnding(projectDirectory))
+ , buildDirectory(ensurePathWithSlashEnding(buildDirectory))
, useTweakedHeaderPaths{useTweakedHeaderPaths}
{}
@@ -49,6 +53,10 @@ private:
void tweakHeaderPaths();
+ bool isProjectHeaderPath(const QString &path) const;
+
+ static QString ensurePathWithSlashEnding(const QString &path);
+
public:
ProjectExplorer::HeaderPaths builtInHeaderPaths;
ProjectExplorer::HeaderPaths systemHeaderPaths;
@@ -56,6 +64,8 @@ public:
const ProjectPart &projectPart;
const QString clangVersion;
const QString clangResourceDirectory;
+ const QString projectDirectory;
+ const QString buildDirectory;
const UseTweakedHeaderPaths useTweakedHeaderPaths;
};