QString projectPartIdForFile(const QString &filePath) { const ProjectPart::Ptr projectPart = projectPartForFile(filePath); if (isProjectPartValid(projectPart)) return projectPart->id(); // OK, Project Part is still loaded return QString(); }
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; part->files = projectFiles; part->languageVersion = languageVersion; RawProjectPartFlags flags; ToolChainInfo tcInfo; if (languageVersion <= ProjectPart::LatestCVersion) { flags = rawProjectPart.flagsForC; tcInfo = m_projectUpdateInfo.cToolChainInfo; } // Use Cxx toolchain for C projects without C compiler in kit and for C++ code if (!tcInfo.isValid()) { flags = rawProjectPart.flagsForCxx; tcInfo = m_projectUpdateInfo.cxxToolChainInfo; } // TODO: If no toolchain is set, show a warning ToolChainEvaluator evaluator(*part.data(), flags, tcInfo); evaluator.evaluate(); part->languageExtensions |= languageExtensions; part->updateLanguageFeatures(); return part; }
static QStringList build(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind) { if (pPart.isNull()) return QStringList(); LibClangOptionsBuilder optionsBuilder(pPart); if (verboseRunLog().isDebugEnabled()) optionsBuilder.add(QLatin1String("-v")); optionsBuilder.addLanguageOption(fileKind); optionsBuilder.addOptionsForLanguage(maybeIncludeBorlandExtensions()); optionsBuilder.addToolchainAndProjectDefines(); static const QString resourceDir = getResourceDir(); if (!resourceDir.isEmpty()) { optionsBuilder.add(QLatin1String("-nostdlibinc")); optionsBuilder.add(QLatin1String("-I") + resourceDir); optionsBuilder.add(QLatin1String("-undef")); } optionsBuilder.addHeaderPathOptions(); // Inject header file static const QString injectedHeader = ICore::instance()->resourcePath() + QLatin1String("/cplusplus/qt%1-qobjectdefs-injected.h"); // if (pPart->qtVersion == ProjectPart::Qt4) { // builder.addOption(QLatin1String("-include")); // builder.addOption(injectedHeader.arg(QLatin1Char('4'))); // } if (pPart->qtVersion == ProjectPart::Qt5) { optionsBuilder.add(QLatin1String("-include")); optionsBuilder.add(injectedHeader.arg(QLatin1Char('5'))); } if (!pPart->projectConfigFile.isEmpty()) { optionsBuilder.add(QLatin1String("-include")); optionsBuilder.add(pPart->projectConfigFile); } optionsBuilder.add(QLatin1String("-fmessage-length=0")); optionsBuilder.add(QLatin1String("-fdiagnostics-show-note-include-stack")); optionsBuilder.add(QLatin1String("-fmacro-backtrace-limit=0")); optionsBuilder.add(QLatin1String("-fretain-comments-from-system-headers")); // TODO: -Xclang -ferror-limit -Xclang 0 ? return optionsBuilder.options(); }
static QStringList build(const ProjectPart::Ptr &projectPart, ProjectFile::Kind fileKind) { if (projectPart.isNull()) return QStringList(); LibClangOptionsBuilder optionsBuilder(projectPart); if (verboseRunLog().isDebugEnabled()) optionsBuilder.add(QLatin1String("-v")); optionsBuilder.addLanguageOption(fileKind); optionsBuilder.addOptionsForLanguage(maybeIncludeBorlandExtensions()); optionsBuilder.addToolchainAndProjectDefines(); optionsBuilder.addResourceDirOptions(); optionsBuilder.addWrappedQtHeadersIncludePath(); optionsBuilder.addHeaderPathOptions(); optionsBuilder.addProjectConfigFileInclude(); optionsBuilder.addExtraOptions(); return optionsBuilder.options(); }
bool isProjectPartValid(const ProjectPart::Ptr projectPart) { if (projectPart) return CppModelManager::instance()->projectPartForId(projectPart->id()); return false; }