<table><tr><td style="">thomassc added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D18224">View Revision</a></tr></table><br /><div><div><p>I re-tested the behavior on files from an actual project and it showed the same behavior when editing files as described in my last post, regardless of how many files are included from the files that are edited. I noticed that the behavior is different when re-opening files: in this case, problemsForFile() is actually called for a larger set of files (although from only looking at this set of files, it seemed a bit random and it was not clear to me how it is determined, I'll have to dig into the source code for this at some point ...).</p>
<p>In any case, the diagnostics cache seems to be clearly broken to me at the moment. The issue is that the ParseSession class and the diagnostics cache is related to a translation unit, but problemsForFile() is called for a specific file of that translation unit. So, if problemsForFile() is called for file A first and then for file B, the problems returned for file B will wrongly re-use cached entries that were created for file A before, while the actual problems might be completely different for both files. Thus, as a concrete issue, if a header file is edited and then the user switches to the source file that was used within the translation unit for determining the header's problems, then KDevelop might show a wrong set of problems for that source file as a result (until the source file is edited again).</p>
<p>I haven't seen a case where the cache has been used correctly. So far I have only seen problemsForFile() being called once for a file from a translation unit. In this case, no correct re-use of Problems is possible on the file level. The incorrect re-use does currently speed up the function, but not in a desirable way. A place where valid re-use would be possible are the IncludeFileNotFoundProblem that are propagated to each document that includes the file with the error. But for that, the cache must be limited to only such problems, which has not been the case.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D18224">https://phabricator.kde.org/D18224</a></div></div><br /><div><strong>To: </strong>thomassc, KDevelop, mwolff<br /><strong>Cc: </strong>aaronpuchert, pino, mwolff, kdevelop-devel, glebaccon, domson, antismap, iodelay, alexeymin, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>