Differential D5586 Diff 14065 languages/plugins/custom-definesandincludes/definesandincludesmanager.cpp
Changeset View
Changeset View
Standalone View
Standalone View
languages/plugins/custom-definesandincludes/definesandincludesmanager.cpp
Show All 23 Lines | |||||
24 | #include "kcm_widget/definesandincludesconfigpage.h" | 24 | #include "kcm_widget/definesandincludesconfigpage.h" | ||
25 | #include "compilerprovider/compilerprovider.h" | 25 | #include "compilerprovider/compilerprovider.h" | ||
26 | #include "compilerprovider/widget/compilerswidget.h" | 26 | #include "compilerprovider/widget/compilerswidget.h" | ||
27 | #include "noprojectincludesanddefines/noprojectincludepathsmanager.h" | 27 | #include "noprojectincludesanddefines/noprojectincludepathsmanager.h" | ||
28 | 28 | | |||
29 | #include <interfaces/icore.h> | 29 | #include <interfaces/icore.h> | ||
30 | #include <interfaces/iprojectcontroller.h> | 30 | #include <interfaces/iprojectcontroller.h> | ||
31 | #include <interfaces/iproject.h> | 31 | #include <interfaces/iproject.h> | ||
32 | #include <interfaces/iruntimecontroller.h> | ||||
33 | #include <interfaces/iruntime.h> | ||||
32 | #include <project/interfaces/ibuildsystemmanager.h> | 34 | #include <project/interfaces/ibuildsystemmanager.h> | ||
33 | #include <project/projectmodel.h> | 35 | #include <project/projectmodel.h> | ||
34 | 36 | | |||
35 | #include <KPluginFactory> | 37 | #include <KPluginFactory> | ||
36 | 38 | | |||
37 | #include <QThread> | 39 | #include <QThread> | ||
38 | #include <QCoreApplication> | 40 | #include <QCoreApplication> | ||
39 | 41 | | |||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 116 | case Utils::ObjC: | |||
115 | return QString(); | 117 | return QString(); | ||
116 | case Utils::Other: | 118 | case Utils::Other: | ||
117 | return QString(); | 119 | return QString(); | ||
118 | } | 120 | } | ||
119 | Q_UNREACHABLE(); | 121 | Q_UNREACHABLE(); | ||
120 | return QString(); | 122 | return QString(); | ||
121 | } | 123 | } | ||
122 | 124 | | |||
125 | Path::List runtimePathsInHost(const Path::List& runtimePaths) | ||||
126 | { | ||||
127 | Path::List ret; | ||||
128 | ret.reserve(runtimePaths.count()); | ||||
129 | const auto rt = ICore::self()->runtimeController()->currentRuntime(); | ||||
130 | for(const auto& runtimePath: runtimePaths) | ||||
131 | ret += rt->pathInHost(runtimePath); | ||||
132 | return ret; | ||||
133 | } | ||||
134 | | ||||
123 | } | 135 | } | ||
124 | 136 | | |||
125 | K_PLUGIN_FACTORY_WITH_JSON(DefinesAndIncludesManagerFactory, "kdevdefinesandincludesmanager.json", registerPlugin<DefinesAndIncludesManager>(); ) | 137 | K_PLUGIN_FACTORY_WITH_JSON(DefinesAndIncludesManagerFactory, "kdevdefinesandincludesmanager.json", registerPlugin<DefinesAndIncludesManager>(); ) | ||
126 | 138 | | |||
127 | DefinesAndIncludesManager::DefinesAndIncludesManager( QObject* parent, const QVariantList& ) | 139 | DefinesAndIncludesManager::DefinesAndIncludesManager( QObject* parent, const QVariantList& ) | ||
128 | : IPlugin(QStringLiteral("kdevdefinesandincludesmanager"), parent ) | 140 | : IPlugin(QStringLiteral("kdevdefinesandincludesmanager"), parent ) | ||
129 | , m_settings(SettingsManager::globalInstance()) | 141 | , m_settings(SettingsManager::globalInstance()) | ||
130 | , m_noProjectIPM(new NoProjectIncludePathsManager()) | 142 | , m_noProjectIPM(new NoProjectIncludePathsManager()) | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 220 | Q_FOREACH (const auto& x, newItems ) { | |||
209 | includes.removeAll(x); | 221 | includes.removeAll(x); | ||
210 | } | 222 | } | ||
211 | } | 223 | } | ||
212 | includes += newItems; | 224 | includes += newItems; | ||
213 | } | 225 | } | ||
214 | 226 | | |||
215 | includes += m_noProjectIPM->includesAndDefines(item->path().path()).first; | 227 | includes += m_noProjectIPM->includesAndDefines(item->path().path()).first; | ||
216 | 228 | | |||
217 | return includes; | 229 | return runtimePathsInHost(includes); | ||
218 | } | 230 | } | ||
219 | 231 | | |||
220 | Path::List DefinesAndIncludesManager::frameworkDirectories( ProjectBaseItem* item, Type type ) const | 232 | Path::List DefinesAndIncludesManager::frameworkDirectories( ProjectBaseItem* item, Type type ) const | ||
221 | { | 233 | { | ||
222 | Q_ASSERT(QThread::currentThread() == qApp->thread()); | 234 | Q_ASSERT(QThread::currentThread() == qApp->thread()); | ||
223 | 235 | | |||
224 | if (!item) { | 236 | if (!item) { | ||
225 | return m_settings->provider()->frameworkDirectories(nullptr); | 237 | return m_settings->provider()->frameworkDirectories(nullptr); | ||
Show All 9 Lines | |||||
235 | } | 247 | } | ||
236 | 248 | | |||
237 | for (auto provider : m_providers) { | 249 | for (auto provider : m_providers) { | ||
238 | if (provider->type() & type) { | 250 | if (provider->type() & type) { | ||
239 | frameworkDirectories += provider->frameworkDirectories(item); | 251 | frameworkDirectories += provider->frameworkDirectories(item); | ||
240 | } | 252 | } | ||
241 | } | 253 | } | ||
242 | 254 | | |||
243 | return frameworkDirectories; | 255 | return runtimePathsInHost(frameworkDirectories); | ||
244 | } | 256 | } | ||
245 | 257 | | |||
246 | bool DefinesAndIncludesManager::unregisterProvider(IDefinesAndIncludesManager::Provider* provider) | 258 | bool DefinesAndIncludesManager::unregisterProvider(IDefinesAndIncludesManager::Provider* provider) | ||
247 | { | 259 | { | ||
248 | int idx = m_providers.indexOf(provider); | 260 | int idx = m_providers.indexOf(provider); | ||
249 | if (idx != -1) { | 261 | if (idx != -1) { | ||
250 | m_providers.remove(idx); | 262 | m_providers.remove(idx); | ||
251 | return true; | 263 | return true; | ||
Show All 16 Lines | |||||
268 | { | 280 | { | ||
269 | Defines ret = m_settings->provider()->defines(nullptr); | 281 | Defines ret = m_settings->provider()->defines(nullptr); | ||
270 | merge(&ret, m_noProjectIPM->includesAndDefines(path).second); | 282 | merge(&ret, m_noProjectIPM->includesAndDefines(path).second); | ||
271 | return ret; | 283 | return ret; | ||
272 | } | 284 | } | ||
273 | 285 | | |||
274 | Path::List DefinesAndIncludesManager::includes(const QString& path) const | 286 | Path::List DefinesAndIncludesManager::includes(const QString& path) const | ||
275 | { | 287 | { | ||
276 | return m_settings->provider()->includes(nullptr) | 288 | return runtimePathsInHost(m_settings->provider()->includes(nullptr) | ||
277 | + m_noProjectIPM->includesAndDefines(path).first; | 289 | + m_noProjectIPM->includesAndDefines(path).first); | ||
278 | } | 290 | } | ||
279 | 291 | | |||
280 | Path::List DefinesAndIncludesManager::frameworkDirectories(const QString& /* path */) const | 292 | Path::List DefinesAndIncludesManager::frameworkDirectories(const QString& /* path */) const | ||
281 | { | 293 | { | ||
282 | return m_settings->provider()->frameworkDirectories(nullptr); | 294 | return runtimePathsInHost(m_settings->provider()->frameworkDirectories(nullptr)); | ||
283 | } | 295 | } | ||
284 | 296 | | |||
285 | void DefinesAndIncludesManager::openConfigurationDialog(const QString& pathToFile) | 297 | void DefinesAndIncludesManager::openConfigurationDialog(const QString& pathToFile) | ||
286 | { | 298 | { | ||
287 | if (auto project = KDevelop::ICore::self()->projectController()->findProjectForUrl(QUrl::fromLocalFile(pathToFile))) { | 299 | if (auto project = KDevelop::ICore::self()->projectController()->findProjectForUrl(QUrl::fromLocalFile(pathToFile))) { | ||
288 | KDevelop::ICore::self()->projectController()->configureProject(project); | 300 | KDevelop::ICore::self()->projectController()->configureProject(project); | ||
289 | } else { | 301 | } else { | ||
290 | m_noProjectIPM->openConfigurationDialog(pathToFile); | 302 | m_noProjectIPM->openConfigurationDialog(pathToFile); | ||
291 | } | 303 | } | ||
292 | } | 304 | } | ||
293 | 305 | | |||
294 | Path::List DefinesAndIncludesManager::includesInBackground(const QString& path) const | 306 | Path::List DefinesAndIncludesManager::includesInBackground(const QString& path) const | ||
295 | { | 307 | { | ||
296 | Path::List includes; | 308 | Path::List includes; | ||
297 | 309 | | |||
298 | for (auto provider: m_backgroundProviders) { | 310 | for (auto provider: m_backgroundProviders) { | ||
299 | includes += provider->includesInBackground(path); | 311 | includes += provider->includesInBackground(path); | ||
300 | } | 312 | } | ||
301 | 313 | | |||
302 | return includes; | 314 | return runtimePathsInHost(includes); | ||
303 | } | 315 | } | ||
304 | 316 | | |||
305 | Path::List DefinesAndIncludesManager::frameworkDirectoriesInBackground(const QString& path) const | 317 | Path::List DefinesAndIncludesManager::frameworkDirectoriesInBackground(const QString& path) const | ||
306 | { | 318 | { | ||
307 | Path::List fwDirs; | 319 | Path::List fwDirs; | ||
308 | 320 | | |||
309 | for (auto provider: m_backgroundProviders) { | 321 | for (auto provider: m_backgroundProviders) { | ||
310 | fwDirs += provider->frameworkDirectoriesInBackground(path); | 322 | fwDirs += provider->frameworkDirectoriesInBackground(path); | ||
311 | } | 323 | } | ||
312 | 324 | | |||
313 | return fwDirs; | 325 | return runtimePathsInHost(fwDirs); | ||
314 | } | 326 | } | ||
315 | 327 | | |||
316 | Defines DefinesAndIncludesManager::definesInBackground(const QString& path) const | 328 | Defines DefinesAndIncludesManager::definesInBackground(const QString& path) const | ||
317 | { | 329 | { | ||
318 | QHash<QString, QString> defines; | 330 | QHash<QString, QString> defines; | ||
319 | 331 | | |||
320 | for (auto provider: m_backgroundProviders) { | 332 | for (auto provider: m_backgroundProviders) { | ||
321 | auto result = provider->definesInBackground(path); | 333 | auto result = provider->definesInBackground(path); | ||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |