Consider the following code :
#include <vector>
class Foo
{
public:
void DoSomething();
private:
struct Bar
{
int mMember1;
int mMember2;
Bar() : mMember1(), mMember2() {}
};
std::vector<Bar> mBars;
};
void Foo::DoSomething()
{
Bar bar1;
mBars.push_back(bar1);
bar1.mMember1 = 0;
mBars[0].mMember1 = 0;
}
int main()
{
Foo foo1;
foo1.DoSomething();
return 0;
}
Focus on the DoSomething() method.
1) if you type "bar1." --> completion works : OK
2) if you type "mBars[0]." --> NO completion kicks in : NOT OK
hope this example can help for the improvement ;-)
This feature need blueshake help.
:lol:
Just for the record: it works with clang (new toy :lol: ):
jens@debian-inspiron:/tmp/test$ clang++ -w -fsyntax-only -Xclang -code-completion-at=main.cpp:28:14 main.cpp
COMPLETION: Bar : Bar::
COMPLETION: mMember1 : [#int#]mMember1
COMPLETION: mMember2 : [#int#]mMember2
COMPLETION: operator= : [#struct Foo::Bar &#]operator=(<#struct Foo::Bar const &#>)
COMPLETION: ~Bar : [#void#]~Bar()
jens@debian-inspiron:/tmp/test$
Quote from: killerbot on October 27, 2010, 09:41:37 AM
2) if you type "mBars[0]." --> NO completion kicks in : NOT OK
Current CC will do something like:
splite the statement
mBars[0].
to
two pieces
One is: mBars class
The next One is: empty string (everything)
Note:
[0] is skipped. So, cc woks badly.
The way to solve the statement information is quite hard. codelite use the bison/yacc grammar to solve the statement grammar tree.
This is the way like gdb to parse user's statement like you enter some command (GDB use bison/yacc grammar either, you can see gdb's source of c-exp.y under gdb subfolder.
p mBars[0].Value
Implement this kind of expression solving is not easy. :D
like jens said, I suggest using Clang (or in the feature) :D it was more powerful and if we use the clang and PCH feature, I think codecompletion will run fast. (see some comments from eranif Clang command line support for codecompletion (http://forums.next.codeblocks.org/index.php/topic,13559.0.html))
editfrom this page,
http://clang.llvm.org/features.html
clang is a hand-write recursive descent parser.
QuoteA single unified parser for C, Objective C, C++, and Objective C++
Clang is the "C Language Family Front-end", which means we intend to support the most popular members of the C family. We are convinced that the right parsing technology for this class of languages is a hand-built recursive-descent parser. Because it is plain C++ code, recursive descent makes it very easy for new developers to understand the code, it easily supports ad-hoc rules and other strange hacks required by C/C++, and makes it straight-forward to implement excellent diagnostics and error recovery.
We believe that implementing C/C++/ObjC in a single unified parser makes the end result easier to maintain and evolve than maintaining a separate C and C++ parser which must be bugfixed and maintained independently of each other.
autually operator [] has been supported for a long time,you guys can write some codes to test it.
the vector doesn't work because of the class[vector] inheritance is not built. I should do this a long ago.
but recently I am quite losing my time.sorry.
Quote from: blueshake on October 27, 2010, 01:19:10 PM
autually operator [] has been supported for a long time,you guys can write some codes to test it.
the vector doesn't work because of the class[vector] inheritance is not built. I should do this a long ago.
but recently I am quite losing my time.sorry.
you might be able to do it somewhere in the (near) future, cause I understand you might have an idea how it can be done, right ?
yes,I have thought this issue for a while.just need to prove if it is right or not.Now I have several plastic struct design on hand. after I finish them .I will start to do it. :D