User forums > General (but related to Code::Blocks)

Code Completion in foreach loop

<< < (3/4) > >>

MortenMacFly:

--- Quote from: ollydbg on October 09, 2012, 02:02:11 am ---Good work, I'm testing your patchAdded code completion of declarations in for/if/while heads, Thanks.

--- End quote ---
Feel free to take over, btw...

koonschi:



--- Quote from: ollydbg on October 09, 2012, 04:39:24 am ---1, RemoveTemplateArgs is missing in header file, comments needed for this function.


--- End quote ---

I'm confused, I just checked and I thought it was in the patch though? At least if I look at the raw patch file it is all at the bottom ...



--- Quote from: ollydbg on October 09, 2012, 04:39:24 am ---Some comments:
2,
--- Code: ---    // for loop heads look like this:
    // ([init1 [, init2 ...] ] ; [cond1 [, cond2 ..]], [mod1 [, mod2 ..]])
--- End code ---
should have the second ";" instead of ",".


--- End quote ---
Oops, you're absolutely right, I will change that asap.


--- Quote from: ollydbg on October 09, 2012, 04:39:24 am ---BTW: It is the first time I see you use another instance (smallTokenizer) of Tokenizer class in Parserthread.  :)


--- End quote ---

Well, it is the first time that I contribute to Code::Blocks, too :) I hope I did not break any rules by using it.
It seemed like the easiest thing to do though, as the expressions in parentheses are parsed as one single token. I did not want to mess around with that, as it's used for function parameters, too.

koonschi:
Corrected patch is online. RemoveTemplateArgs + comments should be in there, too.

ollydbg:
Here is my test code:

--- Code: ---void f()
{
if(TxmlElement* problem = handle.FirstChildElement("test"))
{
  /// ---> will not code complete on 'problem'
     problem;
}

}


void f2()
{
if(TxmlElement* problem1 = handle.FirstChildElement("test"))
{
  /// ---> will not code complete on 'problem'
   problem1;
}
}

--- End code ---

And I see the patch works very nice. I right click on "problem", and select find declaration, it goes to the correct position.
When I click on the "problem1", I see the temp Token "problem" is cleared, and new temp Token "problem1" is created.
Nice work, koonschi.


--- Quote ---Well, it is the first time that I contribute to Code::Blocks, too Smiley I hope I did not break any rules by using it.
It seemed like the easiest thing to do though, as the expressions in parentheses are parsed as one single token. I did not want to mess around with that, as it's used for function parameters, too.

--- End quote ---
I hope this is the beginning of your contribution to C::B, welcome!!!!
It dose not break any rules. I have no objection to use another instance of Tokenizer class in Parserthread class.

Besize that, we have a function in Parserthread

--- Code: ---bool ParserThread::GetBaseArgs(const wxString & args, wxString& baseArgs)
--- End code ---
which translate a complex full function arguments to a simple arguments like:
void f(int a=1, float *p=0x777);

here, (int a=1, float *p=0x777) will be translated to (int a, float *p), I think here we also need a smallTokenizer. :), because sometimes, there are nested "()" in the function arguments, currently implementation of GetBaseArgs() does not work correctly about those nest parentheses.

ollydbg:
Bug comes in the function: void ParserThread::HandleConditionalArguments()

Suppose I have a if condition below:


--- Code: ---if(aaaaa>bbbbb && ccccc<ddddd)

--- End code ---
When parsing, it will add a temporary token with the information below:

--- Code: ---[debug]{m_FullType = "aaaaa&&", m_BaseType = "aaaaa", m_Name = "<", m_Args = "", m_BaseArgs = "", m_AncestorsString = "", m_FileIdx = 1, m_Line = 17, m_ImplFileIdx = 0, m_ImplLine = 0, m_ImplLineStart = 0, m_ImplLineEnd = 0, m_Scope = tsUndefined, m_TokenKind = tkVariable, m_IsOperator = false, m_IsLocal = false, m_IsTemp = true, m_IsConst = 186, m_Index = 501, m_ParentIndex = 500
[debug], m_Children = std::set with 0 elements, m_Ancestors = std::set with 0 elements, m_DirectAncestors = std::set with 0 elements, m_Descendants = std::set with 0 elements, m_Aliases = 0 count of wxArrayString, m_TemplateArgument = "", m_TemplateType = 0 count of wxArrayString, m_TemplateMap = std::map with 0 elements, m_TemplateAlias = "", m_UserData = 0x0, m_TokenTree = 0x3d31270, m_Ticket = 786}>>>>>>cb_gdb:

--- End code ---

You see: m_Name is "<".

I think the logic to find a variable:

--- Code: ---   if (peek.empty())
        {
            if (!m_Str.empty())
            {
             .....
                Token *newToken = DoAddToken(tkVariable, token, smallTokenizer.GetLineNumber());

--- End code ---

Here, if peek is empty, and m_Str have some characters, but the token is “logic compare operators".

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version