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;
}
}