MCPcopy Create free account
hub / github.com/KDE/kdevelop / languagesForUrl

Method languagesForUrl

kdevplatform/shell/languagecontroller.cpp:323–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323QList<ILanguageSupport*> LanguageController::languagesForUrl(const QUrl &url)
324{
325 if (url.isEmpty()) {
326 // The URL of an unsaved document is empty.
327 // The code below cannot find a language for an empty URL.
328 return {};
329 }
330
331 Q_D(LanguageController);
332
333 QMutexLocker lock(&d->dataMutex);
334
335 if(d->m_cleanedUp)
336 return {};
337
338 ///non-crashy part: Use the mime-types of known languages
339 auto languages = d->mimeTypeCache.languagesForFileName(url.fileName());
340
341 //Never use findByUrl from within a background thread, and never load a language support
342 //from within the background thread. Both are unsafe, and can lead to crashes.
343 if(!languages.isEmpty() || QThread::currentThread() != thread())
344 return languages;
345
346 const auto mimeType = QMimeDatabase().mimeTypeForUrl(url);
347 languages = languagesForMimetype(mimeType.name());
348
349 return languages;
350}
351
352QList<ILanguageSupport*> LanguageController::languagesForMimetype(const QString& mimetype)
353{

Calls 5

threadFunction · 0.85
languagesForFileNameMethod · 0.80
isEmptyMethod · 0.45
fileNameMethod · 0.45
nameMethod · 0.45