bool Parser::ParseProject(const filesystem::path& filePath) { if (filePath.str().empty()) { std::cout << "invalid project filename" << std::endl; return false; } auto project = JsonImporter::ImportProject(pimpl_->GetFileManager(), filePath); return ParseProject(project.get()); }
bool Parser::ParseWorkspace(const Workspace* workspace) { if (workspace == nullptr) { std::cout << "invalid workspace" << std::endl; return false; } std::cout << "{ libclang index version " << CINDEX_VERSION_STRING << " }" << std::endl; std::cout << "{ libclang " << clang::String(clang_getClangVersion()).Get() << " }" << std::endl; std::cout << std::endl; std::cout << "> workspace : " << workspace->GetName() << std::endl; { ScopeTimer timer([](double time) { std::cout << "> " << time << "s" << std::endl; }); auto originalOutput = outputDirectory_; for (auto& project : workspace->GetProjects()) { outputDirectory_ = originalOutput / project->GetName(); internal::EnsureDirectoryExists(outputDirectory_); if (!ParseProject(project.get())) { return false; } } outputDirectory_ = originalOutput; } reflection::TypeEnumerator enumerator; pimpl_->GetTypeRegistry().Accept(enumerator); if (listTypes_) { internal::ListTypes(enumerator); } pimpl_->GetDatabase().Initialize(outputDirectory_ / "registry.db"); internal::SaveTypes(enumerator, pimpl_->GetDatabase()); return true; }
void CodeStatExecDlg::DoParseProject(int index) { if (m_cache[index].isParsed || index == 0) return; m_progress = new wxProgressDialog(_("Code Statistics plugin"),_("Parsing project files. Please wait...")); cbProject* project = Manager::Get()->GetProjectManager()->GetProjects()->Item(index - 1); m_currentFile = 0; m_numFiles = project->GetFilesCount(); m_cache[index]=ParseProject(index, nullptr); m_progress->Update(100); delete m_progress; m_progress = nullptr; m_cache[index].isParsed = true; }
void CodeStatExecDlg::DoParseWorkspace() { ProjectCodeStats& statWS = m_cache[0]; if (statWS.isParsed) return; m_progress = new wxProgressDialog(_("Code Statistics plugin"),_("Parsing workspace files. Please wait...")); m_currentFile = 0; m_numFiles = 0; ProjectsArray* projects = Manager::Get()->GetProjectManager()->GetProjects(); for (size_t i = 0, count = projects->GetCount(); i < count; ++i) m_numFiles += projects->Item(i)->GetFilesCount(); ParsedFileNamesSet parsedFileNames; for (size_t i = 1, count = projects->GetCount(); i < count + 1; ++i) { ProjectCodeStats statProject = ParseProject(i, &parsedFileNames); statWS.numFiles += statProject.numFiles; statWS.numFilesNotFound += statProject.numFilesNotFound; statWS.numSkippedFiles += statProject.numSkippedFiles; statWS.codeLines += statProject.codeLines; statWS.emptyLines += statProject.emptyLines; statWS.commentLines += statProject.commentLines; statWS.codeAndCommentLines += statProject.codeAndCommentLines; statWS.totalLines += statProject.totalLines ; } statWS.isParsed = true; m_progress->Update(100); delete m_progress; m_progress = nullptr; }