forked from qt-creator/qt-creator
CppTools: Make create* methods return something
Change-Id: I20cfdaef23e9b7c48c9d3b4f27157e771fd9bc7f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -163,16 +163,17 @@ ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<void> &futureI
|
|||||||
|
|
||||||
ProjectInfo ProjectInfoGenerator::generate()
|
ProjectInfo ProjectInfoGenerator::generate()
|
||||||
{
|
{
|
||||||
m_projectInfo = ProjectInfo(m_projectUpdateInfo.project);
|
ProjectInfo projectInfo(m_projectUpdateInfo.project);
|
||||||
|
|
||||||
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
||||||
if (m_futureInterface.isCanceled())
|
if (m_futureInterface.isCanceled())
|
||||||
return ProjectInfo();
|
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,
|
static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawProjectPart,
|
||||||
@@ -196,8 +197,9 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
|
|||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPart)
|
QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPart)
|
||||||
{
|
{
|
||||||
|
QVector<ProjectPart::Ptr> result;
|
||||||
ProjectFileCategorizer cat(rawProjectPart.displayName,
|
ProjectFileCategorizer cat(rawProjectPart.displayName,
|
||||||
rawProjectPart.files,
|
rawProjectPart.files,
|
||||||
rawProjectPart.fileClassifier);
|
rawProjectPart.fileClassifier);
|
||||||
@@ -210,7 +212,7 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
|
|||||||
if (rawProjectPart.qtVersion == ProjectPart::Qt4_8_6AndOlder)
|
if (rawProjectPart.qtVersion == ProjectPart::Qt4_8_6AndOlder)
|
||||||
defaultVersion = ProjectPart::CXX11;
|
defaultVersion = ProjectPart::CXX11;
|
||||||
if (cat.hasCxxSources()) {
|
if (cat.hasCxxSources()) {
|
||||||
createProjectPart(rawProjectPart,
|
result << createProjectPart(rawProjectPart,
|
||||||
part,
|
part,
|
||||||
cat.cxxSources(),
|
cat.cxxSources(),
|
||||||
cat.partName("C++"),
|
cat.partName("C++"),
|
||||||
@@ -219,7 +221,7 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat.hasObjcxxSources()) {
|
if (cat.hasObjcxxSources()) {
|
||||||
createProjectPart(rawProjectPart,
|
result << createProjectPart(rawProjectPart,
|
||||||
part,
|
part,
|
||||||
cat.objcxxSources(),
|
cat.objcxxSources(),
|
||||||
cat.partName("Obj-C++"),
|
cat.partName("Obj-C++"),
|
||||||
@@ -228,7 +230,7 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat.hasCSources()) {
|
if (cat.hasCSources()) {
|
||||||
createProjectPart(rawProjectPart,
|
result << createProjectPart(rawProjectPart,
|
||||||
part,
|
part,
|
||||||
cat.cSources(),
|
cat.cSources(),
|
||||||
cat.partName("C"),
|
cat.partName("C"),
|
||||||
@@ -237,7 +239,7 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat.hasObjcSources()) {
|
if (cat.hasObjcSources()) {
|
||||||
createProjectPart(rawProjectPart,
|
result << createProjectPart(rawProjectPart,
|
||||||
part,
|
part,
|
||||||
cat.objcSources(),
|
cat.objcSources(),
|
||||||
cat.partName("Obj-C"),
|
cat.partName("Obj-C"),
|
||||||
@@ -245,9 +247,10 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
|
|||||||
ProjectPart::ObjectiveCExtensions);
|
ProjectPart::ObjectiveCExtensions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectInfoGenerator::createProjectPart(const RawProjectPart &rawProjectPart,
|
ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(const RawProjectPart &rawProjectPart,
|
||||||
const ProjectPart::Ptr &templateProjectPart,
|
const ProjectPart::Ptr &templateProjectPart,
|
||||||
const ProjectFiles &projectFiles,
|
const ProjectFiles &projectFiles,
|
||||||
const QString &partName,
|
const QString &partName,
|
||||||
@@ -277,7 +280,7 @@ void ProjectInfoGenerator::createProjectPart(const RawProjectPart &rawProjectPar
|
|||||||
part->languageExtensions |= languageExtensions;
|
part->languageExtensions |= languageExtensions;
|
||||||
part->updateLanguageFeatures();
|
part->updateLanguageFeatures();
|
||||||
|
|
||||||
m_projectInfo.appendProjectPart(part);
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public:
|
|||||||
ProjectInfo generate();
|
ProjectInfo generate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createProjectParts(const RawProjectPart &rawProjectPart);
|
QVector<ProjectPart::Ptr> createProjectParts(const RawProjectPart &rawProjectPart);
|
||||||
void createProjectPart(const RawProjectPart &rawProjectPart,
|
ProjectPart::Ptr createProjectPart(const RawProjectPart &rawProjectPart,
|
||||||
const ProjectPart::Ptr &templateProjectPart,
|
const ProjectPart::Ptr &templateProjectPart,
|
||||||
const ProjectFiles &projectFiles,
|
const ProjectFiles &projectFiles,
|
||||||
const QString &partName,
|
const QString &partName,
|
||||||
@@ -50,10 +50,8 @@ private:
|
|||||||
ProjectPart::LanguageExtensions languageExtensions);
|
ProjectPart::LanguageExtensions languageExtensions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QFutureInterface<void> &m_futureInterface;
|
const QFutureInterface<void> m_futureInterface;
|
||||||
const ProjectUpdateInfo &m_projectUpdateInfo;
|
const ProjectUpdateInfo &m_projectUpdateInfo;
|
||||||
|
|
||||||
ProjectInfo m_projectInfo;
|
|
||||||
};
|
};
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -62,9 +62,8 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo)
|
|||||||
this, &CppProjectUpdater::onToolChainRemoved);
|
this, &CppProjectUpdater::onToolChainRemoved);
|
||||||
|
|
||||||
// Run the project info generator in a worker thread and continue if that one is finished.
|
// 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([=]() {
|
const QFuture<ProjectInfo> future = Utils::runAsync([=]() {
|
||||||
Internal::ProjectInfoGenerator generator(futureInterface, projectUpdateInfo);
|
Internal::ProjectInfoGenerator generator(m_futureInterface, projectUpdateInfo);
|
||||||
return generator.generate();
|
return generator.generate();
|
||||||
});
|
});
|
||||||
m_generateFutureWatcher.setFuture(future);
|
m_generateFutureWatcher.setFuture(future);
|
||||||
|
|||||||
Reference in New Issue
Block a user