I found that VC compiler auto-complete function can not be used for it.
Because the VC header files is special, example:
class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >
{
public:
LPTSTR m_lpstrLabel;
LPTSTR m_lpstrHyperLink;
HCURSOR m_hCursor;
HFONT m_hFont;
HFONT m_hFontNormal;
if remove ATL_NO_VTABLE, it's became:
class CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >
{
public:
it's work fine!
Have any way to fix it?
Thanks!!
In the ccoptiondlg.cpp.
bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
from.Trim(true).Trim(false);
to.Trim(true).Trim(false);
if (!re.Matches(from) || !re.Matches(to))
{
cbMessageBox(_("Replacement tokens can only contain alphanumeric characters and underscores..."),
_("Error"), wxICON_ERROR);
return false;
}
return true;
}
That's the cause of your problem.
In the ccoptiondlg.cpp.
bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
from.Trim(true).Trim(false);
to.Trim(true).Trim(false);
if (!re.Matches(from) || !re.Matches(to))
{
cbMessageBox(_("Replacement tokens can only contain alphanumeric characters and underscores..."),
_("Error"), wxICON_ERROR);
return false;
}
return true;
}
That's the cause of your problem.
Thanks!
I comment this code, and do it ok.
Now, class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > is OK!
But, other headers, egg. string winuser.h, i don't know how to make it work.
WINUSERAPI
int
WINAPI
MessageBoxA(
__in_opt HWND hWnd,
__in_opt LPCSTR lpText,
__in_opt LPCSTR lpCaption,
__in UINT uType);
WINUSERAPI
int
WINAPI
MessageBoxW(
__in_opt HWND hWnd,
__in_opt LPCWSTR lpText,
__in_opt LPCWSTR lpCaption,
__in UINT uType);
#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif // !UNICODE
What do you mean by "CC will not work!!"?
It seems the Parser can't recognize the function argument like this:
MessageBoxA(
__in_opt HWND hWnd,
__in_opt LPCSTR lpText,
__in_opt LPCSTR lpCaption,
__in UINT uType);
The related implementation was in
void ParserThread::HandleFunction(const wxString& name, bool isOperator)
So, you can exam these code carefully to see the reason. :D
Hi, all.
Today, I'm thinking how to refactor the replacement function in
In Tokenizer.cpp GetToken() function
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 this function is some kind too simple. At least, it can do a search, then a replacement.
(I have exam the code in ctags (http://ctags.sourceforge.net) and its manual, especially in it's code to do Macro replacement)
Here
http://ctags.sourceforge.net/ctags.html#OPERATIONAL%20DETAILS
−I identifier−list
Specifies a list of identifiers which are to be specially handled while parsing C and C++ source files. This option is specifically provided to handle special cases arising through the use of preprocessor macros.
When the identifiers listed are simple identifiers, these identifiers will be ignored during parsing of the source files.
If an identifier is suffixed with a ’+’ character, ctags will also ignore any parenthesis-enclosed argument list which may immediately follow the identifier in the source files.
If two identifiers are separated with the ’=’ character, the first identifiers is replaced by the second identifiers for parsing purposes.
So, at least, we can do the same thing like in Ctags.
In the option.c of Ctags source code, there are the related codes to doing identifier replacement.
/* Determines whether or not "name" should be ignored, per the ignore list.
*/
extern boolean isIgnoreToken (
const char *const name, boolean *const pIgnoreParens,
const char **const replacement)
{
boolean result = FALSE;
if (Option.ignore != NULL)
{
const size_t nameLen = strlen (name);
unsigned int i;
if (pIgnoreParens != NULL)
*pIgnoreParens = FALSE;
for (i = 0 ; i < stringListCount (Option.ignore) ; ++i)
{
vString *token = stringListItem (Option.ignore, i);
if (strncmp (vStringValue (token), name, nameLen) == 0)
{
const size_t tokenLen = vStringLength (token);
if (nameLen == tokenLen)
{
result = TRUE;
break;
}
else if (tokenLen == nameLen + 1 &&
vStringChar (token, tokenLen - 1) == '+')
{
result = TRUE;
if (pIgnoreParens != NULL)
*pIgnoreParens = TRUE;
break;
}
else if (vStringChar (token, nameLen) == '=')
{
if (replacement != NULL)
*replacement = vStringValue (token) + nameLen + 1;
break;
}
}
}
}
return result;
}
Here is what we can do in our Code completion code:
inline const wxString& ThisOrReplacement(const wxString& str) const
{
ConfigManagerContainer::StringToStringMap::const_iterator it = s_Replacements.find(str);
if (it != s_Replacements.end()){
//Here we should example the "it->second"
// if it is a "=new_token" string, the current_token should be replaced by "new_token"
// if it is a "-" , the current string should be ignored, then we should return next token
// if it is a "+", the next "parenthesis-enclosed argument list" should be ignored
// if it match any other pre-defined string grama, we will do other thing , eg, expand the current token to two tokens...
//......
//return it->second;
}
return str;
}
Any Comments?
@loaden:
I copy a large header from "Visual studio C++ header folder" which named "WINUSER.h" (232KB)
And I paste to the root of my test project folder, and renamed to "testWINUSER.h"
Then create a simple project
#include "testWINUSER.H"
int main()
{
UserHandleGrantA //code completion works fine!
return 0;
}
And every thing works fine.. At least the last function declaration in that header file is
BOOL UserHandleGrantAccess(
HANDLE hUserHandle,
HANDLE hJob);
And code completion works fine! This means the totally 232K files were parsed, not break in the middle. :D