AddFunctionsImpDlg::AddFunctionsImpDlg(wxWindow* parent, const TagEntryPtrVector_t &tags, const wxString &targetFile)
    : AddFunctionsImplBaseDlg(parent)
{
    unsigned int colCount = m_dataviewModel->GetColCount();
    m_dataviewModel = new MyAddFunctionsModel();
    m_dataviewModel->SetColCount( colCount );
    m_dataview->AssociateModel( m_dataviewModel.get() );

    m_tags.insert(m_tags.end(), tags.begin(), tags.end());
    for(size_t i=0; i<m_tags.size(); ++i) {

        wxVector<wxVariant> cols;
        cols.push_back(true);
        cols.push_back( m_tags.at(i)->GetDisplayName() );

        // keep the implementation as the client data
        wxString body;
        TagEntryPtr tag = m_tags.at(i);
        tag->SetSignature( TagsManagerST::Get()->NormalizeFunctionSig( tag->GetSignature(), Normalize_Func_Name ) );
        body << TagsManagerST::Get()->FormatFunction(tag, FunctionFormat_Impl);
        body << wxT("\n");
        m_dataviewModel->AppendItem( wxDataViewItem(0), cols, new wxStringClientData(body) );
    }
    m_filePicker->SetPath( targetFile );
    WindowAttrManager::Load(this, "AddFunctionsImpDlg", NULL);
}
Beispiel #2
0
TagEntryPtr RefactoringEngine::SyncSignature(const wxFileName& fn,
        int line,
        int pos,
        const wxString &word,
        const wxString &text,
        const wxString &expr)
{
    TagEntryPtr func = TagsManagerST::Get()->FunctionFromFileLine(fn, line);
    if(!func)
        return NULL;

    bool bIsImpl = (func->GetKind() == wxT("function"));

    // Found the counterpart
    std::vector<TagEntryPtr> tags;
    TagsManagerST::Get()->FindImplDecl(fn, line, expr, word, text, tags, !bIsImpl);
    if(tags.size() != 1)
        return NULL;

    TagEntryPtr tag = tags.at(0);
    if(tag->IsMethod() == false)
        return NULL;

    wxString signature;
    if (bIsImpl) {
        // The "source" is an implementaion, which means that we need to prepare declaration signature
        // this could be tricky since we might lose the "default" values
        signature = TagsManagerST::Get()->NormalizeFunctionSig(func->GetSignature(), Normalize_Func_Default_value|Normalize_Func_Name|Normalize_Func_Reverse_Macro);
    } else {
        // Prepare an "implementation" signature
        signature = TagsManagerST::Get()->NormalizeFunctionSig(func->GetSignature(), Normalize_Func_Name|Normalize_Func_Reverse_Macro);
    }

    tag->SetSignature(signature);
    return tag;
}