Commit 3529e785 authored by Tobias Hunger's avatar Tobias Hunger

CppTools: Make create* methods return something

Change-Id: I20cfdaef23e9b7c48c9d3b4f27157e771fd9bc7f
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent a65630ef
......@@ -163,16 +163,17 @@ ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<void> &futureI
ProjectInfo ProjectInfoGenerator::generate()
{
m_projectInfo = ProjectInfo(m_projectUpdateInfo.project);
ProjectInfo projectInfo(m_projectUpdateInfo.project);
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
if (m_futureInterface.isCanceled())
return ProjectInfo();
createProjectParts(rpp);
for (ProjectPart::Ptr part : createProjectParts(rpp))
projectInfo.appendProjectPart(part);
}
return m_projectInfo;
return projectInfo;
}
static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawProjectPart,
......@@ -196,8 +197,9 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
return part;
}
void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPart)
QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPart)
{
QVector<ProjectPart::Ptr> result;
ProjectFileCategorizer cat(rawProjectPart.displayName,
rawProjectPart.files,
rawProjectPart.fileClassifier);
......@@ -210,49 +212,50 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
if (rawProjectPart.qtVersion == ProjectPart::Qt4_8_6AndOlder)
defaultVersion = ProjectPart::CXX11;
if (cat.hasCxxSources()) {
createProjectPart(rawProjectPart,
part,
cat.cxxSources(),
cat.partName("C++"),
defaultVersion,
ProjectPart::NoExtensions);
result << createProjectPart(rawProjectPart,
part,
cat.cxxSources(),
cat.partName("C++"),
defaultVersion,
ProjectPart::NoExtensions);
}
if (cat.hasObjcxxSources()) {
createProjectPart(rawProjectPart,
part,
cat.objcxxSources(),
cat.partName("Obj-C++"),
defaultVersion,
ProjectPart::ObjectiveCExtensions);
result << createProjectPart(rawProjectPart,
part,
cat.objcxxSources(),
cat.partName("Obj-C++"),
defaultVersion,
ProjectPart::ObjectiveCExtensions);
}
if (cat.hasCSources()) {
createProjectPart(rawProjectPart,
part,
cat.cSources(),
cat.partName("C"),
ProjectPart::LatestCVersion,
ProjectPart::NoExtensions);
result << createProjectPart(rawProjectPart,
part,
cat.cSources(),
cat.partName("C"),
ProjectPart::LatestCVersion,
ProjectPart::NoExtensions);
}
if (cat.hasObjcSources()) {
createProjectPart(rawProjectPart,
part,
cat.objcSources(),
cat.partName("Obj-C"),
ProjectPart::LatestCVersion,
ProjectPart::ObjectiveCExtensions);
result << createProjectPart(rawProjectPart,
part,
cat.objcSources(),
cat.partName("Obj-C"),
ProjectPart::LatestCVersion,
ProjectPart::ObjectiveCExtensions);
}
}
return result;
}
void ProjectInfoGenerator::createProjectPart(const RawProjectPart &rawProjectPart,
const ProjectPart::Ptr &templateProjectPart,
const ProjectFiles &projectFiles,
const QString &partName,
ProjectPart::LanguageVersion languageVersion,
ProjectPart::LanguageExtensions languageExtensions)
ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(const RawProjectPart &rawProjectPart,
const ProjectPart::Ptr &templateProjectPart,
const ProjectFiles &projectFiles,
const QString &partName,
ProjectPart::LanguageVersion languageVersion,
ProjectPart::LanguageExtensions languageExtensions)
{
ProjectPart::Ptr part(templateProjectPart->copy());
part->displayName = partName;
......@@ -277,7 +280,7 @@ void ProjectInfoGenerator::createProjectPart(const RawProjectPart &rawProjectPar
part->languageExtensions |= languageExtensions;
part->updateLanguageFeatures();
m_projectInfo.appendProjectPart(part);
return part;
}
} // namespace Internal
......
......@@ -41,19 +41,17 @@ public:
ProjectInfo generate();
private:
void createProjectParts(const RawProjectPart &rawProjectPart);
void createProjectPart(const RawProjectPart &rawProjectPart,
const ProjectPart::Ptr &templateProjectPart,
const ProjectFiles &projectFiles,
const QString &partName,
ProjectPart::LanguageVersion languageVersion,
ProjectPart::LanguageExtensions languageExtensions);
QVector<ProjectPart::Ptr> createProjectParts(const RawProjectPart &rawProjectPart);
ProjectPart::Ptr createProjectPart(const RawProjectPart &rawProjectPart,
const ProjectPart::Ptr &templateProjectPart,
const ProjectFiles &projectFiles,
const QString &partName,
ProjectPart::LanguageVersion languageVersion,
ProjectPart::LanguageExtensions languageExtensions);
private:
const QFutureInterface<void> &m_futureInterface;
const QFutureInterface<void> m_futureInterface;
const ProjectUpdateInfo &m_projectUpdateInfo;
ProjectInfo m_projectInfo;
};
} // namespace Internal
} // namespace CppTools
......@@ -62,9 +62,8 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo)
this, &CppProjectUpdater::onToolChainRemoved);
// Run the project info generator in a worker thread and continue if that one is finished.
const QFutureInterface<void> &futureInterface = m_futureInterface;
const QFuture<ProjectInfo> future = Utils::runAsync([=]() {
Internal::ProjectInfoGenerator generator(futureInterface, projectUpdateInfo);
Internal::ProjectInfoGenerator generator(m_futureInterface, projectUpdateInfo);
return generator.generate();
});
m_generateFutureWatcher.setFuture(future);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment