| 1303 | } |
| 1304 | |
| 1305 | QString ProjectController::mapSourceBuild( const QString& path_, bool reverse, bool fallbackRoot ) const |
| 1306 | { |
| 1307 | Q_D(const ProjectController); |
| 1308 | |
| 1309 | Path path(path_); |
| 1310 | IProject* sourceDirProject = nullptr, *buildDirProject = nullptr; |
| 1311 | for (IProject* proj : std::as_const(d->m_projects)) { |
| 1312 | if(proj->path().isParentOf(path) || proj->path() == path) |
| 1313 | sourceDirProject = proj; |
| 1314 | if(proj->buildSystemManager()) |
| 1315 | { |
| 1316 | Path buildDir = proj->buildSystemManager()->buildDirectory(proj->projectItem()); |
| 1317 | if(buildDir.isValid() && (buildDir.isParentOf(path) || buildDir == path)) |
| 1318 | buildDirProject = proj; |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | if(!reverse) |
| 1323 | { |
| 1324 | // Map-target is the build directory |
| 1325 | if(sourceDirProject && sourceDirProject->buildSystemManager()) |
| 1326 | { |
| 1327 | // We're in the source, map into the build directory |
| 1328 | QString relativePath = sourceDirProject->path().relativePath(path); |
| 1329 | |
| 1330 | Path build = sourceDirProject->buildSystemManager()->buildDirectory(sourceDirProject->projectItem()); |
| 1331 | build.addPath(relativePath); |
| 1332 | while(!QFile::exists(build.path())) |
| 1333 | build = build.parent(); |
| 1334 | return build.pathOrUrl(); |
| 1335 | }else if(buildDirProject && fallbackRoot) |
| 1336 | { |
| 1337 | // We're in the build directory, map to the build directory root |
| 1338 | return buildDirProject->buildSystemManager()->buildDirectory(buildDirProject->projectItem()).pathOrUrl(); |
| 1339 | } |
| 1340 | }else{ |
| 1341 | // Map-target is the source directory |
| 1342 | if(buildDirProject) |
| 1343 | { |
| 1344 | Path build = buildDirProject->buildSystemManager()->buildDirectory(buildDirProject->projectItem()); |
| 1345 | // We're in the source, map into the build directory |
| 1346 | QString relativePath = build.relativePath(path); |
| 1347 | |
| 1348 | Path source = buildDirProject->path(); |
| 1349 | source.addPath(relativePath); |
| 1350 | while(!QFile::exists(source.path())) |
| 1351 | source = source.parent(); |
| 1352 | return source.pathOrUrl(); |
| 1353 | }else if(sourceDirProject && fallbackRoot) |
| 1354 | { |
| 1355 | // We're in the source directory, map to the root |
| 1356 | return sourceDirProject->path().pathOrUrl(); |
| 1357 | } |
| 1358 | } |
| 1359 | return QString(); |
| 1360 | } |
| 1361 | |
| 1362 | void ProjectController::reparseProject(IProject* project, bool forceUpdate, bool forceAll) |
nothing calls this directly
no test coverage detected