Author Topic: remove unused variables in CC, they are mostly in CCManager(SDK)  (Read 4667 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5371
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
remove unused variables in CC, they are mostly in CCManager(SDK)
« on: December 17, 2014, 06:04:14 am »
Code
b207ace51d75056bc6ef0d6cd5aaf3ec23b20e4f
 src/plugins/codecompletion/codecompletion.cpp | 18 ++----------------
 src/plugins/codecompletion/codecompletion.h   | 19 +------------------
 2 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/src/plugins/codecompletion/codecompletion.cpp b/src/plugins/codecompletion/codecompletion.cpp
index cd4f9ee..b7cd488 100644
--- a/src/plugins/codecompletion/codecompletion.cpp
+++ b/src/plugins/codecompletion/codecompletion.cpp
@@ -441,8 +441,6 @@ CodeCompletion::CodeCompletion() :
     m_TimerReparsing(this, idReparsingTimer),
     m_TimerEditorActivated(this, idEditorActivatedTimer),
     m_LastEditor(0),
-    m_ActiveCalltipsNest(0),
-    m_IsAutoPopup(false),
     m_ToolBar(0),
     m_Function(0),
     m_Scope(0),
@@ -452,14 +450,9 @@ CodeCompletion::CodeCompletion() :
     m_NeedReparse(false),
     m_CurrentLength(-1),
     m_NeedsBatchColour(true),
-    m_UseCodeCompletion(true),
-    m_CCAutoLaunchChars(3),
-    m_CCAutoLaunch(true),
-    m_CCLaunchDelay(300),
     m_CCMaxMatches(16384),
     m_CCAutoAddParentheses(true),
     m_CCDetectImplementation(false),
-    m_CCAutoSelectOne(false),
     m_CCEnableHeaders(false),
     m_SystemHeadersThreadCS(),
     m_DocHelper(this)
@@ -471,6 +464,7 @@ CodeCompletion::CodeCompletion() :
 
     Connect(g_idCCLogger,                wxEVT_COMMAND_MENU_SELECTED, CodeBlocksThreadEventHandler(CodeCompletion::OnCCLogger)     );
     Connect(g_idCCDebugLogger,           wxEVT_COMMAND_MENU_SELECTED, CodeBlocksThreadEventHandler(CodeCompletion::OnCCDebugLogger));
+
     // the two events below were generated from NativeParser, as currently, CodeCompletionPlugin is
     // set as the next event handler for m_NativeParser, so it get chance to handle them.
     Connect(ParserCommon::idParserStart, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CodeCompletion::OnParserStart)  );
@@ -516,7 +510,6 @@ CodeCompletion::~CodeCompletion()
 
 void CodeCompletion::OnAttach()
 {
-    m_PageIndex   = -1;
     m_EditMenu    = 0;
     m_SearchMenu  = 0;
     m_ViewMenu    = 0;
@@ -534,8 +527,6 @@ void CodeCompletion::OnAttach()
     LoadTokenReplacements();
     RereadOptions();
 
-    m_LastPosForCodeCompletion = -1;
-
     // Events m_NativeParser does not handle will go to the the next event
     // handler which is the instance of a CodeCompletion.
     m_NativeParser.SetNextHandler(this);
@@ -1565,7 +1556,7 @@ void CodeCompletion::GetAbsolutePath(const wxString& basePath, const wxArrayStri
 
 void CodeCompletion::EditorEventHook(cbEditor* editor, wxScintillaEvent& event)
 {
-    if (!IsAttached() || !m_InitDone || !m_UseCodeCompletion)
+    if (!IsAttached() || !m_InitDone)
     {
         event.Skip();
         return;
@@ -1641,15 +1632,10 @@ void CodeCompletion::RereadOptions()
     m_LexerKeywordsToInclude[8] = cfg->ReadBool(_T("/lexer_keywords_set9"), false);
 
     // for CC
-    m_UseCodeCompletion      = cfg->ReadBool(_T("/use_code_completion"),   true);
-    m_CCAutoLaunchChars      = cfg->ReadInt(_T("/auto_launch_chars"),      3);
-    m_CCAutoLaunch           = cfg->ReadBool(_T("/auto_launch"),           true);
-    m_CCLaunchDelay          = cfg->ReadInt(_T("/cc_delay"),               300);
     m_CCMaxMatches           = cfg->ReadInt(_T("/max_matches"),            16384);
     m_CCAutoAddParentheses   = cfg->ReadBool(_T("/auto_add_parentheses"),  true);
     m_CCDetectImplementation = cfg->ReadBool(_T("/detect_implementation"), false); //depends on auto_add_parentheses
     m_CCFillupChars          = cfg->Read(_T("/fillup_chars"),              wxEmptyString);
-    m_CCAutoSelectOne        = cfg->ReadBool(_T("/auto_select_one"),       false);
     m_CCEnableHeaders        = cfg->ReadBool(_T("/enable_headers"),        true);
 
     if (m_ToolBar)
diff --git a/src/plugins/codecompletion/codecompletion.h b/src/plugins/codecompletion/codecompletion.h
index 93a60fb..08babed 100644
--- a/src/plugins/codecompletion/codecompletion.h
+++ b/src/plugins/codecompletion/codecompletion.h
@@ -270,8 +270,6 @@ private:
     /** delayed running of editor activated event, only the last activated editor should be considered*/
     void OnEditorActivatedTimer(wxTimerEvent& event);
 
-    /** Not used*/
-    int                     m_PageIndex;
     /** Indicates CC's initialization is done*/
     bool                    m_InitDone;
 
@@ -287,7 +285,6 @@ private:
     CodeRefactoring         m_CodeRefactoring;
 
     int                     m_EditorHookId;
-    int                     m_LastPosForCodeCompletion;
 
     /** timer triggered by editor hook function to delay the real-time parse*/
     wxTimer                 m_TimerRealtimeParsing;
@@ -301,9 +298,6 @@ private:
     wxTimer                 m_TimerEditorActivated;
 
     cbEditor*               m_LastEditor;
-    int                     m_ActiveCalltipsNest;
-
-    bool                    m_IsAutoPopup;
 
     // The variables below were related to CC's toolbar
     /** the CC's toolbar */
@@ -344,16 +338,7 @@ private:
     bool                    m_NeedsBatchColour;
 
     //options on code completion (auto suggestion list) feature
-    /** disable the code-completion while editing*/
-    bool                    m_UseCodeCompletion;
-    /** how many characters will the user entered to trigger the code-completion*/
-    int                     m_CCAutoLaunchChars;
-    /** will the code-completion list pop-up automatically or not*/
-    bool                    m_CCAutoLaunch;
-    /** how long will the code-completion list delayed(in microseconds) after you hit the key, if
-        the value is zero, then the list will show immediately
-     */
-    int                     m_CCLaunchDelay;
+
     /** maximum allowed code-completion list entries*/
     size_t                  m_CCMaxMatches;
     /** whether add parentheses after user select a function name in the code-completion suggestion list*/
@@ -361,8 +346,6 @@ private:
     bool                    m_CCDetectImplementation;
     /** defines characters that work like Tab (empty by Default) but are also inserted*/
     wxString                m_CCFillupChars;
-    /** Should a single item auto-completion list automatically choose the item */
-    bool                    m_CCAutoSelectOne;
 
     /** give code completion list for header files, it happens after the #include directive */
     bool                    m_CCEnableHeaders;

I'm going to commit, any ideas?

This part:
Code
@@ -1565,7 +1556,7 @@ void CodeCompletion::GetAbsolutePath(const wxString& basePath, const wxArrayStri
 
 void CodeCompletion::EditorEventHook(cbEditor* editor, wxScintillaEvent& event)
 {
-    if (!IsAttached() || !m_InitDone || !m_UseCodeCompletion)
+    if (!IsAttached() || !m_InitDone)
     {
         event.Skip();
         return;
I think it is OK, because the CodeCompletion(code prompt) is now controlled by CCManager.
CodeCompletion::EditorEventHook() is now only trigger reparse of editor, or update the toolbar.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: remove unused variables in CC, they are mostly in CCManager(SDK)
« Reply #1 on: December 17, 2014, 11:28:15 pm »
Removing should be fine (from my opinion).  Just also remove the corresponding checkboxes from the configuration dialogue.

Hopefully, I will be able to finish up the corresponding options on CCManager side soon; I finally have a break, and should be able to work on it.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5371
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: remove unused variables in CC, they are mostly in CCManager(SDK)
« Reply #2 on: January 06, 2015, 12:18:07 pm »
When I'm doing code clean up, I found that the three code below
Code
    cfg->Write(_T("/documentation_helper_background_color"), (wxColour) XRCCTRL(*this, "btnDocBgColor",   wxButton)->GetBackgroundColour());
    cfg->Write(_T("/documentation_helper_text_color"),       (wxColour) XRCCTRL(*this, "btnDocTextColor", wxButton)->GetBackgroundColour());
    cfg->Write(_T("/documentation_helper_link_color"),       (wxColour) XRCCTRL(*this, "btnDocLinkColor", wxButton)->GetBackgroundColour());
These three fields were saved under code_completion plugin's configuration, but I don't see any codes which use these three fields, any one can check this?

About those three color settings, I see it was saved in the CCOptionDlg::OnApply():
Code
    ColourManager *colours = Manager::Get()->GetColourManager();
    wxColor colour = XRCCTRL(*this, "btnDocBgColor",   wxButton)->GetBackgroundColour();
    colours->SetColour(wxT("cc_docs_back"), colour);
    colour = XRCCTRL(*this, "btnDocTextColor",   wxButton)->GetBackgroundColour();
    colours->SetColour(wxT("cc_docs_text"), colour);
    colour = XRCCTRL(*this, "btnDocLinkColor",   wxButton)->GetBackgroundColour();
    colours->SetColour(wxT("cc_docs_link"), colour);
Those settings were saved in the configure file (note the only customized color were saved):
Code
	<colours>
<list>
<CC_DOCS_LINK>
<colour r="255" g="0" b="128" />
</CC_DOCS_LINK>
</list>
</colours>
And those settings were saved in the CCOptionDlg::CCOptionDlg() to initialized the button color:
Code
    ColourManager *colours = Manager::Get()->GetColourManager();
    XRCCTRL(*this, "btnDocBgColor",         wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_back")));
    XRCCTRL(*this, "btnDocTextColor",       wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_fore")));
    XRCCTRL(*this, "btnDocLinkColor",       wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_link")));
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: remove unused variables in CC, they are mostly in CCManager(SDK)
« Reply #3 on: January 07, 2015, 12:59:59 am »
Colour setting is best to be saved in the ColourManager, so they can be edited in a single place and also to allow easy sharing of colour themes.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5371
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: remove unused variables in CC, they are mostly in CCManager(SDK)
« Reply #4 on: January 07, 2015, 04:01:12 am »
Here is the patch, I'd welcome any comments. The main changes are:

1, I remove all the UIs and related code in the CodeCompletion plugin's option dialog, since they are controlled by CCManager's option dialog.
2, currently, the "case sensitive" option is set when a Parser was created, but when a user change this option in CCManager's option dialog, it don't take effect in the currently already opened project. You need to reopened the cbp. (Maybe, we need a CB event to tell any CodeCompletion plugins that the option has changed, the other way is that we need to read those ccmanager option in our plugins when we used)

Colour setting is best to be saved in the ColourManager, so they can be edited in a single place and also to allow easy sharing of colour themes.
This will be the next step after this one was in trunk.  :)

« Last Edit: January 07, 2015, 04:38:57 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5371
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: remove unused variables in CC, they are mostly in CCManager(SDK)
« Reply #5 on: January 10, 2015, 04:11:08 pm »
In trunk now.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.