projectfilter: improve filter generation code with consistent use arrays

code improvement done as exception in stable branch, as potentially there
will be more additions of the filter list here, where merging into
a changed code base only in master would become more work
parent 1e500fe5
......@@ -23,6 +23,8 @@
#include <KConfigGroup>
#include <array>
using namespace KDevelop;
Filter::Filter()
......@@ -68,42 +70,54 @@ namespace KDevelop {
SerializedFilters defaultFilters()
{
SerializedFilters ret;
ret.reserve(20);
ret.reserve(41);
// filter hidden files
ret << SerializedFilter(QStringLiteral(".*"), Filter::Targets(Filter::Files | Filter::Folders));
// but do show some with special meaning
static const std::array<QString, 10> configFiles = {
// Version control
ret << SerializedFilter(QStringLiteral(".gitignore"), Filter::Files, Filter::Inclusive)
<< SerializedFilter(QStringLiteral(".gitmodules"), Filter::Files, Filter::Inclusive)
QStringLiteral(".gitignore"),
QStringLiteral(".gitmodules"),
// https://pre-commit.com/
<< SerializedFilter(QStringLiteral(".pre-commit-config.yaml"), Filter::Files, Filter::Inclusive)
QStringLiteral(".pre-commit-config.yaml"),
// CI config files
// https://docs.gitlab.com/ee/ci/yaml/
<< SerializedFilter(QStringLiteral(".gitlab-ci.yml"), Filter::Files, Filter::Inclusive)
QStringLiteral(".gitlab-ci.yml"),
// https://travis-ci.org/
<< SerializedFilter(QStringLiteral(".travis.yml"), Filter::Files, Filter::Inclusive)
// https://circleci.com/docs/
<< SerializedFilter(QStringLiteral(".circleci"), Filter::Folders, Filter::Inclusive)
QStringLiteral(".travis.yml"),
// Linting configs
// https://editorconfig.org/
<< SerializedFilter(QStringLiteral(".editorconfig"), Filter::Files, Filter::Inclusive)
QStringLiteral(".editorconfig"),
// https://pep8.readthedocs.io
<< SerializedFilter(QStringLiteral(".pep8"), Filter::Files, Filter::Inclusive)
QStringLiteral(".pep8"),
// https://prettier.io/
<< SerializedFilter(QStringLiteral(".prettierignore"), Filter::Files, Filter::Inclusive)
<< SerializedFilter(QStringLiteral(".prettierrc*"), Filter::Files, Filter::Inclusive)
QStringLiteral(".prettierignore"),
QStringLiteral(".prettierrc*"),
// https://clang.llvm.org/docs/ClangFormat.html
<< SerializedFilter(QStringLiteral(".clang-format"), Filter::Files, Filter::Inclusive);
QStringLiteral(".clang-format"),
};
for (const QString& file : configFiles) {
ret << SerializedFilter(file, Filter::Files, Filter::Inclusive);
}
static const std::array<QString, 1> configFolders = {
// CI config folders
// https://circleci.com/docs/
QStringLiteral(".circleci"),
};
for (const QString& folder : configFolders) {
ret << SerializedFilter(folder, Filter::Folders, Filter::Inclusive);
}
// common vcs folders which we want to hide
static const QVector<QString> invalidFolders = {
static const std::array<QString, 9> invalidFolders = {
QStringLiteral(".git"), QStringLiteral("CVS"), QStringLiteral(".svn"), QStringLiteral("_svn"),
QStringLiteral("SCCS"), QStringLiteral("_darcs"), QStringLiteral(".hg"), QStringLiteral(".bzr"), QStringLiteral("__pycache__")
};
......@@ -112,7 +126,7 @@ SerializedFilters defaultFilters()
}
// common files which we want to hide
static const QVector<QString> filePatterns = {
static const std::array<QString, 20> filePatterns = {
// binary files (Unix)
QStringLiteral("*.o"), QStringLiteral("*.a"), QStringLiteral("*.so"), QStringLiteral("*.so.*"),
// binary files (Windows)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment