Beispiel #1
0
void CppCheckPlugin::OnCheckWorkspaceItem(wxCommandEvent& e)
{
    if(m_cppcheckProcess) {
        clLogMessage(_("CppCheckPlugin: CppCheck is currently busy please wait for it to complete the current check"));
        return;
    }

    if(!m_mgr->GetWorkspace() || !m_mgr->IsWorkspaceOpen()) { return; }

    TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    if(item.m_itemType == ProjectItem::TypeWorkspace) {

        // retrieve complete list of source files of the workspace
        wxArrayString projects;
        wxString err_msg;
        std::vector<wxFileName> tmpfiles;
        m_mgr->GetWorkspace()->GetProjectList(projects);

        for(size_t i = 0; i < projects.GetCount(); i++) {
            ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projects.Item(i), err_msg);
            if(proj) { proj->GetFilesAsVectorOfFileName(tmpfiles); }
        }

        // only C/C++ files
        for(size_t i = 0; i < tmpfiles.size(); i++) {
            if(FileExtManager::GetType(tmpfiles.at(i).GetFullPath()) == FileExtManager::TypeSourceC ||
               FileExtManager::GetType(tmpfiles.at(i).GetFullPath()) == FileExtManager::TypeSourceCpp) {
                m_filelist.Add(tmpfiles.at(i).GetFullPath());
            }
        }
    }
    DoStartTest();
}
Beispiel #2
0
void Copyright::OnProjectInsertCopyrights(wxCommandEvent& e)
{
    // pop up the projects selection dialog
    if(m_mgr->IsWorkspaceOpen() == false) {
        wxMessageBox(_("Batch insert requires a workspace to be opened"), _("CodeLite"), wxICON_WARNING | wxOK);
        return;
    }

    if(!m_mgr->SaveAll()) return;

    // read configuration
    CopyrightsConfigData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CopyrightsConfig"), &data);

    wxString content;
    if(!Validate(content)) { return; }

    // get the project to work on
    TreeItemInfo info = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    wxString project_name = info.m_text;

    wxString err_msg;
    std::vector<wxFileName> files;
    std::vector<wxFileName> filtered_files;
    // loop over the project and collect list of files to work with
    ProjectPtr p = m_mgr->GetWorkspace()->GetProject(project_name);
    if(!p) { return; }

    p->GetFilesAsVectorOfFileName(files);

    // filter non matched files
    wxString mask(data.GetFileMasking());
    mask.Replace(wxT("*."), wxEmptyString);
    mask = mask.Trim().Trim(false);

    wxArrayString exts = wxStringTokenize(mask, wxT(";"));

    // filter out non-matching files (according to masking)
    for(size_t i = 0; i < files.size(); i++) {
        if(exts.Index(files.at(i).GetExt(), false) != wxNOT_FOUND) {
            // valid file
            filtered_files.push_back(files.at(i));
        }
    }

    // update files
    if(filtered_files.empty() == false) { MassUpdate(filtered_files, content); }
}
Beispiel #3
0
void Copyright::OnBatchInsertCopyrights(wxCommandEvent& e)
{
    // pop up the projects selection dialog
    if(m_mgr->IsWorkspaceOpen() == false) {
        wxMessageBox(_("Batch insert requires a workspace to be opened"), _("CodeLite"), wxICON_WARNING | wxOK);
        return;
    }

    if(!m_mgr->SaveAll()) return;

    // read configuration
    CopyrightsConfigData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CopyrightsConfig"), &data);

    wxString content;
    if(!Validate(content)) { return; }

    CopyrightsProjectSelDlg dlg(m_mgr->GetTheApp()->GetTopWindow(), m_mgr->GetWorkspace());
    if(dlg.ShowModal() == wxID_OK) {
        wxArrayString projects;
        dlg.GetProjects(projects);

        // expand constants
        std::vector<wxFileName> files;
        std::vector<wxFileName> filtered_files;
        // loop over the project and collect list of files to work with
        for(size_t i = 0; i < projects.size(); i++) {
            ProjectPtr p = m_mgr->GetWorkspace()->GetProject(projects.Item(i));
            if(p) { p->GetFilesAsVectorOfFileName(files); }
        }

        wxString mask(data.GetFileMasking());
        mask.Replace(wxT("*."), wxEmptyString);
        mask = mask.Trim().Trim(false);

        wxArrayString exts = ::wxStringTokenize(mask, wxT(";"));

        // filter out non-matching files (according to masking)
        for(size_t i = 0; i < files.size(); i++) {
            if(exts.Index(files.at(i).GetExt(), false) != wxNOT_FOUND) {
                // valid file
                filtered_files.push_back(files.at(i));
            }
        }

        if(filtered_files.empty() == false) { MassUpdate(filtered_files, content); }
    }
}
Beispiel #4
0
void CppCheckPlugin::OnCheckProjectItem(wxCommandEvent& e)
{
    if(m_cppcheckProcess) {
        clLogMessage(_("CppCheckPlugin: CppCheck is currently busy please wait for it to complete the current check"));
        return;
    }

    ProjectPtr proj = FindSelectedProject();
    if(!proj) { return; }

    // retrieve complete list of source files of the workspace
    std::vector<wxFileName> tmpfiles;
    proj->GetFilesAsVectorOfFileName(tmpfiles);

    // only C/C++ files
    for(size_t i = 0; i < tmpfiles.size(); i++) {
        if(FileExtManager::GetType(tmpfiles.at(i).GetFullPath()) == FileExtManager::TypeSourceC ||
           FileExtManager::GetType(tmpfiles.at(i).GetFullPath()) == FileExtManager::TypeSourceCpp) {
            m_filelist.Add(tmpfiles.at(i).GetFullPath());
        }
    }

    DoStartTest(proj);
}