LanguageClient: also check for inherited mime types

... when trying to auto setup language servers as well when matching the
configured mime types against a document mime type.
In particular this fixes showing the auto setup editor info bar for the
newly introduced clang format mime type as well as starting the yaml
server for those files, since this clang format mime type inherits the
yaml mime type.

Change-Id: Id3ec64b0a1a128b070eadbcad600b3aaf4e667c3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
David Schulz
2024-01-05 09:01:25 +01:00
parent 6adb82eabc
commit 2e96194681
3 changed files with 79 additions and 36 deletions

View File

@@ -996,10 +996,16 @@ QString StdIOSettingsWidget::arguments() const
return m_arguments->text();
}
bool LanguageFilter::isSupported(const Utils::FilePath &filePath, const QString &mimeType) const
bool LanguageFilter::isSupported(const Utils::FilePath &filePath, const QString &mimeTypeName) const
{
if (mimeTypes.contains(mimeType))
return true;
if (!mimeTypes.isEmpty()) {
const MimeType mimeType = Utils::mimeTypeForName(mimeTypeName);
if (Utils::anyOf(mimeTypes, [mimeType](const QString &supported) {
return mimeType.inherits(supported);
})) {
return true;
}
}
if (filePattern.isEmpty() && filePath.isEmpty())
return mimeTypes.isEmpty();
const QRegularExpression::PatternOptions options