#include <iostream>
#include <string>
int main()
{
std::string s;
s.
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
s.
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
basic_string<char> s;
s.
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
basic_string<wchar_t> ws;
ws.
return 0;
}
#include <iostream>
#include <string>
int main()
{
std::basic_string<char> s;
s.
return 0;
}
the string's ancestor is lost.that is why it can not work.I don't thinks that's the reason. In fact I think I found it.
blueshake: I believe this is related to the "real time parse" where probably some false file information is passed... Could that be? Can you please try SVN trunk?
Parsing stage done (141 total parsed files, 28885 tokens in 0 minute(s), 1.781 seconds).
Parsing stage done (164 total parsed files, 30028 tokens in 0 minute(s), 1.985 seconds).
and see the string information in svn 5986 and svn 6056.see the screen shot.Hmmm... weird. So it could also e related to OllyDbg's modifications for the typedef handling. Because it's in fact a typedef.
#include <iostream>
using namespace std;
class qq
{
int x;
int y;
};
typedef qq pp;
typedef pp tt;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
Hmmm... could you do me a favour and try r6044 versus r6045? r6044 should still work. The modifications between r5986 and r6044 should not matter.QuoteParsing stage done (141 total parsed files, 28885 tokens in 0 minute(s), 1.781 seconds).QuoteParsing stage done (164 total parsed files, 30028 tokens in 0 minute(s), 1.985 seconds).
Hmmm... could you do me a favour and try r6044 versus r6045? r6044 should still work. The modifications between r5986 and r6044 should not matter.QuoteParsing stage done (141 total parsed files, 28885 tokens in 0 minute(s), 1.781 seconds).QuoteParsing stage done (164 total parsed files, 30028 tokens in 0 minute(s), 1.985 seconds).
#include <iostream>
using namespace std;
class qq
{
int x;
int y;
};
typedef qq pp;
typedef pp tt;
tt cc;//
int main()
{
cout << "Hello world!" << endl;
return 0;
}
the issue still exist.so I think there is something wrong with parserthread.OK - after some tests it's definitely related to:
the issue still exist.so I think there is something wrong with parserthread.OK - after some tests it's definitely related to:
http://forums.codeblocks.org/index.php/topic,11754.msg79756.html#msg79756
Stage management is not working as before. OllyDbg?!what does "stage management" means???
It meant the modifications you did with Tokenizer state (introducing the enum TokenizerState).QuoteStage management is not working as before. OllyDbg?!what does "stage management" means???
else if (token==ParserConsts::kw_operator)
{
bool oldState = m_Tokenizer.IsSkippingUnwantedTokens();
m_Tokenizer.SetSkipUnwantedTokens(false);
m_Tokenizer.SetOperatorState(true);
TokenizerState oldState = m_Tokenizer.GetState();
m_Tokenizer.SetState(tsSkipNone);
// don't forget to reset that if you add any early exit condition!
bool oldState = m_Tokenizer.IsSkippingUnwantedTokens();
m_Tokenizer.SetSkipUnwantedTokens(false);
// don't forget to reset that if you add any early exit condition!
TokenizerState oldState = m_Tokenizer.GetState();
m_Tokenizer.SetState(tsSkipUnWanted);
template < XXXX >
class AAA{
...
}
bool oldState = m_Tokenizer.IsSkippingUnwantedTokens();
m_Tokenizer.SetSkipUnwantedTokens(false);
m_Tokenizer.SetOperatorState(true);
Do some parsing..
m_Tokenizer.SetSkipUnwantedTokens(oldState);
But for the long run, I think add a state is convient :DI know, that's why I applied the patch. ;-) However, there seems to be something wrong with the new implementation where you surely can help... :P
Does this bug comes from the "real-time CC" or the patch of my modification of Tokenizer??? :?From the new Tokenizer states. Have another look at my previous post. The two examples in the code do obviously the opposite of what was done previously. Is this intended behaviour of yours?
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6058)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -403,7 +403,7 @@
// need to reset tokenizer's behavior
// don't forget to reset that if you add any early exit condition!
TokenizerState oldState = m_Tokenizer.GetState();
- m_Tokenizer.SetState(tsSkipUnWanted);
+ m_Tokenizer.SetState(tsSkipNone);
m_Str.Clear();
m_LastToken.Clear();
@@ -1385,7 +1385,7 @@
wxString next = m_Tokenizer.PeekToken(); // named namespace
if (next==ParserConsts::opbrace)
{
- m_Tokenizer.SetState(tsSkipNone);
+ m_Tokenizer.SetState(tsSkipUnWanted);
// use the existing copy (if any)
Token* newToken = TokenExists(ns, m_pLastParent, tkNamespace);
// need to reset tokenizer's behavior
// don't forget to reset that if you add any early exit condition!
TokenizerState oldState = m_Tokenizer.GetState();
m_Tokenizer.SetState(tsSkipUnWanted);
m_Str.Clear();
....
No, the first place when entering the DoParse function. we should set the state to "Could you explain '' a little more? Set to what exactly? And what's with the second one?
No, the first place when entering the DoParse function. we should set the state to "Could you explain '' a little more? Set to what exactly? And what's with the second one?
OK, let me explain the old way( before the patch of Tokenizer state related code). [...]Thanks, that made things clear to me.
m_Tokenizer.SetOperatorState(true);
For example (void ParserThread::DoParse()):Any comments on that...?!
Before:CodeAfter:else if (token==ParserConsts::kw_operator)
{
bool oldState = m_Tokenizer.IsSkippingUnwantedTokens();
m_Tokenizer.SetSkipUnwantedTokens(false);
m_Tokenizer.SetOperatorState(true);CodeTokenizerState oldState = m_Tokenizer.GetState();
m_Tokenizer.SetState(tsSkipNone);
So finally, what happened to:CodeThis is not applied anymore if I got the new implementation right. Look again:m_Tokenizer.SetOperatorState(true);
For example (void ParserThread::DoParse()):Any comments on that...?!
Before:CodeAfter:else if (token==ParserConsts::kw_operator)
{
bool oldState = m_Tokenizer.IsSkippingUnwantedTokens();
m_Tokenizer.SetSkipUnwantedTokens(false);
m_Tokenizer.SetOperatorState(true);CodeTokenizerState oldState = m_Tokenizer.GetState();
m_Tokenizer.SetState(tsSkipNone);
void AAA::operator + (XXXX)
or
void AAA::operator = (XXXX)
// i_integer = from.i_;
// f_float = from.f_;
std::string ss;
ss.
string s;
s.
std::string ss;
my_string ms;
ss.
Ok, have a further test, [...]Just for the record: I've implemented some more debugging facilities with the last commit of mine. You can now save the tokens tree to an ASCii file from the CC debug window.
Ok, have a further test, [...]Just for the record: I've implemented some more debugging facilities with the last commit of mine. You can now save the tokens tree to an ASCii file from the CC debug window.
Ok, have a further test, I'm fully agree with blueshake's No ancestor's in the current string Token (http://forums.codeblocks.org/index.php/topic,11800.msg80086.html#msg80086), so, the "string" have no ancestors, that's the reason why we don't have string members list auto completion.I wonder if the modification you did in void ParserThread::ReadClsNames(wxString& ancestor) are 100% correct. NOtice this code snippet:
else if ( wxIsalpha(current.GetChar(0))
&& ( (m_Tokenizer.PeekToken() == ParserConsts::semicolon)
|| (m_Tokenizer.PeekToken() == ParserConsts::comma)) )
{
TRACE(_T("ReadClsNames() : Adding variable '%s' as '%s' to '%s'"),
current.wx_str(),
m_Str.wx_str(),
(m_pLastParent ? m_pLastParent->m_Name.wx_str():_T("<no-parent>")));
Token* newToken = DoAddToken(tkTypedef, current, m_Tokenizer.GetLineNumber());
if (!newToken)
break;
else
{
wxString tempAncestor = ancestor;
newToken->m_AncestorsString = tempAncestor;
newToken->m_ActualType = tempAncestor;
newToken->m_Type = tempAncestor;
}
}
else if ( wxIsalpha(current.GetChar(0))
&& ( (m_Tokenizer.PeekToken() == ParserConsts::semicolon)
|| (m_Tokenizer.PeekToken() == ParserConsts::comma)) )
{
TRACE(_T("ReadClsNames() : Adding variable '%s' as '%s' to '%s'"),
current.wx_str(),
m_Str.wx_str(),
(m_pLastParent ? m_pLastParent->m_Name.wx_str():_T("<no-parent>")));
m_Str.clear();
wxString tempAncestor = ancestor;
m_Str = tempAncestor;
Token* newToken = DoAddToken(tkTypedef, current, m_Tokenizer.GetLineNumber());
if (!newToken)
break;
else
{
newToken->m_AncestorsString = tempAncestor;
//newToken->m_ActualType = tempAncestor;
//if (m_IsPointer)
//{
// newToken->m_Type = tempAncestor + _T("*");
//}
//else
//newToken->m_Type = tempAncestor;
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
inline basic_string<_CharT, _Traits, _Alloc>::
basic_string()
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
: _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
#else
: _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
#endif
// operator+
/**
* @brief Concatenate two strings.
* @param lhs First string.
* @param rhs Last string.
* @return New string with value of @a lhs followed by @a rhs.
*/
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>
operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
{
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
__str.append(__rhs);
return __str;
}
DoAddToken() : Found token (parent).
DoAddToken() : Created token='compare', file_idx=1, line=2016
GetActualTokenType() : Searching within m_Str='int'
GetActualTokenType() : Compensated m_Str='int'
GetActualTokenType() : Found 'int'
DoAddToken() : Prepending ''
DoAddToken() : Added/updated token 'compare' (172), type 'int', actual 'int'. Parent is basic_string (1)
DoParse() : Loop:m_Str='', token=';'
DoParse() : Loop:m_Str='', token='int'
DoParse() : Loop:m_Str='int ', token='compare'
HandleFunction() : Adding function 'compare': m_Str='int '
HandleFunction() : name='compare', args='(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2)', peek='const'
HandleFunction() : !(Ctor/Dtor) 'compare', m_Str='int ', localParent='<none>'
HandleFunction() : Adding function 'compare', ': m_Str='int ', enc_ns='nil'.
HandleFunction() : Add token name='compare', args='(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2)', return type='int '
GetStrippedArgs() : args='(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2)'.
GetStrippedArgs() : stripped_args='(size_type,size_type,const _CharT*,size_type)'.
DoAddToken() : Found token (parent).
DoAddToken() : Created token='compare', file_idx=1, line=2042
GetActualTokenType() : Searching within m_Str='int'
GetActualTokenType() : Compensated m_Str='int'
GetActualTokenType() : Found 'int'
DoAddToken() : Prepending ''
DoAddToken() : Added/updated token 'compare' (173), type 'int', actual 'int'. Parent is basic_string (1)
DoParse() : Loop:m_Str='', token=';'
DoParse() : Loop:m_Str='', token='}'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='inline'
DoParse() : Loop:m_Str='', token='#'
HandlePreprocessorBlocks() : Saving nesting level: 1
HandlePreprocessorBlocks() : Restoring nesting level: 1 (was 1)
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='basic_string'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='basic_string'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='basic_string'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='inline'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='inline'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='inline'
DoParse() : Loop:m_Str='', token='}'
DoParse() : Loop:m_Str='', token='template'
DoParse() : template argument='<typename _CharT, typename _Traits, typename _Alloc>', token ='inline'
Parsing stage done (1 total parsed files, 174 tokens in 0 minute(s), 8.377 seconds).
Updating class browser...
Class browser updated.
if (token == ParserConsts::kw_template)
{
// There are some template defintions that are not working like
// within gcc headers (NB: This syntax is a GNU extension):
// extern template
// const codecvt<char, char, mbstate_t>&
// use_facet<codecvt<char, char, mbstate_t> >(const locale&);
m_Tokenizer.SetState(tsTemplateArgument);
wxString args = m_Tokenizer.GetToken();
token = m_Tokenizer.GetToken();
TRACE(_T("DoParse() : Template argument='%s', token ='%s'"), args.wx_str(), token.wx_str());
if (token==ParserConsts::kw_class)
{
m_Str.Clear();
if (m_Options.handleClasses)
HandleClass(ctClass, args);
else
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
else if (token==ParserConsts::kw_struct)
{
m_Str.Clear();
if (m_Options.handleClasses)
HandleClass(ctStructure, args);
else
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
else
{
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
inline bool
operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
{ return __lhs.compare(__rhs) <= 0; }
Any way, checking the next token after the template argument is not a correct way.True, but I still wonder why it works with vector and alike and why with any revision before applying your and blueshake's patch it used to work. There must be another error.
EXPORT
WXDLLIMPEXP_CORE
WXDLLIMPEXP_BASE
WXDLLIMPEXP_XML
WXDLLIMPEXP_XRC
WXDLLIMPEXP_ADV
WXDLLIMPEXP_AUI
WXDLLIMPEXP_CL
WXDLLIMPEXP_LE_SDK
WXDLLIMPEXP_SQLITE3
WXMAKINGDLL
WXUSINGDLL
_CRTIMP
__CRT_INLINE
__cdecl
__stdcall
WXDLLEXPORT
WXDLLIMPORT
wxT
wxTopLevelWindowNative=wxTopLevelWindowMSW
wxWindow=wxWindowMSW
wxStatusBar=wxStatusBarBase
WXUNUSED
wxDEPRECATED
_T
ATTRIBUTE_PRINTF_1
ATTRIBUTE_PRINTF_2
WXDLLIMPEXP_FWD_BASE
WXDLLIMPEXP_FWD_CORE
DLLIMPORT
DECLARE_INSTANCE_TYPE
emit
Q_OBJECT
Q_PACKED
Q_GADGET
QT_BEGIN_HEADER
QT_END_HEADER
Q_REQUIRED_RESULT
Q_INLINE_TEMPLATE
Q_OUTOFLINE_TEMPLATE
_GLIBCXX_BEGIN_NAMESPACE(std)=namespace std{
_GLIBCXX_END_NAMESPACE=}
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)=namespace std{
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)=namespace std{
_GLIBCXX_END_NESTED_NAMESPACE=}
_GLIBCXX_STD=std
WXDLLIMPEXP_SCI
__const=const
__restrict
__THROW
__wur
_STD_BEGIN=namespace std{
_STD_END=}
__CLRCALL_OR_CDECL
_CRTIMP2_PURE
_STD_BEGIN=namespace std{
_STD_END=}
__CLRCALL_OR_CDECL
if (token == ParserConsts::kw_template)
{
m_Tokenizer.SetState(tsTemplateArgument);
wxString args = m_Tokenizer.GetToken();
token = m_Tokenizer.GetToken();
TRACE(_T("DoParse() : template argument='%s', token ='%s'"), args.wx_str(), token.wx_str());
if (token==ParserConsts::kw_class)
{
m_Str.Clear();
if (m_Options.handleClasses)
HandleClass(ctClass,args);
else
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
else if (token==ParserConsts::kw_struct)
{
m_Str.Clear();
if (m_Options.handleClasses)
HandleClass(ctStructure,args);
else
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
else
{
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
}
else
{
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
inline wstring
to_wstring(long long __val)
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4 * sizeof(long long),
L"%lld", __val); }
if (token == ParserConsts::kw_template)
{
m_Tokenizer.SetState(tsTemplateArgument);
m_TemplateArgument = m_Tokenizer.GetToken();
m_Str.Clear();
token = m_Tokenizer.GetToken();
TRACE(_T("DoParse() : Reading Template argument='%s'"), m_TemplateArgument.wx_str());
m_Tokenizer.SetState(tsSkipUnwanted);
}
class Token : public BlockAllocated<Token, 10000>{
...
wxString m_TemplateArgument;
}
I'm planning adding a variable to store the Template argument in the ParserThread.cpp.Sounds good.
[...]
Also, I suggest that in the Token.h.For what purpose? Displaying the template arguments?
we can add a member to the Token class. like:
[...]
For what purpose? Displaying the template arguments?Yes, also, if we need to do some template instantiation, we need to store the template argument.
class basic_string
{
};
_GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Alloc>
class allocator;
template<class _CharT>
struct char_traits;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
class basic_string;
template<> struct char_traits<char>;
typedef basic_string<char> string;
#ifdef _GLIBCXX_USE_WCHAR_T
template<> struct char_traits<wchar_t>;
typedef basic_string<wchar_t> wstring;
#endif
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) \
&& defined(_GLIBCXX_USE_C99_STDINT_TR1))
template<> struct char_traits<char16_t>;
template<> struct char_traits<char32_t>;
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
#endif
_GLIBCXX_END_NAMESPACE
//string aaaa;
//aaaa.
you can find that the string loses its ancestor.It work before.Exactly. That's what I noticed, too. Still: I don't see why that is. But it's most likely related to Ollydbg's patch. So I was hoping he'd help us...
Ok, I will try my best to find the bug :Dyou can find that the string loses its ancestor.It work before.Exactly. That's what I noticed, too. Still: I don't see why that is. But it's most likely related to Ollydbg's patch. So I was hoping he'd help us...
_GLIBCXX_END_NAMESPACE to }
<TOKEN_REPLACEMENTS>
<ssmap>
<_GLIBCXX_END_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE>
<_GLIBCXX_BEGIN_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NAMESPACE>
<_GLIBCXX_BEGIN_NAMESPACE_TR1>
<![CDATA[-namespace tr1 {]]>
</_GLIBCXX_BEGIN_NAMESPACE_TR1>
<_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<_GLIBCXX_END_NAMESPACE_TR1>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE_TR1>
<_GLIBCXX_END_NESTED_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NESTED_NAMESPACE>
<_GLIBCXX_STD>
<![CDATA[std]]>
</_GLIBCXX_STD>
</ssmap>
</TOKEN_REPLACEMENTS>
Tokenizer::SetReplacementString(_T("_GLIBCXX_END_NAMESPACE"), _T("}"));
void CodeCompletion::LoadTokenReplacements()
{
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
ConfigManagerContainer::StringToStringMap& repl = Tokenizer::GetTokenReplacementsMap();
repl.clear();
if (!cfg->Exists(_T("token_replacements")))
{
// first run; add default replacements string
Tokenizer::SetReplacementString(_T("_GLIBCXX_STD"), _T("std"));
Tokenizer::SetReplacementString(_T("_GLIBCXX_BEGIN_NESTED_NAMESPACE"), _T("+namespace"));
Tokenizer::SetReplacementString(_T("_GLIBCXX_END_NESTED_NAMESPACE"), _T("}"));
Tokenizer::SetReplacementString(_T("_GLIBCXX_BEGIN_NAMESPACE"), _T("+namespace"));
Tokenizer::SetReplacementString(_T("_GLIBCXX_END_NAMESPACE_TR1"), _T("}"));
Tokenizer::SetReplacementString(_T("_GLIBCXX_BEGIN_NAMESPACE_TR1"), _T("-namespace tr1 {"));
}
else
cfg->Read(_T("token_replacements"), &repl);
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
basic_string<char> bs;
bs.append("work fine!");
basic_string<wchar_t> wbs;
wbs.append(L"work too!");
return 0;
}
After that, CC works now !!!!Great! Thank you very much! :lol:
After that, CC works now !!!!Not for me. :-(
It works here. You can see the screenshot as an attachment.After that, CC works now !!!!Not for me. :-(
What happens if you just open the TESTING workspace of the CC plugin, activate the STL project, open stl.cpp and uncomment the "ss.". CC does not kick in for me!
In the original code the order in how the strings were replaced (when replacing in the whole buffer) did matter. I don't think it does so in the current version as it is based on the appearance of the tokens, but just to double check: Is that correct?In the replacement map( wxString Key to wxString Value), I don't think current code has some thing wrong, because each "wxString Key" are different. right? Oh, I can confirm that what you concern won't happen. because when the Tokenizer DoGetToken, they will return a whole "Token string", thus, "_GLIBCXX_BEGIN_NAMESPACE_TR1" and "_GLIBCXX_END_NAMESPACE" are totally different tokens when we are at the last stage of the DoGetToken() function.
I applied this patch, string parsing normal, but wstring parsing is not correct.It works here. You can see the screenshot as an attachment.After that, CC works now !!!!Not for me. :-(
What happens if you just open the TESTING workspace of the CC plugin, activate the STL project, open stl.cpp and uncomment the "ss.". CC does not kick in for me!In the original code the order in how the strings were replaced (when replacing in the whole buffer) did matter. I don't think it does so in the current version as it is based on the appearance of the tokens, but just to double check: Is that correct?In the replacement map( wxString Key to wxString Value), I don't think current code has some thing wrong, because each "wxString Key" are different. right? Oh, I can confirm that what you concern won't happen. because when the Tokenizer DoGetToken, they will return a whole "Token string", thus, "_GLIBCXX_BEGIN_NAMESPACE_TR1" and "_GLIBCXX_END_NAMESPACE" are totally different tokens when we are at the last stage of the DoGetToken() function.
Finally, I think the answer is :"it is correct". :D
#include <iostream>
#include <string>
using namespace std;
int main()
{
basic_string<wchar_t> ws;
ws.
return 0;
}
std::string s;
s. // << CC shall kick in here!
Assume you have several projects in a WS (like the CC "TESTING" WS). Now if you have project A activated but edit a file with the same name of project B and within a function of the same name as present in project A the real-time parse will update the parser according to the editors name. Hence this may be truncated so what gets updated is the wrong method.
I think a full file name with full path(such as: C:\projectA\AAA.cpp or C:\projectB\AAA.cpp )is recorded in the filelist of CC.
if I remember right,the editor name should be the full name.for your example.if there are two same name files in projectA and projectB.
it should be .\projectA\filename
it should be .\projectB\filename
the parser should parse the file correctly according the editor file.
I think a full file name with full path(such as: C:\projectA\AAA.cpp or C:\projectB\AAA.cpp )is recorded in the filelist of CC.
Oh, look this screenshot.@LoadenCode#include <iostream>
#include <string>
using namespace std;
int main()
{
basic_string<wchar_t> ws;
ws.
return 0;
}
where is the option "parse while typiing"?Menu->settings->Editor->CodeCompletion.
hi,I encouter that the parser can not parse in real-time even I enable "parse while typing".
edit:
update to the latest svn without any change.
If you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.Oh, look this screenshot.@LoadenCode#include <iostream>
#include <string>
using namespace std;
int main()
{
basic_string<wchar_t> ws;
ws.
return 0;
}
This works fine here, rev 6083.
You can see the screen shot below:
If you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.
QuoteIf you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.
you can not use variable name ws here.because it has been defined in istream.tcc which belong to gcc files.
Note:
try another name e.g. wsss,you will get the answer.
Confirm it! Thanks!QuoteIf you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.
you can not use variable name ws here.because it has been defined in istream.tcc which belong to gcc files.
Note:
try another name e.g. wsss,you will get the answer.
Good! So, this is not a problem. :wink:
#include <iostream>
#include <string>
int main()
{
std::wstring ws;
ws.
return 0;
}
the reason is simple.I don't get it. m_NeedReparse was used just there. So what's wrong with this piece of code:
the variable needParse's scope is function scope.when it (needParse) leave the functioin body.it will be destroyed.so it will be false again when the carect is in different line.
Parser* parser = m_NativeParser.GetParserPtr();
bool needReparse = false;
if ( parser && parser->Options().whileTyping
&& ( (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
|| (event.GetModificationType() & wxSCI_MOD_DELETETEXT) ) )
{
needReparse = true;
}
if (control->GetCurrentLine() != m_CurrentLine)
{
if (parser && needReparse)
parser->Reparse(editor->GetFilename());
else
FindFunctionAndUpdate(control->GetCurrentLine());
}
@mortenDone in my local copy. Will commit in a while... probably after blueshake answered the other question which may require some modifications, too.
This is a big bug, should be fixed soon.
Re: The 12 January 2010 build (6080) is out. (http://forums.codeblocks.org/index.php/topic,11844.msg80487.html#msg80487)
I don't get it. m_NeedReparse was used just there. So what's wrong with this piece of code:
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6083)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2085,17 +2085,24 @@
}
Parser* parser = m_NativeParser.GetParserPtr();
- bool needReparse = false;
+ //bool needReparse = false;
if ( parser && parser->Options().whileTyping
&& ( (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
|| (event.GetModificationType() & wxSCI_MOD_DELETETEXT) ) )
{
- needReparse = true;
+ //needReparse = true;
+ m_NeedReparse = true;
}
if (control->GetCurrentLine() != m_CurrentLine)
{
- if (parser && needReparse)
- parser->Reparse(editor->GetFilename());
+
+ if (parser && m_NeedReparse)
+ {
+ m_NeedReparse = false;
+ parser->Reparse(editor->GetFilename());
+ }
else
FindFunctionAndUpdate(control->GetCurrentLine());
}
Index: src/plugins/codecompletion/codecompletion.h
===================================================================
--- src/plugins/codecompletion/codecompletion.h (revision 6083)
+++ src/plugins/codecompletion/codecompletion.h (working copy)
@@ -135,7 +135,7 @@
int m_ActiveCalltipsNest;
bool m_IsAutoPopup;
-
+ bool m_NeedReparse;
wxChoice* m_Function;
wxChoice* m_Scope;
FunctionsScopeVec m_FunctionsScope;
This does normally (never ?) happen inside the same event, so we have to remember whether a reparse is needed, either with a member-variable or a static local variable.Dammed. Now I got the point. Ok... I'll take care...
Me should not work when being sick. :?
bool m_IsOperator;
inline const wxString& ThisOrReplacement(const wxString& str) const
{
ConfigManagerContainer::StringToStringMap::const_iterator it = s_Replacements.find(str);
if (it != s_Replacements.end())
return it->second;
return str;
};
I think a variable in Tokenizer class can be removed, because it is never used any more.
Code:
bool m_IsOperator;
BTW: comparing with the "operator" keyword is done in the ParserThread class instead of Tokenizer class.
if (!token)
{
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(_T("FindAIMatches() Token is NULL?!"));
continue;
}
// ignore operators
if (token->m_IsOperator)
continue;
// enums children (enumerators), are added by default
if (token->m_TokenKind == tkEnum)
{
// insert enum type
result.insert(id);
No, There is a member m_IsOperator in the Token class. so does in Tokenizer class.QuoteI think a variable in Tokenizer class can be removed, because it is never used any more.
Code:
bool m_IsOperator;
BTW: comparing with the "operator" keyword is done in the ParserThread class instead of Tokenizer class.
@ollydbg
it was used here in nativeparser.cppCodeif (!token)
{
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(_T("FindAIMatches() Token is NULL?!"));
continue;
}
// ignore operators
if (token->m_IsOperator)
continue;
// enums children (enumerators), are added by default
if (token->m_TokenKind == tkEnum)
{
// insert enum type
result.insert(id);
#include <iostream>
using namespace std;
int abc(int aa)
{
int bb;
aa----------------------not work here.
return 0;
}
int main()
{
cout << "Hello world!" << endl;
return 0;
}
ParseLocalBlock() Block:
int bb;
aa
ParseLocalBlock() Local tokens:
ParseLocalBlock() + int bb parent =
AI() AI enter, actual_search: " aa"
AI() =========================================================
ParseLocalBlock() Block:
int bb;
aa
ParseLocalBlock() Local tokens:
ParseLocalBlock() + int aa parent =
ParseLocalBlock() + int bb parent =
AI() AI enter, actual: " aa"
AI() =========================================================
#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;
}
std::map<int, std::string> m;
m.insert(1, "Hello World!"); // work fine.
Quotestd::map<int, std::string> m;
m.insert(1, "Hello World!"); // work fine.
not work for me.
I search the tokenstree and get nothing.
int abc(int aaaaa)
{
int bb;
aaa
return 0;
}
int main()
{
cout << "Hello world!" << endl;
return 0;
}
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() =========================================================
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() =========================================================
@LoadenCode#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;
}
// 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;
}
ParseFunctionArguments(ed, caretPos);
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
if (!m_Parser.Done())
return false;
if (m_Parser.Done())
return false;
hi,guys.
I found the bug
in the ParseFunctionArguments
should be soCodeif (!m_Parser.Done())
return false;
not so.Codeif (m_Parser.Done())
return false;
Great! Why the "!" is missing........It seems we haven't change this function.My fault. I was removing the artifacts from the past where there used to be a parser per project. So I changed all references to "per project parser" to the global none and obviously missed the !" there. Sorry. Will fix asap...
@LoadenCode#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;
}
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
#include <iostream>
#include <map>
#include <string>
typedef std::map<int, std::string> TestMap;
class A
{
public:
void Test()
{
TestMap2 t2;
t2.in // works here too.
}
private:
typedef std::map<int, std::string> TestMap2;
}
int main()
{
TestMap testMap;
testMap.i // ok, work now.
return 0;
}
#include <iostream>
int main()
{
// std::cou // not work!
std::endl // work here.
return 0;
}
There's a small problem.That's not a problem, that's by design.
#include <iostream>
int main()
{
// std::cou // not work!
std::endl // work here.
return 0;
}
where is the definition of std::cout???Directly in iostream:
extern istream cin; ///< Linked to standard input
extern ostream cout; ///< Linked to standard output
extern ostream cerr; ///< Linked to standard error (unbuffered)
extern ostream clog; ///< Linked to standard error (buffered)
In my opinion: In the parserThread DoParse function, when it meet the "extern" keyword, the parser just skip to the the ";".
In my opinion: In the parserThread DoParse function, when it meet the "extern" keyword, the parser just skip to the the ";".No, the code is question is as follows:
else if (token==ParserConsts::kw_extern)
{
// check for "C"
m_Str = m_Tokenizer.GetToken();
if (m_Str==ParserConsts::kw_C)
{
m_Tokenizer.GetToken(); // "eat" {
DoParse(); // time for recursion ;)
}
else
{
// do nothing, just skip keyword "extern", otherwise uncomment:
//SkipToOneOfChars(ParserConsts::semicolon); // skip externs
}
m_Str.Clear();
}
m_Str = m_Tokenizer.GetToken();
if (m_Str==ParserConsts::kw_C)
{
m_Tokenizer.GetToken(); // "eat" {
DoParse(); // time for recursion ;)
}
else
{
// do nothing, just skip keyword "extern", otherwise uncomment:
//SkipToOneOfChars(ParserConsts::semicolon); // skip externs
}
m_Str.Clear();
m_Str = m_Tokenizer.GetToken();
m_Str.Clear();
//m_Str.Clear();
New bug:Code#include <iostream>
int main()
{
// std::cou // not work!
std::endl // work here.
return 0;
}
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6089)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -524,7 +524,7 @@
else if (token==ParserConsts::kw_extern)
{
// check for "C"
- m_Str = m_Tokenizer.GetToken();
+ m_Str = m_Tokenizer.PeekToken();
if (m_Str==ParserConsts::kw_C)
{
m_Tokenizer.GetToken(); // "eat" {
patch for it.Be careful: In that case not the "{" is "eaten" in the case of extern C {...} statements, but the "C". So your patch will work for the extern cout thing, but will break extern C {...}.CodeIndex: src/plugins/codecompletion/parser/parserthread.cpp
// check for "C"
- m_Str = m_Tokenizer.GetToken();
+ m_Str = m_Tokenizer.PeekToken();
if (m_Str==ParserConsts::kw_C)
{
m_Tokenizer.GetToken(); // "eat" {
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6089)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -534,6 +534,7 @@
{
// do nothing, just skip keyword "extern", otherwise uncomment:
//SkipToOneOfChars(ParserConsts::semicolon); // skip externs
+ m_Tokenizer.UngetToken();
}
m_Str.Clear();
}
hi,morten:Work now! :P
what about this way.CodeIndex: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6089)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -534,6 +534,7 @@
{
// do nothing, just skip keyword "extern", otherwise uncomment:
//SkipToOneOfChars(ParserConsts::semicolon); // skip externs
+ m_Tokenizer.UngetToken();
}
m_Str.Clear();
}
what about this way....I'll try.
Good idea! But it seems there are too many bool variables in the Token class.what about this way....I'll try.
BTW: I was in fact thinking about having another flag for the token to declare it as "extern" (similar to m_IsConst). This would help to e.g. overwrite the "content" in the case you find the true definition / implementation. In addition the tooltip could show "extern" if only the "extern" declaration is found, indicating that the implementation might not be known (as it is in a binary library, for example).
bool m_IsOperator;
bool m_IsLocal; // found in a local file?
bool m_IsTemp; // if true, the tree deletes it in FreeTemporaries()
bool m_IsConst; // the member method is const (yes/no)
I have deleted cb configuration files. Next run cb creates these files with default values.
I've noticed that tokens replacement list is extended. See attacment.
std::string s1; s1. now works fine
As i understand, if you patched your installation to latest nighty, configuration files are not patched at first run.
I have deleted cb configuration files. Next run cb creates these files with default values.Yes, you need edit the "default.conf" file, and add the replacement rules.
I've noticed that tokens replacement list is extended. See attacment.
std::string s1; s1. now works fine
As i understand, if you patched your installation to latest nighty, configuration files are not patched at first run.
<TOKEN_REPLACEMENTS>
<ssmap>
<_GLIBCXX_BEGIN_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NAMESPACE>
<_GLIBCXX_BEGIN_NAMESPACE_TR1>
<![CDATA[-namespace tr1 {]]>
</_GLIBCXX_BEGIN_NAMESPACE_TR1>
<_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<_GLIBCXX_END_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE>
<_GLIBCXX_END_NAMESPACE_TR1>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE_TR1>
<_GLIBCXX_END_NESTED_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NESTED_NAMESPACE>
<_GLIBCXX_STD>
<![CDATA[std]]>
</_GLIBCXX_STD>
</ssmap>
</TOKEN_REPLACEMENTS>
I'm not sure a enum variable(combine all the state in one variable) is better??In terms of memory footprint: yes. In terms of logic: the boolean field have nothing in common really. So combining them logically makes no sense. So a default enum would be enough.