Exemplo n.º 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);
}
Exemplo n.º 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);
}
Exemplo n.º 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);
}
Exemplo n.º 4
0
CScopeSettingsDlg::CScopeSettingsDlg(wxWindow* parent)
    : CScopeSettingsDlgBase(parent)
{
    CScopeConfData settings;
    EditorConfigST::Get()->ReadObject("CscopeSettings", &settings);
    
    m_filePickerCScopeExe->SetPath(settings.GetCscopeExe());
    WindowAttrManager::Load(this, "CScopeSettingsDlg");
}
Exemplo n.º 5
0
void CscopeTab::OnChangeSearchScope(wxCommandEvent& e)
{
    CScopeConfData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &data);
    // update the settings
    data.SetScanScope(m_stringManager.GetStringSelection());
    data.SetRebuildDbOption(m_checkBoxUpdateDb->IsChecked());
    data.SetBuildRevertedIndexOption(m_checkBoxRevertedIndex->IsChecked());
    // store the object
    m_mgr->GetConfigTool()->WriteObject(wxT("CscopeSettings"), &data);
}
Exemplo n.º 6
0
void Cscope::OnDoSettings(wxCommandEvent& e)
{
    // atm the only setting to set is the cscope filepath
    // First find the current value, if any
    CScopeConfData settings;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
    wxString filepath = settings.GetCscopeExe();

    CScopeSettingsDlg dlg(EventNotifier::Get()->TopFrame());
    if(dlg.ShowModal() == wxID_OK) {
        settings.SetCscopeExe(dlg.GetPath());
        m_mgr->GetConfigTool()->WriteObject(wxT("CscopeSettings"), &settings);
    }
}
Exemplo n.º 7
0
void Cscope::OnDoSettings(wxCommandEvent &e)
{
	// atm the only setting to set is the cscope filepath
	// First find the current value, if any
	CScopeConfData settings;
	m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
	wxString filepath = settings.GetCscopeExe();

	// Since there's only the one thing to ask, keep it simple for now
	wxString fp = wxGetTextFromUser(_("Please enter the filepath where cscope can be found"), _("Where is cscope?"), filepath);
	if ( fp.IsEmpty() ) {
		return;
	}

	settings.SetCscopeExe(fp);
	m_mgr->GetConfigTool()->WriteObject(wxT("CscopeSettings"), &settings);
}
Exemplo n.º 8
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);
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
0
CscopeTab::CscopeTab( wxWindow* parent, IManager *mgr )
    : CscopeTabBase( parent )
    , m_table(NULL)
    , m_mgr(mgr)
{
    m_bitmaps = clGetManager()->GetStdIcons()->MakeStandardMimeMap();

    CScopeConfData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &data);

    const wxString SearchScope[] = { wxTRANSLATE("Entire Workspace"), wxTRANSLATE("Active Project") };
    m_stringManager.AddStrings(sizeof(SearchScope)/sizeof(wxString), SearchScope, data.GetScanScope(), m_choiceSearchScope);

    wxFont defFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    m_font = wxFont( defFont.GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);

    m_checkBoxUpdateDb->SetValue(data.GetRebuildOption());
    m_checkBoxRevertedIndex->SetValue(data.GetBuildRevertedIndexOption());
    SetMessage(_("Ready"), 0);

    Clear(); // To make the Clear button UpdateUI work initially
    EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(CscopeTab::OnThemeChanged), NULL, this);
}
Exemplo n.º 11
0
wxString Cscope::GetCscopeExeName()
{
    CScopeConfData settings;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);
    return settings.GetCscopeExe();
}
Exemplo n.º 12
0
wxString Cscope::DoCreateListFile(bool force)
{
    // get the scope
    CScopeConfData settings;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);

    // create temporary file and save the file there
    wxString privateFolder = clCxxWorkspaceST::Get()->GetPrivateFolder();
    wxFileName list_file(privateFolder, "cscope_file.list");
    if(force || settings.GetRebuildOption() || !list_file.FileExists()) {
        wxArrayString projects;
        m_mgr->GetWorkspace()->GetProjectList(projects);
        wxString err_msg;
        std::vector<wxFileName> files;
        std::vector<wxFileName> tmpfiles;
        m_cscopeWin->SetMessage(_("Creating file list..."), 5);

        if(settings.GetScanScope() == SCOPE_ENTIRE_WORKSPACE) {
            for(size_t i = 0; i < projects.GetCount(); i++) {
                ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projects.Item(i), err_msg);
                if(proj) {
                    proj->GetFiles(tmpfiles, true);
                }
            }
        } else {
            // SCOPE_ACTIVE_PROJECT
            wxString projName = m_mgr->GetWorkspace()->GetActiveProjectName();
            ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projName, err_msg);
            if(proj) {
                proj->GetFiles(tmpfiles, true);
            }
        }

        // iterate over the files and convert them to be relative path
        // Also remove any .exe files (one of which managed to crash cscope),
        // and files without an ext, which may be binaries and are unlikely to be .c or .h files in disguise; and .xpm
        // and .png too
        for(size_t i = 0; i < tmpfiles.size(); i++) {
            wxString ext = tmpfiles.at(i).GetExt();
            if(ext == wxT("exe") || ext == wxT("") || ext == wxT("xpm") || ext == wxT("png")) {
                continue;
            }
            tmpfiles.at(i).MakeRelativeTo(privateFolder);
            files.push_back(tmpfiles.at(i));
        }

        // create temporary file and save the file there
        wxFFile file(list_file.GetFullPath(), wxT("w+b"));
        if(!file.IsOpened()) {
            wxLogMessage(wxT("Failed to open temporary file ") + list_file.GetFullPath());
            return wxEmptyString;
        }

        // write the content of the files into the tempfile
        wxString content;
        for(size_t i = 0; i < files.size(); i++) {
            wxFileName fn(files.at(i));
            content << fn.GetFullPath() << wxT("\n");
        }

        file.Write(content);
        file.Flush();
        file.Close();
    }

    return list_file.GetFullPath();
}
Exemplo n.º 13
0
wxString Cscope::DoCreateListFile(bool force)
{
	// get the scope
	CScopeConfData settings;
	m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);

	//create temporary file and save the file there
	wxString wspPath = m_mgr->GetSolution()->GetSolutionFileName().GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
	wxString list_file( wspPath );
	list_file << wxT("cscope_file.list");

	if (force || settings.GetRebuildOption() || !::wxFileExists(list_file))
	{
		wxArrayString projects;
		m_mgr->GetSolution()->GetProjectList(projects);
		wxString err_msg;
		std::vector< wxFileName > files;
		std::vector< wxFileName > tmpfiles;
		m_cscopeWin->SetMessage(wxT("Creating file list..."), 5);

		if (settings.GetScanScope() == SCOPE_ENTIRE_WORKSPACE) {
			for (size_t i=0; i< projects.GetCount(); i++) {
				ProjectPtr proj = m_mgr->GetSolution()->FindProjectByName(projects.Item(i), err_msg);
				if ( proj ) {
					proj->GetFiles(tmpfiles, true);
				}
			}
		} else {
			// SCOPE_ACTIVE_PROJECT
			wxString projName = m_mgr->GetSolution()->GetActiveProjectName();
			ProjectPtr proj = m_mgr->GetSolution()->FindProjectByName(projName, err_msg);
			if ( proj ) {
				proj->GetFiles(tmpfiles, true);
			}
		}

		//iterate over the files and convert them to be relative path
		for (size_t i=0; i< tmpfiles.size(); i++ ) {
			tmpfiles.at(i).MakeRelativeTo(wspPath);
			files.push_back(tmpfiles.at(i));
		}

		//create temporary file and save the file there
		wxFFile file(list_file, wxT("w+b"));
		if (!file.IsOpened()) {
			wxLogMessage(wxT("Failed to open temporary file ") + list_file);
			return wxEmptyString;
		}

		//write the content of the files into the tempfile
		wxString content;
		for (size_t i=0; i< files.size(); i++) {
			wxFileName fn(files.at(i));
			content << fn.GetFullPath() << wxT("\n");
		}

		file.Write( content );
		file.Flush();
		file.Close();
	}

	return list_file;
}