@polygon7
I have write my suggestions here about How does CC can support Doxygen. ( I wrote it here, because I hope others can benefit too
)
Basically, When you caret are located here, before some functions:
*** Your caret position A***
void functionXXX ( )
{
*** Your caret position B***
...
}
If your location is B, then I think in Codecompletions source code, you can easily find the Token around B. See the source snippet:
int NativeParser::FindCurrentFunctionStart(cbEditor* editor, wxString* nameSpace, wxString* procName, int caretPos)
{
...
TokenIdxSet result;
size_t num_results = m_pParser->FindTokensInFile(editor->GetFilename(), result, tkFunction|tkConstructor|tkDestructor);
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(F(_T("FindCurrentFunctionStart() Found %d results"), num_results));
TokensTree* tree = m_pParser->GetTokens();
for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(_T("FindCurrentFunctionStart() (Next) Iteration..."));
Token* token = tree->at(*it);
if (token)
{
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(F(_T("FindCurrentFunctionStart() Iterating: tN='%s', tF='%s', tStart=%d, tEnd=%d"),
token->DisplayName().wx_str(), token->GetFilename().wx_str(), token->m_ImplLineStart, token->m_ImplLineEnd));
// found a matching function; check its bounds
if (token->m_ImplLineStart <= (size_t)line && token->m_ImplLineEnd >= (size_t)line)
{
// got it :)
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(F(_T("FindCurrentFunctionStart() Current function: '%s' (at line %d)"),
token->DisplayName().wx_str(),
token->m_ImplLine));
s_LastNS = token->GetNamespace();
s_LastPROC = token->m_Name;
s_LastResult = control->PositionFromLine(token->m_ImplLine - 1);
// locate function's opening brace
while (s_LastResult < control->GetTextLength())
{
wxChar ch = control->GetCharAt(s_LastResult);
if (ch == _T('{'))
break;
else if (ch == 0)
{
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(_T("FindCurrentFunctionStart() Can't determine functions opening brace..."));
return -1;
}
++s_LastResult;
}
if (nameSpace) *nameSpace = s_LastNS;
if (procName) *procName = s_LastPROC;
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(F(_T("FindCurrentFunctionStart() Namespace='%s', proc='%s' (returning %d)"),
s_LastNS.wx_str(), s_LastPROC.wx_str(), s_LastResult));
return s_LastResult;
}
else if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(F(_T("FindCurrentFunctionStart() Function out of bounds: tN='%s', tF='%s', tStart=%d, tEnd=%d, line=%d (size_t)line=%d"),
token->DisplayName().wx_str(), token->GetFilename().wx_str(), token->m_ImplLineStart, token->m_ImplLineEnd, line, (size_t)line));
}
}
if (s_DebugSmartSense)
Manager::Get()->GetLogManager()->DebugLog(_T("FindCurrentFunctionStart() Can't determine current function..."));
s_LastResult = -1;
return -1;
}
Note that all the Token information was in TokensTree, so, first, you need to get all the tokens belong to the current file, this is done by calling:
TokenIdxSet result;
size_t num_results = m_pParser->FindTokensInFile(editor->GetFilename(), result, tkFunction|tkConstructor|tkDestructor);
The last argument is a mask. If you want to other information, you can change the "mark".
Onec you get the result, you just do a loop on it and find which Token covers your current line.
Finally, you find some one, for my example, you will find the Token " void functionXXX ( ) ", so, you can do everything you like to do.
If you caret is located in position A, I think you can still do the loop in the result, and find the nearest token behind your current line.