| 106 | } |
| 107 | |
| 108 | bool 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 | |
| 143 | QStringList IgnoreManager::loadIgnorePatterns(ProjectExplorer::Project *project) |
| 144 | { |
nothing calls this directly
no outgoing calls
no test coverage detected