User forums > Help
(solved) Code completion plugin won't complete local variables
Acce:
I'm using windows, (c::b build SVN 8150) and can't seem to get local variables to be completed.
I'm quite new to c::b, (moved from eclipse), so I might be doing something wrong, but everything I saw in the code completion plugin settings said nothing about local (automatic) variables.
For example,
--- Code: ---wakeup interrupt (USCIAB0RX_VECTOR) process_RX (void)
{
int receive_buffer = 0;
recei //hitting ctrl+space here doesn't bring up the variable name.
}
--- End code ---
I'm using c::b to program msp430 microcontrollers using mspgcc, and this probably has something to do with that "weird" function declaration (declares an interrupt handler) which the code completion plugin can't parse correctly, because the function doesn't show up in code completion toolbar's function list either.
btw, without macros function call looks like this:
--- Code: ---__attribute__((wakeup)) void __attribute__((interrupt (x))) process_RX(void)
--- End code ---
if that makes some difference..
Thanks in advance!
stefanos_:
Acce, on my system (Debian wheezy 32-bit) I have a similar issue and in order to solve it, I have to first save my changes, and then right-click on the project to re-parse it. It usually works, but when it does not I use Ctrl-SPACE and gives me the options I am looking for after re-parsing process.
Another awkward situation is when you hover on a macro, function or class, it shows you the information you are looking for, but with a right-click option to find its implementation or declaration, it does not take you to it.
It must be an issue with the parser I guess.
ollydbg:
--- Quote from: Acce on August 21, 2012, 11:32:47 am ---I'm using windows, (c::b build SVN 8150) and can't seem to get local variables to be completed.
I'm quite new to c::b, (moved from eclipse), so I might be doing something wrong,
--- End quote ---
Welcome!!!
--- Quote ---but everything I saw in the code completion plugin settings said nothing about local (automatic) variables.
--- End quote ---
Yes, there is no options for local(automatic variables).
--- Quote ---For example,
--- Code: ---wakeup interrupt (USCIAB0RX_VECTOR) process_RX (void)
{
int receive_buffer = 0;
recei //hitting ctrl+space here doesn't bring up the variable name.
}
--- End code ---
I'm using c::b to program msp430 microcontrollers using mspgcc, and this probably has something to do with that "weird" function declaration (declares an interrupt handler) which the code completion plugin can't parse correctly, because the function doesn't show up in code completion toolbar's function list either.
--- End quote ---
Yes, you are right. The code:
--- Code: ---wakeup interrupt (USCIAB0RX_VECTOR) process_RX (void)
--- End code ---
is not a valid function definition. So, CB does not recognize it.
--- Quote ---btw, without macros function call looks like this:
--- Code: ---__attribute__((wakeup)) void __attribute__((interrupt (x))) process_RX(void)
--- End code ---
if that makes some difference.
--- End quote ---
I think you can add some custom string replacement rules for this kind of parsing, you can see this page for some details.
http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#replacement_rules
You can basically strip the strings like "__attribute__((wakeup))" and "__attribute__((interrupt (x)))", so the parser see these code like below:
--- Code: ---void process_RX(void)
--- End code ---
This should be a valid function declaration/definition, because it have some string mode like "AAAA BBBBB(CCCC)". :)
Acce:
Awesome, sounds very promising! Thanks a lot!
because the "x" in interrupt(x) changes, can i do something like strip all strings starting with "__attribute__"?
As for the * rule, it is able to strip parentheses and such, but can it also strip what is inside the ()?
or is it possible to see to the parser output somehow so I can try different rules?
EDIT:
One more question..
Does the parser read the code "as is", or does it run the preprocessor first?
EDIT 2:
I managed to achieve wanted result by adding rules
"wakeup -> "
and
"interrupt -> void"
because the token created from interrupt(USCIAB0RX_VECTOR) is apparently only "interrupt", it got replaced nicely!
Thanks for your help!
ollydbg:
--- Quote from: Acce on August 22, 2012, 11:50:48 am ---Awesome, sounds very promising! Thanks a lot!
because the "x" in interrupt(x) changes, can i do something like strip all strings starting with "__attribute__"?
As for the * rule, it is able to strip parentheses and such, but can it also strip what is inside the ()?
--- End quote ---
Hi, those rules were added years ago, it was mainly in the code completion's source code:
void Tokenizer::MacroReplace(wxString& str)
Which is under:
svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/codecompletion/parser/tokenizer.cpp
So, if you need any improvement, patches were welcome. :)
In-fact, I would like to implement these rules just like we define a real macro, such as:
--- Code: ---#define _GLIBCXX_BEGIN_NESTED_NAMESPACE(a,b) namespace a {
--- End code ---
So, it will be more clean then the currently way:
Current replace rule
--- Quote ---or is it possible to see to the parser output somehow so I can try different rules?
--- End quote ---
If you can build c::b yourself, there is a cc_test project(cbp), then you can enable the TRACE, and see what the parser do when parsing the file.
--- Quote ---EDIT:
One more question..
Does the parser read the code "as is", or does it run the preprocessor first?
--- End quote ---
There is no "preprocessor" stage in our parser, this takes a lot of time, we even don't expand the #include directive, the parser only parse each file(header file or source file) once, and it did some macro replacement in its tokenizer, also it guess whether it hit some macros in some heuristic way. Also, our parser is only a very simple c++ parser, we don't use semantic check or other complex things.
--- Quote ---EDIT 2:
I managed to achieve wanted result by adding rules
"wakeup -> "
and
"interrupt -> void"
because the token created from interrupt(USCIAB0RX_VECTOR) is apparently only "interrupt", it got replaced nicely!
Thanks for your help!
--- End quote ---
Grad to see you solved the problem. :)
Navigation
[0] Message Index
[#] Next page
Go to full version