Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Another completion oddity
blueshake:
yes .even down the cc-branch,you still apply the patch below.this one is different from the one above.
in current cc_branch.it can not work
you still need to apply this patch.
through I upload the patch. it seems dev still not apply it, it need time to test.
you can apply it, test too.
--- Code: ---Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5730)
+++ parserthread.cpp (working copy)
@@ -990,14 +990,30 @@
// BLAH_BLAH
if (!token.IsEmpty())
{
- // skip the rest of the #define
- wxString defVal = token + m_Tokenizer.ReadToEOL();
-
+ // skip the rest of the #define
+ wxString defVal = token + m_Tokenizer.ReadToEOL();
+ wxString para(_T(""));
+ size_t start = defVal.find('(');
+ size_t end = defVal.find(')');
+ //Manager::Get()->GetLogManager()->DebugLog(F(_T("Saving nesting level: %d,%d"), start, end));
// make sure preprocessor definitions are not going under namespaces or classes!
+ if (start != wxString::npos && end != wxString::npos)
+ {
+ para = defVal.Mid(start, end-start+1);
+ m_Str = defVal.Mid(end + 1);
+ m_Str.Trim(false);
+ }
+ else
+ {
+ m_Str = defVal.substr(token.length());
+ m_Str.Trim(false);
+ //defVal = _T("");
+ }
Token* oldParent = m_pLastParent;
m_pLastParent = 0L;
- DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), defVal, false, true);
+ DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), para, false, true);
m_pLastParent = oldParent;
+ m_Str.Clear();
}
}
@@ -1228,7 +1244,7 @@
{
static size_t num = 0;
wxString unnamedTmp;
- unnamedTmp.Printf(_T("Unnamed-%s-%d"),
+ unnamedTmp.Printf(_T("Unnamed%s%d"),
ct == ctClass ? _T("Class") :
ct == ctUnion ? _T("Union") :
_T("Struct"), num++);
@@ -1256,12 +1272,18 @@
// no vars are defined on a typedef, only types
// In the former example, aa is not part of the typedef.
if (m_ParsingTypedef)
+ {
+ m_Str.Clear();
+ ReadClsNames(newToken->m_Name);
break;
-
- m_Str = newToken->m_Name;
- ReadVarNames();
- m_Str.Clear();
- break;
+ }
+ else
+ {
+ m_Str = newToken->m_Name;
+ ReadVarNames();
+ m_Str.Clear();
+ break;
+ }
}
else if (next==ParserConsts::opbrace)
{
@@ -1295,12 +1317,18 @@
// no vars are defined on a typedef, only types
// In the former example, aa is not part of the typedef.
if (m_ParsingTypedef)
+ {
+ m_Str.Clear();
+ ReadClsNames(newToken->m_Name);
break;
-
- m_Str = newToken->m_Name;
- ReadVarNames();
- m_Str.Clear();
- break;
+ }
+ else
+ {
+ m_Str = newToken->m_Name;
+ ReadVarNames();
+ m_Str.Clear();
+ break;
+ }
}
else if (next==ParserConsts::semicolon) // forward decl; we don't care
break;
@@ -1345,6 +1373,8 @@
}
}
}
+ else
+ m_Tokenizer.GetToken();
}
else
break;
@@ -1460,7 +1490,7 @@
if (m_ParsingTypedef)
{
static size_t num = 0;
- token.Printf(_T("Unnamed-Enum-%d"), num++);
+ token.Printf(_T("UnnamedEnum%d"), num++);
m_LastUnnamedTokenName = token;
}
else
@@ -1707,15 +1737,60 @@
#if PARSER_DEBUG_OUTPUT
Manager::Get()->GetLogManager()->DebugLog(F(_("Adding typedef: name='%s', ancestor='%s'"), components.front().c_str(), ancestor.c_str()));
#endif
- Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
+// wxString str = components.front();
+ Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);
+//Token* tdef = DoAddToken(tkTypedef, str, lineNr, 0, 0, args);
+//if ( m_Filename == _T("F:\\fortest\\main.cpp"))
+// Manager::Get()->GetLogManager()->DebugLog(ancestor);
if (tdef)
{
if (!is_function_pointer)
{
tdef->m_AncestorsString = ancestor;
+
tdef->m_ActualType = ancestor;
+// if ( m_Filename == _T("F:\\fortest\\main.cpp"))
+// {
+// Manager::Get()->GetLogManager()->DebugLog(tdef->m_Name + _T(" ") + tdef->m_AncestorsString + tdef->m_ActualType);
+// }
}
else
+ {
tdef->m_ActualType = ancestor + args;
+// tdef->m_AncestorsString = str;
+ }
}
}
+void ParserThread::ReadClsNames(wxString& ancestor)
+{
+ while (1)
+ {
+ wxString current = m_Tokenizer.GetToken();
+
+ if (current.IsEmpty())
+ break;
+ if (current==ParserConsts::comma)
+ continue;
+ else if (current==ParserConsts::semicolon)
+ {
+ m_Tokenizer.UngetToken();
+ break;
+ }
+
+ else if (wxIsalpha(current.GetChar(0)))
+ {
+// Manager::Get()->GetLogManager()->DebugLog(F(_T("Adding variable '%s' as '%s' to '%s'"), current.c_str(), m_Str.c_str(), (m_pLastParent?m_pLastParent->m_Name.c_str():_T("<no-parent>"))));
+ Token* newToken = DoAddToken(tkClass, current, m_Tokenizer.GetLineNumber());
+ if (!newToken)
+ break;
+ else
+ {
+ wxString tempAncestor = ancestor;
+ newToken->m_AncestorsString = tempAncestor;
+ }
+
+ }
+ else // unexpected
+ break;
+ }
+}
Index: parserthread.h
===================================================================
--- parserthread.h (revision 5730)
+++ parserthread.h (working copy)
@@ -89,6 +89,7 @@
void HandlePreprocessorBlocks(const wxString& preproc);
void HandleNamespace();
void ReadVarNames();
+ void ReadClsNames(wxString& ancestor);
void HandleClass(EClassType ct);
void HandleFunction(const wxString& name, bool isOperator = false);
void HandleEnum();
--- End code ---
blueshake:
or you can download the attachment,and replace relative files.compile again.
i think it will work now.
[attachment deleted by admin]
daniloz:
Again thanks for the prompt reply and files... I'm compiling it... ;)
daniloz:
I confirm it's working here as well... thanks !!!!!
mariocup:
Hi blueshake,
the code completion works well with your patch. In the following example the struct Data show the code completion but in the symbol browser it appears as unnamed struct. Any idea how to fix this?
--- Code: ---typedef struct {
int xyz;
int abc;
} Data_t;
Data_t Data;
int main (void)
{
Data.
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version