Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
vector<int> is OK, but string or wstring no-work.
ollydbg:
test code:
--- Code: ---int abc(int aaaaa)
{
int bb;
aaa
return 0;
}
int main()
{
cout << "Hello world!" << endl;
return 0;
}
--- End code ---
In a old version of C::B, it works!
--- Code: ---MarkItemsByAI()
ParseUsingNamespace() Parse file scope for "using namespace"
ParseFunctionArguments() Parse function arguments
FindCurrentFunctionStart() Current function: int abc(int aaaaa) (at line 1)
GenerateResultSet() search 'abc', parent='Global namespace (id:0, type:(null)), isPrefix=0'
ParseFunctionArguments() + Function match: abc
ParseFunctionArguments() Parsing arguments: "int aaaaa;"
ParseLocalBlock() Parse local block
ParseLocalBlock() Block:
int bb;
aaa
ParseLocalBlock() Local tokens:
ParseLocalBlock() + int aaaaa parent =
ParseLocalBlock() + int bb parent =
AI() AI enter, actual: " aaa"
AI() =========================================================
--- End code ---
In the current C::B, failed. see the log:
--- Code: ---MarkItemsByAI()
ParseUsingNamespace() Parse file scope for "using namespace"
ParseLocalBlock() Parse local block
FindCurrentFunctionStart() Looking for tokens in 'C:\cb\testforum\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() (Next) Iteration...
FindCurrentFunctionStart() Iterating: tN='int main()', tF='C:\cb\testforum\main.cpp', tStart=9, tEnd=12
FindCurrentFunctionStart() Function out of bounds: tN='int main()', tF='C:\cb\testforum\main.cpp', tStart=9, tEnd=12, line=5 (size_t)line=5
FindCurrentFunctionStart() (Next) Iteration...
FindCurrentFunctionStart() Iterating: tN='int abc(int aaaaa)', tF='C:\cb\testforum\main.cpp', tStart=2, tEnd=7
FindCurrentFunctionStart() Current function: 'int abc(int aaaaa)' (at line 1)
FindCurrentFunctionStart() Namespace='', proc='abc' (returning 20)
ParseLocalBlock() Block:
int bb;
aa
ParseLocalBlock() Local tokens:
ParseLocalBlock() + int bb parent =
AI() AI enter, actual_search: " aa"
AI() =========================================================
--- End code ---
So, I will check why the function parameters were not added.....
blueshake:
--- Quote from: Loaden on January 17, 2010, 12:53:04 pm ---
--- Code: ---#include <iostream>
#include <map>
#include <string>
int main()
{
typedef std::map<int, std::string> TestMap;
TestMap testMap;
// testMap. // not work!
std::map<int, std::string> m;
m.insert(1, "Hello World!"); // work fine.
return 0;
}
--- End code ---
--- End quote ---
@Loaden
you can not typedef something in the function body.The reason is not clear for me,maybe ollydbg or morten can release some answers. :D
ollydbg:
Quite strange. See the function below:
--- Code: ---// Here, we collect the "using namespace XXXX" directives
// Also, we locate the current caret in which function, then, add the function parameters to Token trie
// Also, the variables in the function body( local block ) was add to the Token trie
size_t NativeParser::MarkItemsByAI(TokenIdxSet& result, bool reallyUseAI, bool noPartialMatch, bool caseSensitive, int caretPos)
{
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(F(_T("MarkItemsByAI()")));
result.clear();
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (!ed)
return 0;
if (!m_Parser.Done())
Manager::Get()->GetLogManager()->DebugLog(_T("C++ Parser is still parsing files..."));
else
{
// remove old temporaries
m_Parser.GetTokens()->FreeTemporaries();
m_Parser.GetTempTokens()->Clear();
// find "using namespace" directives in the file
TokenIdxSet search_scope;
ParseUsingNamespace(ed, search_scope, caretPos);
// parse function's arguments
ParseFunctionArguments(ed, caretPos);
// parse current code block (from the start of function up to the cursor)
ParseLocalBlock(ed, caretPos);
if (!reallyUseAI)
{
// all tokens, no AI whatsoever
TokensTree* tokens = m_Parser.GetTokens();
for (size_t i = 0; i < tokens->size(); ++i)
result.insert(i);
return result.size();
}
// we have correctly collected all the tokens, so we will do the artificial intelligence search
return AI(result, ed, wxEmptyString, noPartialMatch, caseSensitive, &search_scope, caretPos);
}
return 0;
}
--- End code ---
So, the
--- Code: ---ParseFunctionArguments(ed, caretPos);
--- End code ---
should be called. But see in the ParseFunctionArguments body, there is a log out put :
--- Code: ---bool NativeParser::ParseFunctionArguments(cbEditor* ed, int caretPos)
{
if (!ed)
return false;
if (m_Parser.Done())
return false;
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(_T("ParseFunctionArguments() Parse function arguments"));
TokenIdxSet proc_result;
if (FindCurrentFunctionToken(ed, proc_result, caretPos) != 0)
{
for (TokenIdxSet
--- End code ---
But I can't see any text about "ParseFunctionArguments() Parse function arguments" in the debug log output.... Why?
blueshake:
hi,guys.
I found the bug
in the ParseFunctionArguments
should be so
--- Code: --- if (!m_Parser.Done())
return false;
--- End code ---
not so.
--- Code: --- if (m_Parser.Done())
return false;
--- End code ---
ollydbg:
--- Quote from: blueshake on January 17, 2010, 02:33:43 pm ---hi,guys.
I found the bug
in the ParseFunctionArguments
should be so
--- Code: --- if (!m_Parser.Done())
return false;
--- End code ---
not so.
--- Code: --- if (m_Parser.Done())
return false;
--- End code ---
--- End quote ---
Great! Why the "!" is missing........It seems we haven't change this function.
Edit:
It is a typo in rev 6058. :D
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version