MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / parseProject

Method parseProject

src/plugins/cxx/cmake/project/cmakeasynparse.cpp:158–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void CmakeAsynParse::parseProject(QStandardItem *rootItem, const dpfservice::ProjectInfo &prjInfo)
159{
160 isStop = false;
161 if (!rootItem)
162 return;
163
164 TargetsManager::instance()->readTargets(prjInfo.buildFolder(), prjInfo.workspaceFolder());
165 auto cbpParser = TargetsManager::instance()->cbpParser();
166 // add cmakefile to tree first.
167 auto cmakeList = cbpParser->getCmakeFileList();
168 QSet<QString> cmakeFiles {};
169 for (auto &cmakeFile : cmakeList) {
170 if (isStop)
171 return;
172
173 QString cmakeFilePath = cmakeFile.get()->getfilePath();
174 if (cmakeFilePath.endsWith("CMakeLists.txt"))
175 cmakeFiles.insert(cmakeFilePath);
176 QFileInfo cmakeFileInfo(cmakeFilePath);
177 if (cmakeFileInfo.fileName().toLower() == kProjectFile.toLower()) {
178 auto cmakeParentItem = rootItem;
179 QString relativePath = QDir(prjInfo.workspaceFolder()).relativeFilePath(cmakeFileInfo.dir().path());
180 QString absolutePath = QDir(prjInfo.workspaceFolder()).absoluteFilePath(cmakeFileInfo.dir().path());
181 if (!relativePath.isEmpty() && relativePath != ".") {
182 cmakeParentItem = createParentItem(rootItem, relativePath, absolutePath);
183 }
184
185 auto cmakeFileItem = new QStandardItem();
186 cmakeFileItem->setText(cmakeFileInfo.fileName());
187 cmakeFileItem->setToolTip(cmakeFileInfo.filePath());
188 cmakeParentItem->appendRow(cmakeFileItem);
189 cmakeFileItem->setData(cmakeFileInfo.absoluteFilePath(), Project::FileIconRole);
190 cmakeFileItem->setData(cmakeFileInfo.absoluteFilePath(), Project::FilePathRole);
191
192 // monitor cmake file change to refresh project tree.
193 if (cmakeParentItem == rootItem) {
194 CmakeItemKeeper::instance()->addCmakeRootFile(rootItem, cmakeFilePath);
195 } else {
196 CmakeItemKeeper::instance()->addCmakeSubFiles(rootItem, { cmakeFilePath });
197 }
198 }
199 }
200
201 QSet<QString> commonFiles {};
202 const QList<CMakeBuildTarget> &targets = cbpParser->getBuildTargets();
203 for (auto target : targets) {
204 if (isStop)
205 return;
206
207 if (target.type == kUtility) {
208 continue;
209 }
210 QString targetRootPath = getTargetRootPath(target, prjInfo);
211 if (!QFileInfo(targetRootPath).exists())
212 continue;
213 QString relativePath = QDir(prjInfo.workspaceFolder()).relativeFilePath(QDir(targetRootPath).path());
214 QString absolutePath = QDir(prjInfo.workspaceFolder()).absoluteFilePath(QDir(targetRootPath).path());
215 QStandardItem *targetRootItem = rootItem;

Callers

nothing calls this directly

Calls 15

getTargetRootPathFunction · 0.85
setFunction · 0.85
readTargetsMethod · 0.80
cbpParserMethod · 0.80
endsWithMethod · 0.80
insertMethod · 0.80
fileNameMethod · 0.80
addCmakeRootFileMethod · 0.80
addCmakeSubFilesMethod · 0.80
startsWithMethod · 0.80
setSourceFilesMethod · 0.80

Tested by

no test coverage detected