MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / matchPathWithPattern

Method matchPathWithPattern

context/IgnoreManager.cpp:108–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108bool IgnoreManager::matchPathWithPattern(const QString &path, const QString &pattern) const
109{
110 QString adjustedPattern = pattern.trimmed();
111
112 bool matchFromRoot = adjustedPattern.startsWith('/');
113 if (matchFromRoot)
114 adjustedPattern = adjustedPattern.mid(1);
115
116 bool matchDirOnly = adjustedPattern.endsWith('/');
117 if (matchDirOnly)
118 adjustedPattern.chop(1);
119
120 QString regexPattern = QRegularExpression::escape(adjustedPattern);
121
122 regexPattern.replace("\\*\\*", ".*");
123
124 regexPattern.replace("\\*", "[^/]*");
125
126 regexPattern.replace("\\?", ".");
127
128 if (matchFromRoot)
129 regexPattern = QString("^%1").arg(regexPattern);
130 else
131 regexPattern = QString("(^|/)%1").arg(regexPattern);
132
133 if (matchDirOnly)
134 regexPattern = QString("%1$").arg(regexPattern);
135 else
136 regexPattern = QString("%1($|/)").arg(regexPattern);
137
138 QRegularExpression regex(regexPattern);
139 QRegularExpressionMatch match = regex.match(path);
140 return match.hasMatch();
141}
142
143QStringList IgnoreManager::loadIgnorePatterns(ProjectExplorer::Project *project)
144{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected