Пример #1
0
void ReconcileProjectDlg::DoFindFiles()
{
    m_stalefiles.clear();
    m_newfiles.clear();

    ProjectPtr proj = ManagerST::Get()->GetProject(m_projname);
    wxCHECK_RET(proj, "Can't find a Project with the supplied name");

    // get list of files from the project
    Project::FileInfoVector_t projectfiles;
    proj->GetFilesMetadata(projectfiles);
    wxStringSet_t projectfilesSet;
    
    Project::FileInfoVector_t::const_iterator it = projectfiles.begin();
    for( ; it != projectfiles.end(); ++it ) {
        projectfilesSet.insert( it->GetFilename() );
    }
    
    std::vector<wxString> result;
    std::set_difference(m_allfiles.begin(), m_allfiles.end(), projectfilesSet.begin(), projectfilesSet.end(), std::back_inserter(result));
    m_newfiles.insert(result.begin(), result.end());

    // now run the diff reverse to get list of stale files
    m_stalefiles.clear();
    Project::FileInfoVector_t::const_iterator iter = projectfiles.begin();
    for(; iter != projectfiles.end(); ++iter ) {
        if ( !wxFileName::Exists( iter->GetFilename() ) ) {
            m_stalefiles.push_back( *iter );
        }
    }
}
Пример #2
0
void CodeFormatter::OnFormatProject(wxCommandEvent& e)
{
    wxUnusedVar(e);
    TreeItemInfo selectedItem = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    if(selectedItem.m_itemType != ProjectItem::TypeProject) {
        return;
    }

    ProjectPtr pProj = clCxxWorkspaceST::Get()->GetProject(selectedItem.m_text);
    CHECK_PTR_RET(pProj);

    Project::FileInfoVector_t allFiles;
    pProj->GetFilesMetadata(allFiles);

    std::vector<wxFileName> filesToFormat;
    // Filter non C++/JavaScript files
    for(size_t i = 0; i < allFiles.size(); ++i) {
        wxFileName fn(allFiles.at(i).GetFilename());
        if(fn.GetFullName() == "sqlite3.c") {
            // skip this famous a quite large file ...
            continue;
        }

        const wxString& filename = allFiles.at(i).GetFilename();
        if(FileExtManager::IsCxxFile(filename) || FileExtManager::IsJavascriptFile(filename)) {
            filesToFormat.push_back(allFiles.at(i).GetFilename());
        }
    }

    if(filesToFormat.empty()) {
        ::wxMessageBox(_("Nothing to be done here"));
        return;
    }

    wxString msg;
    msg << _("You are about to beautify ") << filesToFormat.size() << _(" files\nContinue?");
    if(wxYES != ::wxMessageBox(msg, _("Source Code Formatter"), wxYES_NO | wxCANCEL | wxCENTER)) {
        return;
    }

    // Format the files
    BatchFormat(filesToFormat);
}