Esempio n. 1
0
void TagsOptionsDlg::Parse()
{
    // Prepate list of files to work on
    wxArrayString files = wxStringTokenize(m_textCtrlFilesList->GetValue(), wxT(" \t"), wxTOKEN_STRTOK);
    wxArrayString searchPaths = GetCTagsSearchPaths();
    wxArrayString fullpathsArr;

    for(size_t i = 0; i < files.size(); i++) {
        wxString file = files[i].Trim().Trim(false);
        if(file.IsEmpty()) continue;

        for(size_t xx = 0; xx < searchPaths.size(); xx++) {
            wxString fullpath;
            fullpath << searchPaths.Item(xx) << wxFileName::GetPathSeparator() << file;
            wxFileName fn(fullpath);
            if(fn.FileExists()) {
                fullpathsArr.Add(fn.GetFullPath());
                break;
            }
        }
    }

    // Clear the PreProcessor table
    PPTable::Instance()->Clear();
    for(size_t i = 0; i < fullpathsArr.size(); i++)
        PPScan(fullpathsArr.Item(i), true);

    // Open an editor and print out the results
    IEditor* editor = PluginManager::Get()->NewEditor();
    if(editor) {
        editor->AppendText(PPTable::Instance()->Export());
        CopyData();
        EndModal(wxID_OK);
    }
}
void SvnDiffHandler::Process(const wxString& output)
{
    // Open the changes inside the editor only if we are not using an external
    // diff viewer
    if(GetPlugin()->GetSettings().GetFlags() & SvnUseExternalDiff)
        return;

    IEditor *editor = GetPlugin()->GetManager()->NewEditor();
    if(editor) {
        // Set the lexer name to 'Diff'
        editor->SetLexerName(wxT("Diff"));
        editor->AppendText(output);
    }
}
void MemCheckOutputView::SuppressErrors(unsigned int mode, wxDataViewItem* dvItem)
{
    if(m_mgr->OpenFile(m_choiceSuppFile->GetStringSelection())) {
        IEditor* editor = m_mgr->GetActiveEditor();
        if(editor) {
            editor->GetCtrl()->DocumentEnd();
            editor->GetCtrl()->Home();
            int posStart = editor->GetCtrl()->GetCurrentPos();
            editor->AppendText(wxString::Format("\n# Added %s", wxDateTime::Now().Format("%F %T")));

            switch(mode) {
            case SUPPRESS_CLICKED: {
                MemCheckErrorReferrer* errorRef =
                    dynamic_cast<MemCheckErrorReferrer*>(m_dataViewCtrlErrorsModel->GetClientObject(*dvItem));
                // TODO ? print error message?
                if(!errorRef) break;
                editor->AppendText(wxString::Format("\n%s", errorRef->Get().getSuppression()));
                errorRef->Get().suppressed = true;
            } break;

            case SUPPRESS_CHECKED: {
                wxVariant variant;
                wxDataViewItemArray items;
                m_dataViewCtrlErrorsModel->GetChildren(wxDataViewItem(0), items);
                int supColumn = GetColumnByName(_("Suppress"));
                if(supColumn == wxNOT_FOUND) {
                    return;
                }

                MemCheckErrorReferrer* errorRef;
                for(wxDataViewItemArray::iterator it = items.begin(); it != items.end(); ++it) {
                    m_dataViewCtrlErrorsModel->GetValue(variant, *it, supColumn);
                    if(variant.GetBool()) {
                        errorRef =
                            dynamic_cast<MemCheckErrorReferrer*>(m_dataViewCtrlErrorsModel->GetClientObject(*it));
                        editor->AppendText(wxString::Format("\n%s", errorRef->Get().getSuppression()));
                        errorRef->Get().suppressed = true;
                    }
                }
            } break;

            case SUPPRESS_ALL:
                for(size_t item = 0; item < m_filterResults.size(); ++item) {
                    editor->AppendText(wxString::Format("\n%s", m_filterResults[item]->getSuppression()));
                    m_filterResults[item]->suppressed = true;
                }
                break;

            case SUPPRESS_SELECTED:
                long item = -1;
                for(;;) {
                    item = m_listCtrlErrors->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
                    if(item == -1) break;
                    editor->AppendText(wxString::Format("\n%s", m_filterResults[item]->getSuppression()));
                    m_filterResults[item]->suppressed = true;
                }
                break;
            }

            editor->AppendText(wxT("\n"));
            editor->GetCtrl()->DocumentEnd();
            int textLen = editor->GetCtrl()->GetCurrentPos() - posStart;
            editor->SelectText(posStart, textLen);
            wxCommandEvent saveEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("save_file"));
            m_mgr->GetTheApp()->GetTopWindow()->GetEventHandler()->ProcessEvent(saveEvent);

            // reload pages after suppression
            if(m_plugin->GetSettings()->GetOmitSuppressed()) {
                switch(mode) {
                case SUPPRESS_CLICKED:
                case SUPPRESS_CHECKED:
                    ResetItemsView();
                    ShowPageView(m_currentPage);
                    itemsInvalidSupp = true;
                    break;
                case SUPPRESS_ALL:
                case SUPPRESS_SELECTED:
                    ResetItemsSupp();
                    ApplyFilterSupp(FILTER_STRING);
                    itemsInvalidView = true;
                    break;
                }
            }
        }
    }
}