forked from qt-creator/qt-creator
ProjectExplorer: Merge IDevice::{filePath,mapToGlobalPath}
They were doing practically the same. Keep the 'filePath' name for now until something more fitting comes up. Change-Id: I96ca4da4b30b7b463583e002f2c19d6e6c5541e6 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -773,17 +773,11 @@ bool DockerDevice::usableAsBuildDevice() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath DockerDevice::mapToGlobalPath(const FilePath &pathOnDevice) const
|
FilePath DockerDevice::filePath(const QString &pathOnDevice) const
|
||||||
{
|
{
|
||||||
if (pathOnDevice.needsDevice()) {
|
|
||||||
// Already correct form, only sanity check it's ours...
|
|
||||||
QTC_CHECK(handlesFile(pathOnDevice));
|
|
||||||
return pathOnDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME,
|
return FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME,
|
||||||
d->repoAndTagEncoded(),
|
d->repoAndTagEncoded(),
|
||||||
pathOnDevice.path());
|
pathOnDevice);
|
||||||
|
|
||||||
// The following would work, but gives no hint on repo and tag
|
// The following would work, but gives no hint on repo and tag
|
||||||
// result.setScheme("docker");
|
// result.setScheme("docker");
|
||||||
|
@@ -81,9 +81,8 @@ public:
|
|||||||
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
||||||
bool usableAsBuildDevice() const override;
|
bool usableAsBuildDevice() const override;
|
||||||
|
|
||||||
Utils::FilePath mapToGlobalPath(const Utils::FilePath &pathOnDevice) const override;
|
|
||||||
|
|
||||||
Utils::FilePath rootPath() const override;
|
Utils::FilePath rootPath() const override;
|
||||||
|
Utils::FilePath filePath(const QString &pathOnDevice) const override;
|
||||||
|
|
||||||
bool handlesFile(const Utils::FilePath &filePath) const override;
|
bool handlesFile(const Utils::FilePath &filePath) const override;
|
||||||
bool ensureReachable(const Utils::FilePath &other) const override;
|
bool ensureReachable(const Utils::FilePath &other) const override;
|
||||||
|
@@ -167,7 +167,7 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
|
|||||||
paths.append(FilePath::fromString(path.trimmed()));
|
paths.append(FilePath::fromString(path.trimmed()));
|
||||||
}
|
}
|
||||||
paths = Utils::transform(paths, [dockerDevice](const FilePath &path) {
|
paths = Utils::transform(paths, [dockerDevice](const FilePath &path) {
|
||||||
return dockerDevice->mapToGlobalPath(path);
|
return dockerDevice->filePath(path.path());
|
||||||
});
|
});
|
||||||
return paths;
|
return paths;
|
||||||
};
|
};
|
||||||
|
@@ -139,10 +139,9 @@ bool DesktopDevice::handlesFile(const FilePath &filePath) const
|
|||||||
return !filePath.needsDevice();
|
return !filePath.needsDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath DesktopDevice::mapToGlobalPath(const Utils::FilePath &pathOnDevice) const
|
FilePath DesktopDevice::filePath(const QString &pathOnDevice) const
|
||||||
{
|
{
|
||||||
QTC_CHECK(!pathOnDevice.needsDevice());
|
return FilePath::fromParts({}, {}, pathOnDevice);
|
||||||
return pathOnDevice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment DesktopDevice::systemEnvironment() const
|
Environment DesktopDevice::systemEnvironment() const
|
||||||
|
@@ -34,9 +34,9 @@ public:
|
|||||||
|
|
||||||
bool handlesFile(const Utils::FilePath &filePath) const override;
|
bool handlesFile(const Utils::FilePath &filePath) const override;
|
||||||
Utils::Environment systemEnvironment() const override;
|
Utils::Environment systemEnvironment() const override;
|
||||||
Utils::FilePath mapToGlobalPath(const Utils::FilePath &pathOnDevice) const override;
|
|
||||||
|
|
||||||
Utils::FilePath rootPath() const override;
|
Utils::FilePath rootPath() const override;
|
||||||
|
Utils::FilePath filePath(const QString &pathOnDevice) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DesktopDevice();
|
DesktopDevice();
|
||||||
|
@@ -200,20 +200,10 @@ DeviceFileAccess *IDevice::fileAccess() const
|
|||||||
return d->fileAccess;
|
return d->fileAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath IDevice::mapToGlobalPath(const FilePath &pathOnDevice) const
|
|
||||||
{
|
|
||||||
if (pathOnDevice.needsDevice()) {
|
|
||||||
// Already correct form, only sanity check it's ours...
|
|
||||||
QTC_CHECK(handlesFile(pathOnDevice));
|
|
||||||
return pathOnDevice;
|
|
||||||
}
|
|
||||||
// match DeviceManager::deviceForPath
|
|
||||||
return FilePath::fromParts(u"device", id().toString(), pathOnDevice.path());
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath IDevice::filePath(const QString &pathOnDevice) const
|
FilePath IDevice::filePath(const QString &pathOnDevice) const
|
||||||
{
|
{
|
||||||
return mapToGlobalPath(FilePath::fromString(pathOnDevice));
|
// match DeviceManager::deviceForPath
|
||||||
|
return FilePath::fromParts(u"device", id().toString(), pathOnDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDevice::handlesFile(const FilePath &filePath) const
|
bool IDevice::handlesFile(const FilePath &filePath) const
|
||||||
@@ -226,8 +216,8 @@ bool IDevice::handlesFile(const FilePath &filePath) const
|
|||||||
FilePath IDevice::searchExecutableInPath(const QString &fileName) const
|
FilePath IDevice::searchExecutableInPath(const QString &fileName) const
|
||||||
{
|
{
|
||||||
FilePaths paths;
|
FilePaths paths;
|
||||||
for (const FilePath &path : systemEnvironment().path())
|
for (const FilePath &pathEntry : systemEnvironment().path())
|
||||||
paths.append(mapToGlobalPath(path));
|
paths.append(filePath(pathEntry.path()));
|
||||||
return searchExecutable(fileName, paths);
|
return searchExecutable(fileName, paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +225,7 @@ FilePath IDevice::searchExecutable(const QString &fileName, const FilePaths &dir
|
|||||||
{
|
{
|
||||||
for (FilePath dir : dirs) {
|
for (FilePath dir : dirs) {
|
||||||
if (!handlesFile(dir)) // Allow device-local dirs to be used.
|
if (!handlesFile(dir)) // Allow device-local dirs to be used.
|
||||||
dir = mapToGlobalPath(dir);
|
dir = filePath(dir.path());
|
||||||
QTC_CHECK(handlesFile(dir));
|
QTC_CHECK(handlesFile(dir));
|
||||||
const FilePath candidate = dir / fileName;
|
const FilePath candidate = dir / fileName;
|
||||||
if (candidate.isExecutableFile())
|
if (candidate.isExecutableFile())
|
||||||
|
@@ -189,7 +189,7 @@ public:
|
|||||||
void setMachineType(MachineType machineType);
|
void setMachineType(MachineType machineType);
|
||||||
|
|
||||||
virtual Utils::FilePath rootPath() const;
|
virtual Utils::FilePath rootPath() const;
|
||||||
Utils::FilePath filePath(const QString &pathOnDevice) const;
|
virtual Utils::FilePath filePath(const QString &pathOnDevice) const;
|
||||||
|
|
||||||
Utils::FilePath debugServerPath() const;
|
Utils::FilePath debugServerPath() const;
|
||||||
void setDebugServerPath(const Utils::FilePath &path);
|
void setDebugServerPath(const Utils::FilePath &path);
|
||||||
@@ -219,8 +219,6 @@ public:
|
|||||||
Utils::DeviceFileAccess *fileAccess() const;
|
Utils::DeviceFileAccess *fileAccess() const;
|
||||||
virtual bool handlesFile(const Utils::FilePath &filePath) const;
|
virtual bool handlesFile(const Utils::FilePath &filePath) const;
|
||||||
|
|
||||||
virtual Utils::FilePath mapToGlobalPath(const Utils::FilePath &pathOnDevice) const;
|
|
||||||
|
|
||||||
virtual Utils::FilePath searchExecutableInPath(const QString &fileName) const;
|
virtual Utils::FilePath searchExecutableInPath(const QString &fileName) const;
|
||||||
virtual Utils::FilePath searchExecutable(const QString &fileName,
|
virtual Utils::FilePath searchExecutable(const QString &fileName,
|
||||||
const Utils::FilePaths &dirs) const;
|
const Utils::FilePaths &dirs) const;
|
||||||
|
@@ -1120,7 +1120,7 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
|
|||||||
compilerPaths << candidate;
|
compilerPaths << candidate;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const FilePath globalDir = device->mapToGlobalPath(deviceDir);
|
const FilePath globalDir = device->filePath(deviceDir.path());
|
||||||
globalDir.iterateDirectory(callBack, {nameFilters, QDir::Files | QDir::Executable});
|
globalDir.iterateDirectory(callBack, {nameFilters, QDir::Files | QDir::Executable});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -119,7 +119,7 @@ FilePath ProjectConfiguration::mapFromBuildDeviceToGlobalPath(const FilePath &pa
|
|||||||
{
|
{
|
||||||
IDevice::ConstPtr dev = BuildDeviceKitAspect::device(kit());
|
IDevice::ConstPtr dev = BuildDeviceKitAspect::device(kit());
|
||||||
QTC_ASSERT(dev, return path);
|
QTC_ASSERT(dev, return path);
|
||||||
return dev->mapToGlobalPath(path);
|
return dev->filePath(path.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
Id ProjectExplorer::idFromMap(const QVariantMap &map)
|
Id ProjectExplorer::idFromMap(const QVariantMap &map)
|
||||||
|
Reference in New Issue
Block a user