Пример #1
0
void Cscope::OnCreateDB(wxCommandEvent& e)
{
    // sanity
    if(m_mgr->IsWorkspaceOpen() == false) {
        return;
    }

    m_cscopeWin->Clear();
    wxString list_file = DoCreateListFile(true);

    // get the reverted index option
    wxString command;
    wxString endMsg;
    CScopeConfData settings;

    command << GetCscopeExeName();

    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
    if(settings.GetBuildRevertedIndexOption()) {
        command << wxT(" -q");
        endMsg << _("Recreated inverted CScope DB");
    } else {
        command << wxT(" -b");
        endMsg << _("Recreated CScope DB");
    }

    // Do the actual create db
    // since the process is always running from the workspace
    // directory, there is no need to specify the full path of the list file

    command << wxT(" -L -i cscope_file.list");
    DoCscopeCommand(command, wxEmptyString, endMsg);
}
Пример #2
0
void Cscope::OnFindFunctionsCallingThisFunction(wxCommandEvent& e)
{
    wxString word = GetSearchPattern();
    if(word.IsEmpty()) {
        return;
    }

    m_cscopeWin->Clear();
    wxString list_file = DoCreateListFile(false);

    // get the rebuild option
    wxString rebuildOption = wxT("");
    CScopeConfData settings;

    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
    if(!settings.GetRebuildOption()) {
        rebuildOption = wxT(" -d");
    }

    // Do the actual search
    wxString command;
    wxString endMsg;
    command << GetCscopeExeName() << rebuildOption << wxT(" -L -3 ") << word << wxT(" -i ") << list_file;
    endMsg << _("cscope results for: functions calling '") << word << wxT("'");
    DoCscopeCommand(command, word, endMsg);
}
Пример #3
0
void Cscope::OnFindSymbol(wxCommandEvent &e)
{
	// sanity
	if ( m_mgr->GetActiveEditor() == NULL ) {
		return;
	}
	wxString word = m_mgr->GetActiveEditor()->GetWordAtCaret();
	if (word.IsEmpty()) {
		return;
	}

	m_cscopeWin->Clear();
	wxString list_file = DoCreateListFile(false);

	// get the rebuild option
	wxString rebuildOption = wxT("");
	CScopeConfData settings;

	m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
	if (!settings.GetRebuildOption())
	{
		rebuildOption = wxT(" -d");
	}

	//Do the actual search
	wxString command;
	wxString endMsg;
	command << GetCscopeExeName() << rebuildOption << wxT(" -L -0 ") << word << wxT(" -i ") << list_file;
	endMsg << wxT("cscope results for: find C symbol '") << word << wxT("'");
	DoCscopeCommand(command, word, endMsg);
}
Пример #4
0
void Cscope::OnFindGlobalDefinition(wxCommandEvent& e)
{
    wxString word = GetSearchPattern();
    if(word.IsEmpty()) {
        return;
    }
    m_cscopeWin->Clear();
    wxString list_file = DoCreateListFile(false);

    // Do the actual search
    wxString command;
    wxString endMsg;
    command << GetCscopeExeName() << wxT(" -d -L -1 ") << word << wxT(" -i ") << list_file;
    endMsg << _("cscope results for: find global definition of '") << word << wxT("'");
    DoCscopeCommand(command, word, endMsg);
}
Пример #5
0
void Cscope::DoCscopeCommand(const wxString &command, const wxString &findWhat, const wxString &endMsg)
{
	// We haven't yet found a valid cscope exe, so look for one
	wxString where;
	if ( !ExeLocator::Locate( GetCscopeExeName(), where ) ) {
		wxString msg; msg << _("I can't find 'cscope' anywhere. Please check if it's installed.") << wxT('\n')
						  << _("Or tell me where it can be found, from the menu: 'Plugins | CScope | Settings'");
		wxMessageBox( msg, _("CScope not found"), wxOK|wxCENTER|wxICON_WARNING );
		return;
	}

	//try to locate the cscope database
	wxArrayString output;

	//set the focus to the cscope tab
	Notebook *book = m_mgr->GetOutputPaneNotebook();

	//make sure that the Output pane is visible
	wxAuiManager *aui = m_mgr->GetDockingManager();
	if (aui) {
		wxAuiPaneInfo &info = aui->GetPane(wxT("Output View"));
		if (info.IsOk() && !info.IsShown()) {
			info.Show();
			aui->Update();
		}
	}

	wxString curSel = book->GetPageText((size_t)book->GetSelection());
	if (curSel != CSCOPE_NAME) {
		for (size_t i=0; i<(size_t)book->GetPageCount(); i++) {
			if (book->GetPageText(i) == CSCOPE_NAME) {
				book->SetSelection(i);
				break;
			}
		}
	}

	//create the search thread and return
	CscopeRequest *req = new CscopeRequest();
	req->SetOwner     (this    );
	req->SetCmd       (command );
	req->SetEndMsg    (endMsg  );
	req->SetFindWhat  (findWhat);
	req->SetWorkingDir(m_mgr->GetSolution()->GetSolutionFileName().GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR));

	CScopeThreadST::Get()->Add( req );
}
Пример #6
0
void Cscope::OnFindFunctionsCallingThisFunction(wxCommandEvent &e)
{
	wxString word = m_mgr->GetActiveEditor()->GetWordAtCaret();
	if (word.IsEmpty()) {
		return;
	}

	m_cscopeWin->Clear();
	wxString list_file = DoCreateListFile(false);

	//Do the actual search
	wxString command;
	wxString endMsg;
	command << GetCscopeExeName() << wxT(" -d -L -3 ") << word << wxT(" -i ") << list_file;
	endMsg << wxT("cscope results for: functions calling '") << word << wxT("'");
	DoCscopeCommand(command, word, endMsg);
}
Пример #7
0
void Cscope::OnFindFilesIncludingThisFname(wxCommandEvent& e)
{
    wxString word = m_mgr->GetActiveEditor()->GetSelection();
    if(word.IsEmpty()) {
        // If there's no selection, try for the caret word
        // That'll either be (rubbish, or) a filename
        // or it'll be the 'h'of filename.h
        // Cscope can cope with just a filename
        word = m_mgr->GetActiveEditor()->GetWordAtCaret();
        if(word == wxT("h")) {
            long pos = m_mgr->GetActiveEditor()->GetCurrentPosition();
            long start = m_mgr->GetActiveEditor()->WordStartPos(pos - 2, true);
            wxString name = m_mgr->GetActiveEditor()->GetTextRange(start, pos - 2);
            // Append the .h  Cscope would be happy with just foo,
            // but would also return #include foobar.h which isn't what's been requested
            word = name + wxT(".h");
        }
        if(word.IsEmpty()) {
            return;
        }
    }

    m_cscopeWin->Clear();
    wxString list_file = DoCreateListFile(false);

    // get the rebuild option
    wxString rebuildOption = wxT("");
    CScopeConfData settings;

    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
    if(!settings.GetRebuildOption()) {
        rebuildOption = wxT(" -d");
    }

    // Do the actual search
    wxString command;
    wxString endMsg;
    command << GetCscopeExeName() << rebuildOption << wxT(" -L -8 ") << word << wxT(" -i ") << list_file;
    endMsg << _("cscope results for: files that #include '") << word << wxT("'");
    DoCscopeCommand(command, word, endMsg);
}
Пример #8
0
void Cscope::DoFindSymbol(const wxString& word)
{
    m_cscopeWin->Clear();
    wxString list_file = DoCreateListFile(false);

    // get the rebuild option
    wxString rebuildOption = wxT("");
    CScopeConfData settings;

    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
    if(!settings.GetRebuildOption()) {
        rebuildOption = wxT(" -d");
    }

    // Do the actual search
    wxString command;
    wxString endMsg;
    command << GetCscopeExeName() << rebuildOption << wxT(" -L -0 ") << word << wxT(" -i ") << list_file;
    endMsg << wxT("cscope results for: find C symbol '") << word << wxT("'");
    DoCscopeCommand(command, word, endMsg);
}
Пример #9
0
void Cscope::OnFindGlobalDefinition(wxCommandEvent &e)
{
	// sanity
	if ( m_mgr->GetActiveEditor() == NULL ) {
		return;
	}

	wxString word = m_mgr->GetActiveEditor()->GetWordAtCaret();
	if (word.IsEmpty()) {
		return;
	}
	m_cscopeWin->Clear();
	wxString list_file = DoCreateListFile(false);

	//Do the actual search
	wxString command;
	wxString endMsg;
	command << GetCscopeExeName() << wxT(" -d -L -1 ") << word << wxT(" -i ") << list_file;
	endMsg << wxT("cscope results for: find global definition of '") << word << wxT("'");
	DoCscopeCommand(command, word, endMsg);
}