| 71 | } |
| 72 | |
| 73 | ParseSessionData::Ptr DUChainUtils::findParseSessionData(const IndexedString &file, const IndexedString &tufile) |
| 74 | { |
| 75 | DUChainReadLocker lock; |
| 76 | auto context = KDevelop::DUChainUtils::standardContextForUrl(file.toUrl()); |
| 77 | if (!context || !context->ast()) { |
| 78 | // no cached data found for the current file, but maybe |
| 79 | // we are lucky and can grab it from the TU context |
| 80 | // this happens e.g. when originally a .cpp file is open and then one |
| 81 | // of its included files is opened in the editor. |
| 82 | context = KDevelop::DUChainUtils::standardContextForUrl(tufile.toUrl()); |
| 83 | } |
| 84 | |
| 85 | if (context) { |
| 86 | return ParseSessionData::Ptr(dynamic_cast<ParseSessionData*>(context->ast().data())); |
| 87 | } |
| 88 | return {}; |
| 89 | } |
| 90 | |
| 91 | } |