Author Topic: CC toolbar enhancement  (Read 26109 times)

Offline sbezgodov

  • Multiple posting newcomer
  • *
  • Posts: 15
CC toolbar enhancement
« on: March 18, 2010, 01:37:22 pm »
Hello, all.
I've make a patch, which improves codecompletion plugin toolbar functionality and speeds up switching editors.
1. Now in the plugin options dialog you can turn off scope filtering choice control. This means you can choose Visual Studio or Visual Assist alike style. Using second variant also saves some space in screen area.
2. Added Freeze/Thaw calls to toolbar's choice controls. This massively increases speed of switching between editor files!! Especially noticeable when user switches between large files.
3. Added cbEVT_UPDATE_VIEW_LAYOUT event. This needed to update toolbar size after changing its style in plugin options. Further can be used if we will decide to implement customizable toolbars or when forced layout update is needed.
4. Fixed bug when editor cursor is inside namespace, and it wasn't shown in toolbar.



[attachment deleted by admin]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC toolbar enhancement
« Reply #1 on: March 18, 2010, 02:17:24 pm »
I've made similar patch, but I haven't found the time to show it to the public :)

One question (I've not looked at the implementation):
Do you sort the Visual Assist style combo? If not please do it, because it is very helpful :)
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC toolbar enhancement
« Reply #2 on: March 18, 2010, 02:32:50 pm »
Do you sort the Visual Assist style combo? If not please do it, because it is very helpful :)
But make it configurable :D. Because often methods are sorted/grouped by functionality which would get lost if always sorted alphabetically.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC toolbar enhancement
« Reply #3 on: March 18, 2010, 02:35:23 pm »
1. Now in the plugin options dialog you can turn off scope filtering choice control. This means you can choose Visual Studio or Visual Assist alike style. Using second variant also saves some space in screen area.
I wonder how you would quickly limit the view by namespace using only one combobox. Assume you have a file that works a lot with namespaces and would like to see just the methods of a certain namespace. That's why the initial implementation was splitted into two controls IIRC.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CC toolbar enhancement
« Reply #4 on: March 18, 2010, 03:13:42 pm »
Nice work, I will download the patch and test it, thanks!!!

Edit
I'm thinking about parsing: using namespace statement like:

ParserThread::ParseBufferForNamespaces

I personally think: we can hold these information when we doing the batch parsing, so, these information can be directly retrieved from the Tokentree.

Any body can understand my idea??, sorry if I'm not explain well.
« Last Edit: March 18, 2010, 03:20:08 pm 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 sbezgodov

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: CC toolbar enhancement
« Reply #5 on: March 18, 2010, 03:29:36 pm »
Do you sort the Visual Assist style combo? If not please do it, because it is very helpful :)
But make it configurable :D. Because often methods are sorted/grouped by functionality which would get lost if always sorted alphabetically.
Yes, combos are sorted alphabetically case insensitive.
Do you mean to add a toolbar menu button, where you can choose how to display items in comboboxes?

Offline sbezgodov

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: CC toolbar enhancement
« Reply #6 on: March 18, 2010, 03:45:49 pm »
I'm thinking about parsing: using namespace statement like:

ParserThread::ParseBufferForNamespaces

I personally think: we can hold these information when we doing the batch parsing, so, these information can be directly retrieved from the Tokentree.

Any body can understand my idea??, sorry if I'm not explain well.

I thought about it, but fear to change anything in Token or TokenTree. :) Is it good idea to store token implementation start/end lines in array or better hold this information in tokens tree? Multiple impl. start/end lines used only for namespaces.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CC toolbar enhancement
« Reply #7 on: March 18, 2010, 04:07:08 pm »
Quote
Is it good idea to store token implementation start/end lines in array or better hold this information in tokens tree? Multiple impl. start/end lines used only for namespaces.
Sorry, I'm not quite understand your idea. Currently, a Token structure is something like:

Code
class Token : public BlockAllocated<Token, 10000>
{
    friend class TokensTree;
    public:
        Token();
        Token(const wxString& name, unsigned int file, unsigned int line);
        ~Token();

        void AddChild(int child);
        void RemoveChild(int child);
        wxString GetNamespace() const;
        bool InheritsFrom(int idx) const;
        wxString DisplayName() const;
        wxString GetTokenKindString() const;
        wxString GetTokenScopeString() const;
        wxString GetFilename() const;
        wxString GetImplFilename() const;
        inline unsigned long GetTicket() const { return m_Ticket; }
        bool MatchesFiles(const TokenFilesSet& files);

        bool SerializeIn(wxInputStream* f);
        bool SerializeOut(wxOutputStream* f);
        int GetSelf()         { return m_Self; } // current index in the tree
        wxString GetParentName();
        Token* GetParentToken();
        TokensTree* GetTree() { return m_pTree; }

        wxString      m_Type;       // this is the return value (if any): e.g. const wxString&
        wxString      m_ActualType; // this is what the parser believes is the actual return value: e.g. wxString
        wxString      m_Name;
        wxString      m_Args;
        wxString      m_StrippedArgs;
        wxString      m_AncestorsString; // all ancestors comma-separated list
        wxString      m_TemplateArgument;
        unsigned int  m_FileIdx;
        unsigned int  m_Line;
        unsigned int  m_ImplFileIdx;
        unsigned int  m_ImplLine;      // where the token was met
        unsigned int  m_ImplLineStart; // if token is impl, opening brace line
        unsigned int  m_ImplLineEnd;   // if token is impl, closing brace line
        TokenScope    m_Scope;
        TokenKind     m_TokenKind;
        bool          m_IsOperator;
        bool          m_IsLocal;       // found in a local file?
        bool          m_IsTemp;        // if true, the tree deletes it in FreeTemporaries()
        bool          m_IsConst;       // the member method is const (yes/no)

        int           m_ParentIndex;
        TokenIdxSet   m_Children;
        TokenIdxSet   m_Ancestors;
        TokenIdxSet   m_DirectAncestors;
        TokenIdxSet   m_Descendants;

        wxArrayString m_Aliases; // used for namespace aliases

        void*         m_pUserData; // custom user-data (the classbrowser expects it to be a pointer to a cbProject)

    protected:
        TokensTree*   m_pTree;
        int           m_Self; // current index in the tree
        unsigned long m_Ticket;

        static unsigned long GetTokenTicket();
};

So, You means that the same Tokens(used form, especially they used have different imp start line and end line) can be merged to one Token?
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 sbezgodov

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: CC toolbar enhancement
« Reply #8 on: March 18, 2010, 04:55:26 pm »
So, You means that the same Tokens(used form, especially they used have different imp start line and end line) can be merged to one Token?

Yes, i mean merging exactly to one token. Or make special container  in tokentree for additional namespaces information.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: CC toolbar enhancement
« Reply #9 on: March 19, 2010, 06:10:02 am »
Great, works well.
Thanks!
----------------------
Oh, I found a bug: can not find the global functions.
Code
#include <iostream>

using namespace std;

class A
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

class B
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

class C
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

// can not jump to here
void func1() {}
void func2() {}
void func3() {}

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
« Last Edit: March 19, 2010, 06:16:21 am by Loaden »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: CC toolbar enhancement
« Reply #10 on: March 19, 2010, 06:29:05 am »
I change xrc's size, like:
Code
<?xml version="1.0" ?>
<resource>
  <object class="wxToolBarAddOn" name="codecompletion_toolbar">
    <object class="wxChoice" name="chcCodeCompletionScope">
      <content/>
  <size>220,-1</size>
    </object>
    <object class="wxChoice" name="chcCodeCompletionFunction">
      <content/>
  <size>690,-1</size>
    </object>
  </object>
</resource>


[attachment deleted by admin]

Offline sbezgodov

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: CC toolbar enhancement
« Reply #11 on: March 19, 2010, 11:16:30 am »
Oh, I found a bug: can not find the global functions.

Seems that this bug related to parser, because these functions are not displayed in symbols browser too. I use svn6178 revision.

Any suggestions how to make toolbar more configurable, please. Which sort orders do we need? Is manual resizing needed? Is item coloring for different token types needed?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: CC toolbar enhancement
« Reply #12 on: March 19, 2010, 11:37:36 am »
Oh, I found a bug: can not find the global functions.
Seems that this bug related to parser, because these functions are not displayed in symbols browser too. I use svn6178 revision.
Is not the case, in here, this tip is correct!

[attachment deleted by admin]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: CC toolbar enhancement
« Reply #13 on: March 19, 2010, 11:43:01 am »
If I put the top of the global functions, then all functions are normal!
Code
#include <iostream>

using namespace std;

// can not jump to here
void func1() {}
void func2() {}
void func3() {}

class A
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

class B
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

class C
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
And if change to:
Code
class A
{
public:
    void func1() {}
    void func2() {}
    void func3() {}
};

// can not jump to here
void func1() {}
void func2() {}
void func3() {}
Now, it's unwork.

WOW! i see, this is indeed parser problem!
If change global function's name to :
Code
// can not jump to here
void gfunc1() {}
void gfunc2() {}
void gfunc3() {}
then, that's work well now.

Offline sbezgodov

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: CC toolbar enhancement
« Reply #14 on: March 19, 2010, 01:24:49 pm »
Following patch formally fixes this bug, Loaden.

Code
Index: token.cpp
===================================================================
--- token.cpp (revision 6178)
+++ token.cpp (working copy)
@@ -521,9 +521,7 @@
         if (!curToken)
             continue;
 
-        if (   (   (parent < 0)
-                || (curToken->m_ParentIndex == parent) )
-            && (curToken->m_TokenKind & kindMask) )
+        if ((curToken->m_ParentIndex == parent) && (curToken->m_TokenKind & kindMask))
         {
             return result;
         }


But it makes another questions. Can this patch raise another bugs? :) And why we should return first found token if searched token parent is -1 (Global namespace) ?