Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
A bug in handling #define
blueshake:
new patch:
I just add a line compare here.because for codes:
--- Code: ---#define BOOST_ALIGNED_STORAGE_HPP
int main() {}
--- End code ---
when we do this,
--- Code: ---wxString para = m_Tokenizer.GetToken();
--- End code ---
at this time ,m_Tokenizer will return int ,then we do this
--- Code: ---m_Str << m_Tokenizer.ReadToEOL();
--- End code ---
it will eat the whole line codes
--- Code: ---int main()
--- End code ---
that is why the tokens number are lost.
BTW. @morten
can we print the whole project's tokens name to the file??so when we make patch,when the tokens numbers are wrong.we can use diff tool to check whick tokens are lost.
blueshake:
Another update.
remove the compile warning.
forget to do this in last patch.
--- Quote ---if (!m_Str.IsEmpty())
m_Str << _T(" ");
m_Str << m_Tokenizer.ReadToEOL();
--- End quote ---
--- Code: ---Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6169)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1123,8 +1123,8 @@
void ParserThread::HandleDefines()
{
- wxString filename;
- int lineNr = m_Tokenizer.GetLineNumber();
+ //wxString filename;
+ size_t lineNr = m_Tokenizer.GetLineNumber();
wxString token = m_Tokenizer.GetToken(); // read the token after #define
m_Str.Clear();
// now token holds something like:
@@ -1132,31 +1132,30 @@
if (!token.IsEmpty())
{
// skip the rest of the #define
- wxString defVal = token + m_Tokenizer.ReadToEOL();
- wxString para(_T(""));
- int start = defVal.Find('(');
- int end = defVal.Find(')');
-
+ wxString para = m_Tokenizer.GetToken();
TRACE(_T("HandleDefines() : Saving nesting level: %d,%d"), start, end);
-
- // make sure preprocessor definitions are not going under namespaces or classes!
- if (start != wxNOT_FOUND && end != wxNOT_FOUND)
+ if (lineNr == m_Tokenizer.GetLineNumber())
{
- para = defVal.Mid(start, end-start+1);
- m_Str = defVal.Mid(end + 1);
- m_Str.Trim(false);
+ if (para.IsEmpty() || para.GetChar(0) != '(') //check if contain the open brace
+ {
+ m_Str = para;
+ para = wxEmptyString;
+ }
+ if (!m_Str.IsEmpty())
+ m_Str << _T(" ");
+ m_Str << m_Tokenizer.ReadToEOL();
}
else
{
- m_Str = defVal.substr(token.length());
- m_Str.Trim(false);
- //defVal = _T("");
+ m_Tokenizer.UngetToken();
+ para = wxEmptyString;
+ m_Str << m_Tokenizer.ReadToEOL();
}
Token* oldParent = m_pLastParent;
m_pLastParent = 0L;
DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), para, false, true);
m_pLastParent = oldParent;
- m_Str.Clear();
+ //m_Str.Clear();
}
}
--- End code ---
MortenMacFly:
--- Quote from: blueshake on February 19, 2010, 04:16:12 am ---can we print the whole project's tokens name to the file??so when we make patch,when the tokens numbers are wrong.we can use diff tool to check whick tokens are lost. [/b]
--- End quote ---
Sure. Using the token debug window (CTRL + double-click on a token). There you'll find a save button that allows to save the file list as well as the whole token tree to a file. That's why I could tell you what's missing btw... ;-)
But be careful: Creating the token tree can take a long time! C::B seems frozen then but it's not. Just be patient.
MortenMacFly:
--- Quote from: blueshake on February 19, 2010, 04:16:12 am ---at this time ,m_Tokenizer will return int ,then we do this
--- Code: ---m_Str << m_Tokenizer.ReadToEOL();
--- End code ---
--- End quote ---
It depends on the settings of the Tokenizer (what to skip) IMHO.
Navigation
[0] Message Index
[*] Previous page
Go to full version