Author Topic: New code completion remarks/issues  (Read 159117 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
New code completion remarks/issues
« on: September 15, 2009, 12:24:28 pm »
Shortly in a nightly build the new code completion engine will be available.
One can already get it from svn.

This thread is the start base to discuss issues.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
Re: New code completion remarks/issues
« Reply #1 on: September 15, 2009, 12:25:07 pm »
I have several classes with several members and methods, and I don't get any completion at all.
All members start with "m_", none of them work, calling the other member methods from within a member method same story. In the Symbols browser the classes are shown correctly !!!

I think i has something to do with namespace.

Example :
I have class CStop in the namespace vipnt. That class has a member m_Angle (amongst other) and (amongst other) the following method "Configure", but no completion on either.
However when I start typing like this in a member method of this class, I do get completions.

Quote
   vipnt::CStop::Configure
   vipnt::CStop::m_Angle

Note when I to "ctr-space" I see a lot of things, but the moment I start typing m_ there are already no more matches in the list.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
Re: New code completion remarks/issues
« Reply #2 on: September 15, 2009, 12:26:10 pm »
Here's a reduced testing example showing the issue. (just add the 2 files to the dummy console application you get from the CB project wizard)

1) create Stop.h with the following content :
Code: [Select]
#ifndef _STOP_H_INCLUDE
#define _STOP_H_INCLUDE

namespace vipnt
{

class CStop
{
public:
void RePaint();
bool HasWork() const;

private:

int* m_Angle;
int* m_Variance;
};

} // namespace vipnt
#endif // _STOP_H_INCLUDE

2) create Stop.cpp with the following content :
Code: [Select]
#include "Stop.h"

namespace vipnt
{

namespace
{
const int NumberOfZones = 6;
} // namespace


bool CStop::HasWork() const
{
return true;
} // end of HasWork

void CStop::RePaint()
{
} // end of RePaint

} // namespace vipnt

go into RePaint and try :
 m_Angle : no completion
 HasWork no completion
 ctrl-space  nothing to find in there that starts with m_

Now remove in the cpp file the anonymous namespace (declaring the constant) and everything will work.

EDIT : when I moved the anonymous namespace in front of the vipnt namespace in the cpp file then again it works.
Nesting seems to introduce issues.
« Last Edit: September 15, 2009, 03:00:58 pm by killerbot »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
Re: New code completion remarks/issues
« Reply #3 on: September 15, 2009, 12:26:43 pm »
other interesting things to note. Look at the code completion toolbar, the read only field at the left.

enter the vipnt namespace --> vipnt
enter the anonymous (nested) --> vipnt
enter CStop::HasWork()  --> CStop !!!!!!!!!!!!!!!!!!!
enter CStop::RePaint()  --> CStop  !!!!!!!!!!!!!!!!!!!

NOW : move the anonyous namespace between the HasWork en RePaint methods.

enter the vipnt namespace --> vipnt
enter CStop::HasWork()  --> vipnt::CStop
enter the anonymous (nested) --> vipnt
enter CStop::RePaint()  --> vipnt::CStop

This gives better things in the toolbar, and it also brings back the completion.

Strange, strange, strange.


OPEN  QUESTION : could it have to do with one namespace being immediately nested after the start of another namespace
Code: [Select]
namespace vipnt
{

namespace
{
const int NumberOfZones = 6;
}

...
« Last Edit: September 15, 2009, 03:00:39 pm by killerbot »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13011
    • Travis build status
Re: New code completion remarks/issues
« Reply #4 on: September 15, 2009, 12:47:07 pm »
I have been wondering lately,
why not add some kind of functionality/application test for the code completion.
Parsing is one of the areas that allow easy testing.
The benefits of the testing (obvious to many I'm sure) are:
1. You get instant answer if your change is correct or you add new test, so other don't break you code later
2. The behavior of the code is documented through the test
3. Users are happier, because of less bugs
4. Developers are braver when they refactor, because they have a safety net.
5. There is measure of progress (5 test pass we have 10 left for example)

Best regards
(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: 9611
Re: New code completion remarks/issues
« Reply #5 on: September 15, 2009, 01:15:49 pm »
why not add some kind of functionality/application test for the code completion.
Absolutely true!
It could be as simple as a project that contains 1..n files (classes) with special items to be resolved. We could start with Lievens class(es) provided here. :-) Just name them e.h. anonymous_namespace_test.cpp or alike... so we know by filename what's the actual test in the class.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #6 on: September 15, 2009, 01:24:12 pm »
Quote
namespace vipnt
{

namespace
{
   const in NumberOfZones = 6;
}

...
if we give the anonymous namespace a name .for example qq.
the cc work again.
and it is strange in function NativeParser::FindCurrentFunctionStart:
watch these codes and turn it on.
Code: [Select]
                #if wxCHECK_VERSION(2, 9, 0)
                    Manager::Get()->GetLogManager()->DebugLog(F(_T("Current function: %s (at line %d)"), token->DisplayName().wx_str(), token->m_ImplLine));
                #else
                    Manager::Get()->GetLogManager()->DebugLog(F(_T("Current function: %s (at line %d)"), token->DisplayName().c_str(), token->m_ImplLine));
                #endif
if the anonymous namespace in the namespace vipnt,
the code::block debug print Current function: CStop::RePaint() : void (at line 19)
if the anonymous namespace out the namespace vipnt,
the code::block debug print Current function: vipnt::CStop::RePaint() : void (at line 19)
the difference is the outside  one has the vipnt:: but the inside one has nothing.
and this will affect the NativeParser::FindCurrentFunctionToken
it make the RePaint's parentscope can not be add to search socpe ,so the cc didn't work.
above is my guess.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
Re: New code completion remarks/issues
« Reply #7 on: September 15, 2009, 01:39:09 pm »
but note that if I leave the anonymous namespace nested inside vipnt, but move it between the 2 methods, the parsing also works again.


Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #8 on: September 15, 2009, 01:54:46 pm »
ok,I move the the anonymous namespace to the position between the 2 methods.
yes ,it work.
and the code::block debug print Current function: vipnt::CStop::RePaint() : void (at line 19)
the output is the same to the anonymous outside the vipnt which cc work too.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9611
Re: New code completion remarks/issues
« Reply #9 on: September 15, 2009, 02:13:09 pm »
namespace
{
   const in NumberOfZones = 6;
}
Are you aware that this is NOT a legal paragraph? There is no type called "in"... I guess it should read "int". The parser gets confused by that probably. If I change the type to "int" it works pretty well here (latest CC from trunk).
« Last Edit: September 15, 2009, 02:30:19 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
Re: New code completion remarks/issues
« Reply #10 on: September 15, 2009, 02:30:59 pm »
should be int, yes. But still fails for me.
Updating to latest in svn right now ...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5270
Re: New code completion remarks/issues
« Reply #11 on: September 15, 2009, 02:51:30 pm »
at rev 5790, and it still fails.

@Morton : how come so many cc stuff works for you and not for us ?? ;-)

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #12 on: September 15, 2009, 02:53:30 pm »
fail for me too at rev 5790.
« Last Edit: September 15, 2009, 02:55:16 pm by blueshake »
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9611
Re: New code completion remarks/issues
« Reply #13 on: September 15, 2009, 03:14:47 pm »
@Morton : how come so many cc stuff works for you and not for us ?? ;-)
Dunno. It's really the same code as in trunk now. However - if it makes you "feel better" (;-)): I know at least one class that works for Jens and blueshake but not for me. :-(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9611
Re: New code completion remarks/issues
« Reply #14 on: September 15, 2009, 03:16:33 pm »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ