Bug 381709

Summary: Matlab script interpreted as C++
Product: [Applications] kdevelop Reporter: peje66
Component: All editorsAssignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: geetam.chawla, igorkuo, mail
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Imge of Matlab script showing erroneous C++-problems

Description peje66 2017-06-27 06:04:50 UTC
Created attachment 106331 [details]
Imge of Matlab script showing erroneous C++-problems

If I load a matlab-script in kdevelop it's parsed as C++-code and generates a ton of warnings.
Se image. All the markings in the editor window is distracting.
Document is marked as Tools->Mode->Scientific->Matlab

"kmimetypefinder5 reformat_flux.m" reports "text/x-matlab"
Comment 1 Sven Brauch 2017-06-27 16:59:30 UTC
I just tried, the issue is reproducible here ... not sure what is responsible for that :/
Comment 2 geetam chawla 2017-06-27 18:59:42 UTC
@Sven: For me it is only reproducible if I add it to a session which has existing cpp projects, if a new session is created for matlab project(s), matlab scripts are not interpreted as cpp.
Comment 3 Igor Kushnir 2023-09-28 18:28:13 UTC
*.m is registered as both a Matlab and an Objective-C MIME type extension. kdevelop/plugins/clang/kdevclangsupport.json contains "text/x-objcsrc" among X-KDevelop-SupportedMimeTypes. When any file parsed by KDevelop's Clang plugin is loaded (C, C++ or Objective-C), LanguageController adds all of the plugin's supported extensions into the MimeTypeCache. The cache is consulted before MIME type detection. So it returns ClangSupport for any *.m file afterward.

Note that the MimeTypeCache is not just an optimization. Simply removing the cache would make LanguageController::languagesForUrl() always return an empty list in a background thread because of an early return required for thread safety.