Won't this continually drive CPU usage as the user types given that you are forcing a reparse on the wxSCI_MOD_INSERTTEXT and wxSCI_MOD_DELETETEXT events?
Index: src/include/filemanager.h
===================================================================
--- src/include/filemanager.h (revision 5951)
+++ src/include/filemanager.h (working copy)
@@ -144,7 +144,19 @@
NullLoader(const wxString& name, char* buffer, size_t size) { fileName = name; data = buffer; len = size; Ready(); };
void operator()(){};
};
-
+class EditorReuser : public LoaderBase
+{
+public:
+ EditorReuser(const wxString& name, const wxString& s)
+ {
+ fileName = name;
+ len = strlen(s.mb_str(wxConvUTF8));
+ data = new char[len + 1];
+ strcpy(data, (const char*)s.mb_str(wxConvUTF8));
+ Ready();
+ }
+ void operator()(){};
+};
// ***** class: FileManager *****
class FileManager : public Mgr<FileManager>
{
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 5951)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -172,7 +172,8 @@
m_IsAutoPopup(false),
m_ToolbarChanged(true),
m_CurrentLine(0),
- m_LastFile(wxEmptyString)
+ m_LastFile(wxEmptyString),
+ m_NeedReparse(false)
{
if(!Manager::LoadResource(_T("codecompletion.zip")))
{
@@ -2069,7 +2070,11 @@
}
}
}
-
+ if ((event.GetModificationType() & wxSCI_MOD_INSERTTEXT) ||
+ (event.GetModificationType() & wxSCI_MOD_DELETETEXT))
+ {
+ m_NeedReparse = true;
+ }
if( control->GetCurrentLine() != m_CurrentLine)
{
m_CurrentLine = control->GetCurrentLine();
@@ -2093,6 +2098,16 @@
m_Scope->SetSelection(wxNOT_FOUND);
}
}
+ if (m_NeedReparse)
+ {
+ Parser* parser = m_NativeParser.FindParserFromActiveEditor();
+ if (parser)
+ {
+ parser->Reparse(editor->GetFilename());
+ }
+ m_NeedReparse= false;
+ }
+
}
// allow others to handle this event
Index: src/plugins/codecompletion/codecompletion.h
===================================================================
--- src/plugins/codecompletion/codecompletion.h (revision 5951)
+++ src/plugins/codecompletion/codecompletion.h (working copy)
@@ -146,7 +146,7 @@
int m_CurrentLine;
map<wxString, int> m_SearchItem;
wxString m_LastFile;
-
+ bool m_NeedReparse;
bool m_LexerKeywordsToInclude[9];
DECLARE_EVENT_TABLE()
Index: src/plugins/codecompletion/parser/parser.cpp
===================================================================
--- src/plugins/codecompletion/parser/parser.cpp (revision 5951)
+++ src/plugins/codecompletion/parser/parser.cpp (working copy)
@@ -538,7 +538,7 @@
}
if (!opts.loader) //this should always be true (memory will leak if a loader has already been initialized before this point)
- opts.loader = Manager::Get()->GetFileManager()->Load(bufferOrFilename, false);
+ opts.loader = Manager::Get()->GetFileManager()->Load(bufferOrFilename, true);
}
#if PARSER_DEBUG_OUTPUT
Index: src/sdk/filemanager.cpp
===================================================================
--- src/sdk/filemanager.cpp (revision 5951)
+++ src/sdk/filemanager.cpp (working copy)
@@ -138,12 +138,8 @@
cbEditor* ed = em->GetBuiltinEditor(em->GetEditor(i));
if(ed && fileName == ed->GetFilename())
{
- wxString s(ed->GetControl()->GetText());
- #if wxCHECK_VERSION(2, 9, 0)
- NullLoader *nl = new NullLoader(file, (char*) s.wx_str(), s.length() * sizeof(wxChar));
- #else
- NullLoader *nl = new NullLoader(file, (char*) s.c_str(), s.length() * sizeof(wxChar));
- #endif
+
+ EditorReuser *nl = new EditorReuser(file, ed->GetControl()->GetText());
return nl;
}
}
Index: src/include/filemanager.h
===================================================================
--- src/include/filemanager.h (revision 5973)
+++ src/include/filemanager.h (working copy)
@@ -144,7 +144,19 @@
NullLoader(const wxString& name, char* buffer, size_t size) { fileName = name; data = buffer; len = size; Ready(); };
void operator()(){};
};
-
+class EditorReuser : public LoaderBase
+{
+public:
+ EditorReuser(const wxString& name, const wxString& s)
+ {
+ fileName = name;
+ len = strlen(s.mb_str(wxConvUTF8));
+ data = new char[len + 1];
+ strcpy(data, (const char*)s.mb_str(wxConvUTF8));
+ Ready();
+ }
+ void operator()(){};
+};
// ***** class: FileManager *****
class FileManager : public Mgr<FileManager>
{
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 5973)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -172,7 +172,8 @@
m_IsAutoPopup(false),
m_ToolbarChanged(true),
m_CurrentLine(0),
- m_LastFile(wxEmptyString)
+ m_LastFile(wxEmptyString),
+ m_NeedReparse(false)
{
if(!Manager::LoadResource(_T("codecompletion.zip")))
{
@@ -2069,7 +2070,11 @@
}
}
}
-
+ if ((event.GetModificationType() & wxSCI_MOD_INSERTTEXT) ||
+ (event.GetModificationType() & wxSCI_MOD_DELETETEXT))
+ {
+ m_NeedReparse = true;
+ }
if( control->GetCurrentLine() != m_CurrentLine)
{
m_CurrentLine = control->GetCurrentLine();
@@ -2093,6 +2098,16 @@
m_Scope->SetSelection(wxNOT_FOUND);
}
}
+ if (m_NeedReparse)
+ {
+ Parser* parser = m_NativeParser.FindParserFromActiveEditor();
+ if (parser)
+ {
+ parser->Reparse(editor->GetFilename());
+ }
+ m_NeedReparse= false;
+ }
+
}
// allow others to handle this event
Index: src/plugins/codecompletion/codecompletion.h
===================================================================
--- src/plugins/codecompletion/codecompletion.h (revision 5973)
+++ src/plugins/codecompletion/codecompletion.h (working copy)
@@ -146,7 +146,7 @@
int m_CurrentLine;
map<wxString, int> m_SearchItem;
wxString m_LastFile;
-
+ bool m_NeedReparse;
bool m_LexerKeywordsToInclude[9];
DECLARE_EVENT_TABLE()
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 5973)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -2152,18 +2152,13 @@
}
s_LastEditor = editor;
s_LastLine = line;
-
- Parser parser(this);
- parser.ParseBufferForFunctions(control->GetTextRange(0, pos));
-
- wxArrayString funcs;
- TokensTree* tmptree = parser.GetTempTokens();
-
- // look for implementation functions that enclose our current line number
- for(size_t i = 0; i < tmptree->size();i++)
+ TokenIdxSet result;
+ m_Parser.FindTokensInFile(editor->GetFilename(), result, tkFunction|tkConstructor|tkDestructor);
+ TokensTree* tree = m_Parser.GetTokens();
+ for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
- Token* token = tmptree->at(i);
- if (token && (token->m_TokenKind == tkFunction || token->m_TokenKind == tkConstructor || token->m_TokenKind == tkDestructor))
+ Token* token = tree->at(*it);
+ if (token)
{
// found a function; check its bounds
if (token->m_ImplLineStart <= (size_t)line && token->m_ImplLineEnd >= (size_t)line)
@@ -2174,6 +2169,7 @@
token->DisplayName().wx_str(),
token->m_ImplLine));
+
s_LastNS = token->GetNamespace();
s_LastPROC = token->m_Name;
s_LastResult = control->PositionFromLine(token->m_ImplLine - 1);
Index: src/plugins/codecompletion/parser/parser.cpp
===================================================================
--- src/plugins/codecompletion/parser/parser.cpp (revision 5973)
+++ src/plugins/codecompletion/parser/parser.cpp (working copy)
@@ -538,7 +538,7 @@
}
if (!opts.loader) //this should always be true (memory will leak if a loader has already been initialized before this point)
- opts.loader = Manager::Get()->GetFileManager()->Load(bufferOrFilename, false);
+ opts.loader = Manager::Get()->GetFileManager()->Load(bufferOrFilename, true);
}
#if PARSER_DEBUG_OUTPUT
@@ -1045,3 +1045,22 @@
}
return true;
}
+size_t Parser::FindTokensInFile(const wxString& fileName,TokenIdxSet& result,short int kindMask)
+{
+ result.clear();
+ wxString file = UnixFilename(fileName);
+ TokenIdxSet tmpresult;
+ wxCriticalSectionLocker lock(s_MutexProtection);
+ if(!m_pTokens->FindTokensInFile(file,tmpresult,kindMask))
+ return 0;
+
+ TokenIdxSet::iterator it;
+ for(it = tmpresult.begin();it!=tmpresult.end();++it)
+ {
+ Token* token = m_pTokens->at(*it);
+ if(token)
+ //result.push_back(token);
+ result.insert(*it);
+ }
+ return result.size();
+}
Index: src/plugins/codecompletion/parser/parser.h
===================================================================
--- src/plugins/codecompletion/parser/parser.h (revision 5973)
+++ src/plugins/codecompletion/parser/parser.h (working copy)
@@ -153,6 +153,7 @@
Token* FindChildTokenByName(Token* parent, const wxString& name, bool useInheritance = false, short int kindMask = 0xFFFF) const;
size_t FindMatches(const wxString& s, TokenList& result, bool caseSensitive = true, bool is_prefix = true);
size_t FindMatches(const wxString& s, TokenIdxSet& result, bool caseSensitive = true, bool is_prefix = true);
+ size_t FindTokensInFile(const wxString& fileName, TokenIdxSet& result, short int kindMask);
ParserOptions& Options() { return m_Options; }
BrowserOptions& ClassBrowserOptions() { return m_BrowserOptions; }
Index: src/sdk/filemanager.cpp
===================================================================
--- src/sdk/filemanager.cpp (revision 5973)
+++ src/sdk/filemanager.cpp (working copy)
@@ -138,12 +138,8 @@
cbEditor* ed = em->GetBuiltinEditor(em->GetEditor(i));
if(ed && fileName == ed->GetFilename())
{
- wxString s(ed->GetControl()->GetText());
- #if wxCHECK_VERSION(2, 9, 0)
- NullLoader *nl = new NullLoader(file, (char*) s.wx_str(), s.length() * sizeof(wxChar));
- #else
- NullLoader *nl = new NullLoader(file, (char*) s.c_str(), s.length() * sizeof(wxChar));
- #endif
+
+ EditorReuser *nl = new EditorReuser(file, ed->GetControl()->GetText());
return nl;
}
}
if (result.size()<1) // found nothing in the search_scope, add global namespace
{
if (s_DebugSmartSense)
{
Manager::Get()->GetLogManager()->DebugLog(F(_T("AI() result is zero, so, add the Global namespace")));
}
search_scope->insert(-1);
FindAIMatches(parser, components, result, -1, noPartialMatch, caseSensitive, true, 0xffff, search_scope);
}
But this bug CC fail after A class's static method called. (http://forums.codeblocks.org/index.php/topic,11677.msg79385.html#msg79385) still exist. :(
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 5986)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -1410,16 +1410,23 @@
funcdata->m_NameSpaces.clear();
funcdata->parsed = true;
- Parser parser(this);
+ /*Parser parser(this);
TokensTree* tmptree = parser.GetTempTokens();
tmptree->clear();
parser.ParseBufferForFunctions(ed->GetControl()->GetText());
for(size_t i = 0; i < tmptree->size(); ++i)
+ */
+ Parser* parser = m_NativeParser.FindParserFromEditor(ed);
+ if (!parser)
+ return;
+ TokenIdxSet result;
+ TokensTree* tmptree = parser->GetTokens();
+ parser->FindTokensInFile(filename, result, tkFunction|tkConstructor|tkDestructor);
+ for (TokenIdxSet::iterator it =result.begin(); it != result.end(); ++it)
{
- const Token* token = tmptree->at(i);
- if (token && (token->m_TokenKind == tkFunction || token->m_TokenKind == tkConstructor || token->m_TokenKind == tkDestructor)
- && token->m_ImplLine != 0)
+ const Token* token = tmptree->at(*it);
+ if (token && token->m_ImplLine != 0)//&& (token->m_TokenKind == tkFunction || token->m_TokenKind == tkConstructor || token->m_TokenKind == tkDestructor)
{
FunctionScope func;
func.StartLine = token->m_ImplLine - 1;
@@ -2077,28 +2084,6 @@
}
if( control->GetCurrentLine() != m_CurrentLine)
{
- m_CurrentLine = control->GetCurrentLine();
- int sel = FunctionPosition();
- if(sel != -1 && sel != m_Function->GetSelection())
- {
- m_Function->SetSelection(sel);
- m_Scope->SetSelection(sel);
- }
- else if(sel == -1)
- {
- m_Function->SetSelection(wxNOT_FOUND);
- // TO DO : set scope correctly
- int NsSel = NameSpacePosition();
- if(NsSel != -1)
- {
- m_Scope->SetSelection(NsSel + m_StartIdxNameSpaceInScope);
- }
- else
- {
- m_Scope->SetSelection(wxNOT_FOUND);
- }
- }
-
if (m_NeedReparse)
{
Parser* parser = m_NativeParser.FindParserFromActiveEditor();
@@ -2107,7 +2092,32 @@
parser->Reparse(editor->GetFilename());
}
m_NeedReparse= false;
+ //m_CurrentLine = control->GetCurrentLine();
}
+ else
+ {
+ m_CurrentLine = control->GetCurrentLine();
+ int sel = FunctionPosition();
+ if(sel != -1 && sel != m_Function->GetSelection())
+ {
+ m_Function->SetSelection(sel);
+ m_Scope->SetSelection(sel);
+ }
+ else if(sel == -1)
+ {
+ m_Function->SetSelection(wxNOT_FOUND);
+ // TO DO : set scope correctly
+ int NsSel = NameSpacePosition();
+ if(NsSel != -1)
+ {
+ m_Scope->SetSelection(NsSel + m_StartIdxNameSpaceInScope);
+ }
+ else
+ {
+ m_Scope->SetSelection(wxNOT_FOUND);
+ }
+ }
+ }
}
// allow others to handle this event
@@ -2133,4 +2143,5 @@
void CodeCompletion::OnParserEnd(wxCommandEvent& event)
{
// nothing for now
+ ParseFunctionsAndFillToolbar(true);
}
optimize the cc search process based on real-time parse.This is certainly the cause for the wrong file being returned which I've reported here:
[...]CodeIndex: src/include/filemanager.h
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 5973)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -2152,18 +2152,13 @@
}
s_LastEditor = editor;
s_LastLine = line;
-
- Parser parser(this);
- parser.ParseBufferForFunctions(control->GetTextRange(0, pos));
-
- wxArrayString funcs;
- TokensTree* tmptree = parser.GetTempTokens();
-
- // look for implementation functions that enclose our current line number
- for(size_t i = 0; i < tmptree->size();i++)
+ TokenIdxSet result;
+ m_Parser.FindTokensInFile(editor->GetFilename(), result, tkFunction|tkConstructor|tkDestructor);
+ TokensTree* tree = m_Parser.GetTokens();
+ for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
- Token* token = tmptree->at(i);
- if (token && (token->m_TokenKind == tkFunction || token->m_TokenKind == tkConstructor || token->m_TokenKind == tkDestructor))
+ Token* token = tree->at(*it);
+ if (token)
{
// found a function; check its bounds
if (token->m_ImplLineStart <= (size_t)line && token->m_ImplLineEnd >= (size_t)line)
@@ -2174,6 +2169,7 @@
token->DisplayName().wx_str(),
token->m_ImplLine));
+
s_LastNS = token->GetNamespace();
s_LastPROC = token->m_Name;
s_LastResult = control->PositionFromLine(token->m_ImplLine - 1);
optimize the cc search process based on real-time parse.
before:
parse the contexts between the begin and the caret position to get the function tokens.
now
get the function tokens from the tokentree with filename directly based on real-time parse.and this reduce the parse time.
enjoy it. :D
patch:CodeIndex: src/include/filemanager.h
===================================================================
--- src/include/filemanager.h (revision 5973)
+++ src/include/filemanager.h (working copy)
@@ -144,7 +144,19 @@
NullLoader(const wxString& name, char* buffer, size_t size) { fileName = name; data = buffer; len = size; Ready(); };
void operator()(){};
};
-
+class EditorReuser : public LoaderBase
+{
+public:
+ EditorReuser(const wxString& name, const wxString& s)
+ {
+ fileName = name;
+ len = strlen(s.mb_str(wxConvUTF8));
+ data = new char[len + 1];
+ strcpy(data, (const char*)s.mb_str(wxConvUTF8));
+ Ready();
+ }
+ void operator()(){};
+};
// ***** class: FileManager *****
class FileManager : public Mgr<FileManager>
{
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 5973)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -172,7 +172,8 @@
m_IsAutoPopup(false),
m_ToolbarChanged(true),
m_CurrentLine(0),
- m_LastFile(wxEmptyString)
+ m_LastFile(wxEmptyString),
+ m_NeedReparse(false)
{
if(!Manager::LoadResource(_T("codecompletion.zip")))
{
@@ -2069,7 +2070,11 @@
}
}
}
-
+ if ((event.GetModificationType() & wxSCI_MOD_INSERTTEXT) ||
+ (event.GetModificationType() & wxSCI_MOD_DELETETEXT))
+ {
+ m_NeedReparse = true;
+ }
if( control->GetCurrentLine() != m_CurrentLine)
{
m_CurrentLine = control->GetCurrentLine();
@@ -2093,6 +2098,16 @@
m_Scope->SetSelection(wxNOT_FOUND);
}
}
+ if (m_NeedReparse)
+ {
+ Parser* parser = m_NativeParser.FindParserFromActiveEditor();
+ if (parser)
+ {
+ parser->Reparse(editor->GetFilename());
+ }
+ m_NeedReparse= false;
+ }
+
}
// allow others to handle this event
Index: src/plugins/codecompletion/codecompletion.h
===================================================================
--- src/plugins/codecompletion/codecompletion.h (revision 5973)
+++ src/plugins/codecompletion/codecompletion.h (working copy)
@@ -146,7 +146,7 @@
int m_CurrentLine;
map<wxString, int> m_SearchItem;
wxString m_LastFile;
-
+ bool m_NeedReparse;
bool m_LexerKeywordsToInclude[9];
DECLARE_EVENT_TABLE()
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 5973)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -2152,18 +2152,13 @@
}
s_LastEditor = editor;
s_LastLine = line;
-
- Parser parser(this);
- parser.ParseBufferForFunctions(control->GetTextRange(0, pos));
-
- wxArrayString funcs;
- TokensTree* tmptree = parser.GetTempTokens();
-
- // look for implementation functions that enclose our current line number
- for(size_t i = 0; i < tmptree->size();i++)
+ TokenIdxSet result;
+ m_Parser.FindTokensInFile(editor->GetFilename(), result, tkFunction|tkConstructor|tkDestructor);
+ TokensTree* tree = m_Parser.GetTokens();
+ for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
- Token* token = tmptree->at(i);
- if (token && (token->m_TokenKind == tkFunction || token->m_TokenKind == tkConstructor || token->m_TokenKind == tkDestructor))
+ Token* token = tree->at(*it);
+ if (token)
{
// found a function; check its bounds
if (token->m_ImplLineStart <= (size_t)line && token->m_ImplLineEnd >= (size_t)line)
@@ -2174,6 +2169,7 @@
token->DisplayName().wx_str(),
token->m_ImplLine));
+
s_LastNS = token->GetNamespace();
s_LastPROC = token->m_Name;
s_LastResult = control->PositionFromLine(token->m_ImplLine - 1);
Index: src/plugins/codecompletion/parser/parser.cpp
===================================================================
--- src/plugins/codecompletion/parser/parser.cpp (revision 5973)
+++ src/plugins/codecompletion/parser/parser.cpp (working copy)
@@ -538,7 +538,7 @@
}
if (!opts.loader) //this should always be true (memory will leak if a loader has already been initialized before this point)
- opts.loader = Manager::Get()->GetFileManager()->Load(bufferOrFilename, false);
+ opts.loader = Manager::Get()->GetFileManager()->Load(bufferOrFilename, true);
}
#if PARSER_DEBUG_OUTPUT
@@ -1045,3 +1045,22 @@
}
return true;
}
+size_t Parser::FindTokensInFile(const wxString& fileName,TokenIdxSet& result,short int kindMask)
+{
+ result.clear();
+ wxString file = UnixFilename(fileName);
+ TokenIdxSet tmpresult;
+ wxCriticalSectionLocker lock(s_MutexProtection);
+ if(!m_pTokens->FindTokensInFile(file,tmpresult,kindMask))
+ return 0;
+
+ TokenIdxSet::iterator it;
+ for(it = tmpresult.begin();it!=tmpresult.end();++it)
+ {
+ Token* token = m_pTokens->at(*it);
+ if(token)
+ //result.push_back(token);
+ result.insert(*it);
+ }
+ return result.size();
+}
Index: src/plugins/codecompletion/parser/parser.h
===================================================================
--- src/plugins/codecompletion/parser/parser.h (revision 5973)
+++ src/plugins/codecompletion/parser/parser.h (working copy)
@@ -153,6 +153,7 @@
Token* FindChildTokenByName(Token* parent, const wxString& name, bool useInheritance = false, short int kindMask = 0xFFFF) const;
size_t FindMatches(const wxString& s, TokenList& result, bool caseSensitive = true, bool is_prefix = true);
size_t FindMatches(const wxString& s, TokenIdxSet& result, bool caseSensitive = true, bool is_prefix = true);
+ size_t FindTokensInFile(const wxString& fileName, TokenIdxSet& result, short int kindMask);
ParserOptions& Options() { return m_Options; }
BrowserOptions& ClassBrowserOptions() { return m_BrowserOptions; }
Index: src/sdk/filemanager.cpp
===================================================================
--- src/sdk/filemanager.cpp (revision 5973)
+++ src/sdk/filemanager.cpp (working copy)
@@ -138,12 +138,8 @@
cbEditor* ed = em->GetBuiltinEditor(em->GetEditor(i));
if(ed && fileName == ed->GetFilename())
{
- wxString s(ed->GetControl()->GetText());
- #if wxCHECK_VERSION(2, 9, 0)
- NullLoader *nl = new NullLoader(file, (char*) s.wx_str(), s.length() * sizeof(wxChar));
- #else
- NullLoader *nl = new NullLoader(file, (char*) s.c_str(), s.length() * sizeof(wxChar));
- #endif
+
+ EditorReuser *nl = new EditorReuser(file, ed->GetControl()->GetText());
return nl;
}
}
optimize the cc search process based on real-time parse.This is certainly the cause for the wrong file being returned which I've reported here:
[...]CodeIndex: src/include/filemanager.h
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 5973)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -2152,18 +2152,13 @@
}
s_LastEditor = editor;
s_LastLine = line;
-
- Parser parser(this);
- parser.ParseBufferForFunctions(control->GetTextRange(0, pos));
-
- wxArrayString funcs;
- TokensTree* tmptree = parser.GetTempTokens();
-
- // look for implementation functions that enclose our current line number
- for(size_t i = 0; i < tmptree->size();i++)
+ TokenIdxSet result;
+ m_Parser.FindTokensInFile(editor->GetFilename(), result, tkFunction|tkConstructor|tkDestructor);
+ TokensTree* tree = m_Parser.GetTokens();
+ for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
- Token* token = tmptree->at(i);
- if (token && (token->m_TokenKind == tkFunction || token->m_TokenKind == tkConstructor || token->m_TokenKind == tkDestructor))
+ Token* token = tree->at(*it);
+ if (token)
{
// found a function; check its bounds
if (token->m_ImplLineStart <= (size_t)line && token->m_ImplLineEnd >= (size_t)line)
@@ -2174,6 +2169,7 @@
token->DisplayName().wx_str(),
token->m_ImplLine));
+
s_LastNS = token->GetNamespace();
s_LastPROC = token->m_Name;
s_LastResult = control->PositionFromLine(token->m_ImplLine - 1);
http://forums.codeblocks.org/index.php/topic,11800.msg80076.html#msg80076
Look: Previously the parser was created based on the native parsers current state. Now you just use the attached parser which maybe wrong because it may point to the wrong file!
I believe something like FindParserFromEditor needs to be used here...
I check out the FindParserFromEditor.It just simply return the m_Parser.You are right. What a messy code that was... From the early stages where there were several parsers per project. I've cleaned it up thoroughly and committed.