Ok, it works nice.
Copy nativeparser_base.h and nativeparser_base.cpp to the parser folder.
I have add some code snippet in frame.cpp
//Here we are going to test the expression solving algorithm
NativeParserTest nativeParserTest;
wxString exp = _T("obj.m_Member1");
TokenIdxSet searchScope;
searchScope.insert(-1);
TokenIdxSet result;
TokensTree *tree = ParserTest::Get()->GetTokensTree();
nativeParserTest.TestExpression(exp,
tree,
searchScope,
result );
wxLogMessage(_T("Result have %d matches"), result.size());
for (TokenIdxSet::iterator it=result.begin(); it!=result.end(); ++it)
{
Token* token = tree->at(*it);
if (token)
{
wxString log;
log << token->GetTokenKindString() << _T(" ")
<< token->DisplayName() << _T("\t[")
<< token->m_Line << _T(",")
<< token->m_ImplLine << _T("]");
CCLogger::Get()->Log(log);
}
}
And here is the class declaration and implementation:
#ifndef NATIVEPARSERTEST_H
#define NATIVEPARSERTEST_H
#include "nativeparser_base.h"
class NativeParserTest : public NativeParserBase
{
public:
NativeParserTest();
~NativeParserTest();
bool TestExpression(wxString& expression,
TokensTree * tree,
const TokenIdxSet& searchScope,
TokenIdxSet& result);
};
#endif //NATIVEPARSERTEST_H
#include <sdk.h>
#ifndef CB_PRECOMP
#endif
#include "nativeparsertest.h"
#include "parser/cclogger.h"
#define CC_NATIVEPARSERTEST_DEBUG_OUTPUT 0
#if CC_GLOBAL_DEBUG_OUTPUT == 1
#undef CC_NATIVEPARSERTEST_DEBUG_OUTPUT
#define CC_NATIVEPARSERTEST_DEBUG_OUTPUT 1
#elif CC_GLOBAL_DEBUG_OUTPUT == 2
#undef CC_NATIVEPARSERTEST_DEBUG_OUTPUT
#define CC_NATIVEPARSERTEST_DEBUG_OUTPUT 2
#endif
#ifdef CC_PARSER_TEST
// #define ADDTOKEN(format, args...) \
// CCLogger::Get()->AddToken(F(format, ##args))
// #define TRACE(format, args...) \
// CCLogger::Get()->DebugLog(F(format, ##args))
// #define TRACE2(format, args...) \
// CCLogger::Get()->DebugLog(F(format, ##args))
#define ADDTOKEN(format, args...) \
wxLogMessage(F(format, ##args))
#define TRACE(format, args...) \
wxLogMessage(F(format, ##args))
#define TRACE2(format, args...) \
wxLogMessage(F(format, ##args))
#else
#if CC_NATIVEPARSERTEST_DEBUG_OUTPUT == 1
#define ADDTOKEN(format, args...) \
CCLogger::Get()->AddToken(F(format, ##args))
#define TRACE(format, args...) \
CCLogger::Get()->DebugLog(F(format, ##args))
#define TRACE2(format, args...)
#elif CC_NATIVEPARSERTEST_DEBUG_OUTPUT == 2
#define ADDTOKEN(format, args...) \
CCLogger::Get()->AddToken(F(format, ##args))
#define TRACE(format, args...) \
do \
{ \
if (g_EnableDebugTrace) \
CCLogger::Get()->DebugLog(F(format, ##args)); \
} \
while (false)
#define TRACE2(format, args...) \
CCLogger::Get()->DebugLog(F(format, ##args))
#else
#define ADDTOKEN(format, args...)
#define TRACE(format, args...)
#define TRACE2(format, args...)
#endif
#endif
extern bool s_DebugSmartSense;
NativeParserTest::NativeParserTest( )
{
}
NativeParserTest::~NativeParserTest()
{
}
bool NativeParserTest::TestExpression(wxString& expression,
TokensTree * tree,
const TokenIdxSet& searchScope,
TokenIdxSet& result)
{
// find all other matches
std::queue<ParserComponent> components;
BreakUpComponents(expression, components);
ResolveExpression(tree, components, searchScope, result, true, false);
if (s_DebugSmartSense)
CCLogger::Get()->DebugLog(F(_T("NativeParserTest::TestExpression , returned %d results"),result.size()));
return true;
}
The test code is in my previous post, and I can see the final result:
...
000033. NativeParserTest::TestExpression , returned 1 results
000034. variable int A::m_Member1 [5,0]
...
EDIT:
I add the diff file, so it is test only patch.(Note, the diff file contains my other part of changes to CC, like adding some comments, re-direct the TRACE message to standard console, so I can still see these messages when the app hit a breakpoint.....)
The patch is generated by git, but I think using the patch command under msys, it can directly apply the change on a SVN trunk.
BTW: Maybe, some EOL should be changed after patching, because my git use Linux-style EOL.