summaryrefslogtreecommitdiff
path: root/sdk/codelite_indexer
diff options
context:
space:
mode:
authorAlessio Treglia <alessio@debian.org>2010-07-29 14:07:51 +0200
committerAlessio Treglia <alessio@debian.org>2010-07-29 14:07:51 +0200
commit3aaf99776a19410a065e341fa5ffd35aa26f8b9a (patch)
treef4f25d175c172e6c309e3feac13aae49f6cb38d5 /sdk/codelite_indexer
parentbd7ae7fd2a68eeb7067bd7e4edf978a78ed231ba (diff)
Imported Upstream version 2.6.0.4189~dfsg
Diffstat (limited to 'sdk/codelite_indexer')
-rw-r--r--sdk/codelite_indexer/codelite_indexer.project10
-rw-r--r--sdk/codelite_indexer/indexer_client/main.cpp17
-rw-r--r--sdk/codelite_indexer/libctags/c.c31
-rw-r--r--sdk/codelite_indexer/libctags/read.c16
-rw-r--r--sdk/codelite_indexer/utils.cpp117
-rw-r--r--sdk/codelite_indexer/utils.h39
6 files changed, 95 insertions, 135 deletions
diff --git a/sdk/codelite_indexer/codelite_indexer.project b/sdk/codelite_indexer/codelite_indexer.project
index 7841893f..e3d8472b 100644
--- a/sdk/codelite_indexer/codelite_indexer.project
+++ b/sdk/codelite_indexer/codelite_indexer.project
@@ -121,6 +121,7 @@
<Dependencies Name="Debug_Unix"/>
<Dependencies Name="Release_Unix"/>
<Dependencies Name="Debug_Win"/>
+ <Dependencies Name="Release_Win"/>
<Settings Type="Executable">
<Configuration Name="Debug_Unix" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
<Compiler Options="-g" Required="yes" PreCompiledHeader="">
@@ -153,13 +154,13 @@
</AdditionalRules>
</Configuration>
<Configuration Name="Debug_Win" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
- <Compiler Options="-g;-Wall" Required="yes" PreCompiledHeader="">
+ <Compiler Options="-g;-Wall;$(shell wx-config --cflags --debug=yes)" Required="yes" PreCompiledHeader="">
<IncludePath Value="."/>
<IncludePath Value="libctags/"/>
<Preprocessor Value="__WXMSW__"/>
<Preprocessor Value="__DEBUG"/>
</Compiler>
- <Linker Options="" Required="yes"/>
+ <Linker Options="$(shell wx-config --libs --debug=yes)" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="eran" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
@@ -216,12 +217,12 @@
</AdditionalRules>
</Configuration>
<Configuration Name="Release_Win" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
- <Compiler Options="-O2;-Wall;-s" Required="yes" PreCompiledHeader="">
+ <Compiler Options="-O2;-Wall;-s;$(shell wx-config --cflags --unicode)" Required="yes" PreCompiledHeader="">
<IncludePath Value="."/>
<IncludePath Value="libctags/"/>
<Preprocessor Value="__WXMSW__"/>
</Compiler>
- <Linker Options="-O2;-s" Required="yes"/>
+ <Linker Options="-O2;-s;$(shell wx-config --libs --unicode)" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="./Release/codelite_indexer" IntermediateDirectory="./Release" Command="C:\Development\C++\codelite\CL_trunk\sdk\codelite_indexer\Release\$(ProjectName)" CommandArguments="--batch C:/Development/C++/linux-source-2.6.31/cscope_file.list" WorkingDirectory="C:/Development/C++/linux-source-2.6.31/" PauseExecWhenProcTerminates="yes"/>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
@@ -257,5 +258,4 @@
<ResourceCompiler Options=""/>
</GlobalSettings>
</Settings>
- <Dependencies Name="Release_Win"/>
</CodeLite_Project>
diff --git a/sdk/codelite_indexer/indexer_client/main.cpp b/sdk/codelite_indexer/indexer_client/main.cpp
index 8b45b28c..426a152e 100644
--- a/sdk/codelite_indexer/indexer_client/main.cpp
+++ b/sdk/codelite_indexer/indexer_client/main.cpp
@@ -32,16 +32,13 @@ int main(int argc, char **argv)
// build the request
req.setCmd(clIndexerRequest::CLI_PARSE_AND_SAVE);
std::vector<std::string> files;
-
-#ifdef __WXMSW__
- files.push_back("C:\\Development\\C++\\codelite\\CL_trunk\\sdk\\codelite_indexer\\workerthread_test.h");
-#else
- char *home = getenv("HOME");
- std::string file_name;
- file_name += home;
- file_name += "/devl/codelite/sqlite3/sqlite3.h";
- files.push_back(file_name);
-#endif
+
+ char *testFile = getenv("TEST_FILE");
+ if( testFile == NULL ) {
+ printf("ERROR: Please set env variable TEST_FILE\n");
+ exit(-1);
+ }
+ files.push_back(testFile);
req.setFiles(files);
req.setCtagOptions("--excmd=pattern --sort=no --fields=aKmSsnit --c-kinds=+p --C++-kinds=+p -IwxT,_T");
diff --git a/sdk/codelite_indexer/libctags/c.c b/sdk/codelite_indexer/libctags/c.c
index 0f26be20..7fb6b6f9 100644
--- a/sdk/codelite_indexer/libctags/c.c
+++ b/sdk/codelite_indexer/libctags/c.c
@@ -2596,6 +2596,9 @@ static void parseGeneralToken (statementInfo *const st, const int c)
*/
static void nextToken (statementInfo *const st)
{
+ const tokenInfo *const prev = prevToken (st, 1);
+ const tokenInfo *const prev2 = prevToken (st, 2);
+ const tokenInfo *const prev3 = prevToken (st, 3);
tokenInfo *token;
do
{
@@ -2604,7 +2607,33 @@ static void nextToken (statementInfo *const st)
{
case EOF: longjmp (Exception, (int) ExceptionEOF); break;
case '(': analyzeParens (st); break;
- case '<': processAngleBracket (); break;
+ case '<': {
+ if(prev->type == TOKEN_NAME && prev2->keyword == KEYWORD_CLASS && prev3->keyword == KEYWORD_TEMPLATE) {
+ /* we found a template instantiation */
+ CollectingSignature = TRUE;
+
+ /* Keep the template instantiation list */
+ /* clear the Signature global buffer */
+ if(Signature->size) {
+ memset(Signature->buffer, 0, Signature->size);
+ }
+ Signature->length = 0;
+ vStringPut(Signature, '<');
+ processAngleBracket ();
+
+ vStringCat(prev->name, Signature);
+ /* clear the Signature global buffer */
+ if(Signature->size) {
+ memset(Signature->buffer, 0, Signature->size);
+ }
+ Signature->length = 0;
+ CollectingSignature = FALSE;
+
+ } else {
+ processAngleBracket ();
+ }
+ break;
+ }
case '*': st->haveQualifyingName = FALSE; break;
case ',': setToken (st, TOKEN_COMMA); break;
case ':': processColon (st); break;
diff --git a/sdk/codelite_indexer/libctags/read.c b/sdk/codelite_indexer/libctags/read.c
index 1881a00a..a8edb2df 100644
--- a/sdk/codelite_indexer/libctags/read.c
+++ b/sdk/codelite_indexer/libctags/read.c
@@ -405,6 +405,7 @@ extern void fileUngetc (int c)
File.ungetch = c;
}
+extern char* regReplace(const char* src, const char* key, const char* value);
static vString *iFileGetLine (void)
{
static list_t *replacements = (list_t *)0;
@@ -458,14 +459,25 @@ static vString *iFileGetLine (void)
list_node_t *node = replacements->head;
while( node ) {
- tmp = string_replace(new_str, ((string_pair_t*)node->data)->key, ((string_pair_t*)node->data)->data);
+ char *find_what = ((string_pair_t*)node->data)->key;
+ char *replace_with = ((string_pair_t*)node->data)->data;
+
+ if(find_what && strlen(find_what) > 3 && strncmp(find_what, "re:", 3) == 0) {
+ // regular expression search/replace
+ tmp = regReplace(new_str, find_what+3, replace_with);
+
+ } else {
+ // normal searcn/replace
+ tmp = string_replace(new_str, find_what, replace_with);
+
+ }
if(!first_loop) {
free(new_str);
}
new_str = tmp;
first_loop = 0;
-
+
/* advance to next item in the list */
node = node->next;
}
diff --git a/sdk/codelite_indexer/utils.cpp b/sdk/codelite_indexer/utils.cpp
index 5be78da1..dce4ca28 100644
--- a/sdk/codelite_indexer/utils.cpp
+++ b/sdk/codelite_indexer/utils.cpp
@@ -2,6 +2,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <wx/string.h>
+#include <wx/regex.h>
+#include <map>
#ifdef __WXMSW__
# include <windows.h>
@@ -16,60 +19,6 @@
*/
/**
- * @brief return the string before the first occurance of 'c'
- * @param s input string
- * @param c delimiter char
- * @return string or the entire 's' string of 'c' is not found
- */
-std::string before_first(const std::string &s, char c)
-{
- std::string::size_type where = s.find(c);
- if (where == std::string::npos) {
- return s;
- }
- return s.substr(0, where);
-}
-
-/**
- * @brief return string after the first occurance of 'c'
- * @param s input string
- * @param c delimiter char
- * @return string or empty string if 'c' is not found
- */
-std::string after_first(const std::string &s, char c)
-{
- std::string::size_type where = s.find(c);
- if (where == std::string::npos) {
- return "";
- }
- return s.substr(where);
-}
-
-/**
- * @brief return true if s starts with prefix, false otherwise
- */
-bool starts_with(const std::string &s, const std::string &prefix)
-{
- if (s.find(prefix) == 0) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief return true if s starts with prefix, false otherwise
- */
-bool ends_with(const std::string &s, const std::string &suffix, std::string &rest)
-{
- std::string::size_type where = s.rfind(suffix);
- if (where != std::string::npos && ((s.length() - where) == suffix.length()) ) {
- rest = s.substr(where);
- return true;
- }
- return false;
-}
-
-/**
* @brief remove whitespaces from string
* @param str
*/
@@ -118,30 +67,6 @@ std::vector<std::string> string_tokenize(const std::string &str, const std::stri
return tokens;
}
-/**
- * @brief Gets all characters before the last occurrence of c. Returns the empty string if c is not found
- */
-std::string before_last(const std::string &str, char c)
-{
- std::string::size_type where = str.rfind(c);
- if (where == std::string::npos) {
- return "";
- }
- return str.substr(0, where);
-}
-
-/**
- * @brief Gets all the characters after the last occurrence of c. Returns the whole string if c is not found.
- */
-std::string after_last(const std::string &str, char c)
-{
- std::string::size_type where = str.rfind(c);
- if (where == std::string::npos) {
- return str;
- }
- return str.substr(where+1);
-}
-
// ------------------------------------------
// Process manipulation
// ------------------------------------------
@@ -169,3 +94,39 @@ bool is_process_alive(long pid)
return kill(pid, 0) == 0; // send signal 0 to process
#endif
}
+
+static std::map<wxString, wxRegEx*> s_regexPool;
+
+extern "C" char* regReplace(const char* src, const char* key, const char* value)
+{
+ wxString findWhat = wxString(key, wxConvUTF8);
+ wxString replaceWith = wxString(value, wxConvUTF8);
+ wxString inputStr = wxString(src, wxConvUTF8);
+
+
+ wxRegEx *re (NULL);
+ if(s_regexPool.find(findWhat) != s_regexPool.end()) {
+ re = s_regexPool.find(findWhat)->second;
+ }
+
+ if(re == NULL) {
+ re = new wxRegEx(findWhat);
+ }
+
+ if(!re->IsValid()) {
+ // invalid regular expression
+ // return a copy of the input string
+ delete re;
+ return strdup(src);
+ }
+
+ // keep this instance
+ s_regexPool[findWhat] = re;
+
+ // regex is valid, try to match
+ if(re->Matches(inputStr)) {
+ re->ReplaceAll(&inputStr, replaceWith);
+ }
+
+ return strdup( inputStr.mb_str(wxConvUTF8).data() );
+}
diff --git a/sdk/codelite_indexer/utils.h b/sdk/codelite_indexer/utils.h
index 42e6519b..bb48be4d 100644
--- a/sdk/codelite_indexer/utils.h
+++ b/sdk/codelite_indexer/utils.h
@@ -3,35 +3,6 @@
#include <vector>
#include <string>
-/**
- * helper string methods
- */
-
-/**
- * @brief return the string before the first occurance of 'c'
- * @param s input string
- * @param c delimiter char
- * @return string or the entire 's' string of 'c' is not found
- */
-std::string before_first(const std::string &s, char c);
-
-/**
- * @brief return string after the first occurance of 'c'
- * @param s input string
- * @param c delimiter char
- * @return string or empty string if 'c' is not found
- */
-std::string after_first(const std::string &s, char c);
-
-/**
- * @brief return true if s starts with prefix, false otherwise
- */
-bool starts_with(const std::string &s, const std::string &prefix);
-
-/**
- * @brief return true if s starts with prefix, false otherwise
- */
-bool ends_with(const std::string &s, const std::string &suffix, std::string &rest);
/**
* @brief remove whitespaces from string
@@ -47,16 +18,6 @@ void string_trim(std::string &str);
*/
std::vector<std::string> string_tokenize(const std::string &str, const std::string& delimiter);
-/**
- * @brief Gets all characters before the last occurrence of c. Returns the empty string if c is not found
- */
-std::string before_last(const std::string &str, char c);
-
-/**
- * @brief Gets all the characters after the last occurrence of c. Returns the whole string if c is not found.
- */
-std::string after_last(const std::string &str, char c);
-
//------------------------------------------------------------
// process methods
//------------------------------------------------------------