News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

New code completion remarks/issues

Started by killerbot, September 15, 2009, 12:24:28 PM

Previous topic - Next topic

killerbot

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.

killerbot

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.

killerbot

#2
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 :

#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 :

#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.

killerbot

#3
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

namespace vipnt
{

namespace
{
const int NumberOfZones = 6;
}

...

oBFusCATed

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!]

MortenMacFly

Quote from: oBFusCATed on September 15, 2009, 12:47:07 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

blueshake

Quotenamespace 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.
                #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?

killerbot

but note that if I leave the anonymous namespace nested inside vipnt, but move it between the 2 methods, the parsing also works again.


blueshake

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?

MortenMacFly

#9
Quote from: blueshake on September 15, 2009, 01:24:12 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).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

killerbot

should be int, yes. But still fails for me.
Updating to latest in svn right now ...

killerbot

at rev 5790, and it still fails.

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

blueshake

#12
fail for me too at rev 5790.
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?

MortenMacFly

Quote from: killerbot on September 15, 2009, 02:51:30 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]