Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 5824)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -427,71 +427,79 @@
delete [] Compilers;
} // end of AddCompilerDirs
+
+
wxArrayString NativeParser::GetGCCCompilerDirs(const wxString &cpp_compiler, const wxString &base)
{
wxArrayString gcc_compiler_dirs;
// for starters , only do this for gnu compiler
-// Manager::Get()->GetLogManager()->DebugLog(_T("CompilerID ") + CompilerID);
- // wxString Command("mingw32-g++ -v -E -x c++ - < nul");
- // specifying "< nul", does not seem to work
- // workaround : create a dummy file (let's hope it does not exist)
+ //Manager::Get()->GetLogManager()->DebugLog(_T("CompilerID ") + CompilerID);
+ //
+ // windows: mingw32-g++ -v -E -x c++ nul
+ // linux : g++ -v -E -x c++ /dev/null
// do the trick only for c++, not needed then for C (since this is a subset of C++)
- wxString DummyFileName = wxFileName::CreateTempFileName(_T("Dummy_z4hsdkl9nf7ba3L9nv41"));
- if(!DummyFileName.IsEmpty())
+
+
+ // let's construct the command
+ // use a null file handler
+ // both works fine in Windows and linux
+
+#ifdef __WXMSW__
+ wxString Command = cpp_compiler + _T(" -v -E -x c++ nul");
+#else
+ wxString Command = cpp_compiler + _T(" -v -E -x c++ /dev/null");
+#endif
+
+ // action time (everything shows up on the error stream
+ wxArrayString Output, Errors;
+ wxExecute(Command, Output, Errors, wxEXEC_NODISABLE);
+ int nCount = Errors.GetCount();
+ // the include dir (1 per line) show up between the lines
+ // #include <...> search starts here:
+ // End of search list
+ // let's hope this does not change too quickly, otherwise we need
+ // to adjust our search code (for several versions ...)
+ bool bStart = false;
+ for(int idxCount = 0; idxCount < nCount; ++idxCount)
{
- // let's construct the command
- wxString Command = cpp_compiler + _T(" -v -E -x c++ ") + DummyFileName;
- // action time (everything shows up on the error stream
- wxArrayString Output, Errors;
- wxExecute(Command, Output, Errors, wxEXEC_NODISABLE);
- int nCount = Errors.GetCount();
- // the include dir (1 per line) show up between the lines
- // #include <...> search starts here:
- // End of search list
- // let's hope this does not change too quickly, otherwise we need
- // to adjust our search code (for several versions ...)
- bool bStart = false;
- for(int idxCount = 0; idxCount < nCount; ++idxCount)
+ if (!bStart && Errors[idxCount] == _("#include <...> search starts here:"))
{
- if (!bStart && Errors[idxCount] == _("#include <...> search starts here:"))
+ bStart = true;
+ }
+ else if (bStart && Errors[idxCount] == _("End of search list."))
+ {
+ bStart = false; // could jump out of for loop if we want
+ }
+ else if (bStart)
+ {
+// Manager::Get()->GetLogManager()->DebugLog("include dir " + Errors[idxCount]);
+ // get rid of the leading space (more general : any whitespace)in front
+ wxRegEx reg(_T("^[ \t]*(.*)"));
+ if(reg.Matches(Errors[idxCount]))
{
- bStart = true;
- }
- else if (bStart && Errors[idxCount] == _("End of search list."))
- {
- bStart = false; // could jump out of for loop if we want
- }
- else if (bStart)
- {
-// Manager::Get()->GetLogManager()->DebugLog("include dir " + Errors[idxCount]);
- // get rid of the leading space (more general : any whitespace)in front
- wxRegEx reg(_T("^[ \t]*(.*)"));
- if(reg.Matches(Errors[idxCount]))
+ wxString out = reg.GetMatch(Errors[idxCount], 1);
+ if(!out.IsEmpty())
{
- wxString out = reg.GetMatch(Errors[idxCount], 1);
- if(!out.IsEmpty())
+ wxFileName dir(out);
+ if (NormalizePath(dir,base))
{
- wxFileName dir(out);
- if (NormalizePath(dir,base))
- {
- Manager::Get()->GetLogManager()->DebugLog(_T("Caching GCC dir: ") + dir.GetFullPath());
- gcc_compiler_dirs.Add(dir.GetFullPath());
- }
- else
- #if wxCHECK_VERSION(2, 9, 0)
- Manager::Get()->GetLogManager()->DebugLog(F(_T("Error normalizing path: '%s' from '%s'"),out.wx_str(),base.wx_str()));
- #else
- Manager::Get()->GetLogManager()->DebugLog(F(_T("Error normalizing path: '%s' from '%s'"),out.c_str(),base.c_str()));
- #endif
+ Manager::Get()->GetLogManager()->DebugLog(_T("Caching GCC dir: ") + dir.GetFullPath());
+ gcc_compiler_dirs.Add(dir.GetFullPath());
}
+ else
+ #if wxCHECK_VERSION(2, 9, 0)
+ Manager::Get()->GetLogManager()->DebugLog(F(_T("Error normalizing path: '%s' from '%s'"),out.wx_str(),base.wx_str()));
+ #else
+ Manager::Get()->GetLogManager()->DebugLog(F(_T("Error normalizing path: '%s' from '%s'"),out.c_str(),base.c_str()));
+ #endif
}
}
- } // end for : idx : idxCount
- // clean up our temp file
- ::wxRemoveFile(DummyFileName);
- } // Dummy is open
+ }
+ } // end for : idx : idxCount
+
+
return gcc_compiler_dirs;
}
@@ -1209,11 +1217,16 @@
#endif
{
case ']':
- case ')': ++nest; break;
+ case ')': ++nest; --x;break;
case '[':
- case '(': --nest; break;
+ case '(': --nest; --x;break;
+
}
+ while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
+ --x;
+ if ((x >= 0) && (line.GetChar(x) == ')' || line.GetChar(x) == ']'))
+ ++nest;
}
if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
--x;
@@ -1268,7 +1281,7 @@
is_function = line.GetChar(startAt) == '(';
++nest;
- while (startAt < line.Length() - 1 && nest != 0)
+ while (startAt < line.Length()-1 && nest != 0)
{
++startAt;
#if wxCHECK_VERSION(2, 9, 0)
@@ -1278,13 +1291,18 @@
#endif
{
case ']':
- case ')': --nest; break;
+ case ')': --nest; ++startAt;break;
case '[':
- case '(': ++nest; break;
+ case '(': ++nest; ++startAt;break;
}
+ while (startAt < line.Length()-1&& (line.GetChar(startAt) == ' ' || line.GetChar(startAt) == '\t'))
+ ++startAt;
+ if (startAt < line.Length()-1 && (line.GetChar(startAt) == '(' || line.GetChar(startAt) == '['))
+ ++nest;
}
- ++startAt;
+ //++startAt;
+
}
//Manager::Get()->GetLogManager()->DebugLog("Return at %d (%c): res=%s", startAt, line.GetChar(startAt), res.c_str());
@@ -1412,6 +1430,8 @@
static wxString cached_search;
static size_t cached_results_count = 0;
+
+
// early-out opportunity
// if the user starts typing a token that in our last search had 0 results,
// and we see that he's continuing typing for that same token,
@@ -1522,6 +1542,7 @@
}
cached_editor = editor;
+ if (result.size() || (m_EditorEndWord - m_EditorStartWord))
cached_editor_start_word = m_EditorStartWord;
cached_search = actual;
cached_results_count = result.size();
Note: this patch, the first part was using a null file to get the GCC include path(this avoid creating a dummy file)
I'd like you test it and comments are welcome! thanks.