Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
code completion fails for struct in a vector
killerbot:
Consider the following code :
--- 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;
}
--- End code ---
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 ;-)
Loaden:
This feature need blueshake help.
:lol:
Jenna:
Just for the record: it works with clang (new toy :lol: ):
--- Code: ---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$
--- End code ---
ollydbg:
--- Quote from: killerbot on October 27, 2010, 09:41:37 am ---2) if you type "mBars[0]." --> NO completion kicks in : NOT OK
--- End quote ---
Current CC will do something like:
splite the statement
--- Code: ---mBars[0].
--- End code ---
to
two pieces
One is: mBars class
The next One is: empty string (everything)
Note:
--- Code: ---[0]
--- End code ---
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.
--- Code: ---p mBars[0].Value
--- End code ---
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)
edit
from this page,
http://clang.llvm.org/features.html
clang is a hand-write recursive descent parser.
--- Quote ---A 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.
--- End quote ---
blueshake:
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.
Navigation
[0] Message Index
[#] Next page
Go to full version