· 8 years ago · Dec 03, 2017, 12:12 PM
1#3015426 main() function disappears after adding second project.
2
3diff -r dabad893d55f -r d78e7873c3ea CodeLite/istorage.h
4--- a/CodeLite/istorage.h Sun Sep 11 13:34:11 2011 +0300
5+++ b/CodeLite/istorage.h Mon Sep 12 20:17:40 2011 +0300
6@@ -251,7 +251,7 @@
7 * @param path
8 * @return TagOk or TagError
9 */
10- virtual int DeleteTagEntry ( const wxString &kind, const wxString &signature, const wxString &path ) = 0;
11+ virtual int DeleteTagEntry ( const wxString &kind, const wxString &signature, const wxString &path, const wxString &file ) = 0;
12
13 /**
14 * Return a result set of tags according to file name.
15diff -r dabad893d55f -r d78e7873c3ea CodeLite/parse_thread.cpp
16--- a/CodeLite/parse_thread.cpp Sun Sep 11 13:34:11 2011 +0300
17+++ b/CodeLite/parse_thread.cpp Mon Sep 12 20:17:40 2011 +0300
18@@ -260,7 +260,7 @@
19
20 // remove all the 'deleted' items from the database
21 for (i=0; i<deletedItems.size(); i++) {
22- m_pDb->DeleteTagEntry(deletedItems[i].second.GetKind(), deletedItems[i].second.GetSignature(), deletedItems[i].second.GetPath());
23+ m_pDb->DeleteTagEntry(deletedItems[i].second.GetKind(), deletedItems[i].second.GetSignature(), deletedItems[i].second.GetPath(), deletedItems[i].second.GetFile());
24 }
25
26 // insert all new items to database
27diff -r dabad893d55f -r d78e7873c3ea CodeLite/tags_storage_sqlite3.cpp
28--- a/CodeLite/tags_storage_sqlite3.cpp Sun Sep 11 13:34:11 2011 +0300
29+++ b/CodeLite/tags_storage_sqlite3.cpp Mon Sep 12 20:17:40 2011 +0300
30@@ -123,7 +123,7 @@
31 m_db->ExecuteUpdate(sql);
32
33 // Create unique index on tags table
34- sql = wxT("CREATE UNIQUE INDEX IF NOT EXISTS TAGS_UNIQ on tags(kind, path, signature);");
35+ sql = wxT("CREATE UNIQUE INDEX IF NOT EXISTS TAGS_UNIQ on tags(kind, path, signature, file);");
36 m_db->ExecuteUpdate(sql);
37
38 sql = wxT("CREATE INDEX IF NOT EXISTS KIND_IDX on tags(kind);");
39@@ -826,15 +826,16 @@
40 return TagOk;
41 }
42
43-int TagsStorageSQLite::DeleteTagEntry(const wxString& kind, const wxString& signature, const wxString& path)
44+int TagsStorageSQLite::DeleteTagEntry(const wxString& kind, const wxString& signature, const wxString& path, const wxString& file)
45 {
46 // Delete this record from database.
47 // Delete is done using the index
48 try {
49- wxSQLite3Statement statement = m_db->GetPrepareStatement(wxT("DELETE FROM TAGS WHERE Kind=? AND Signature=? AND Path=?"));
50+ wxSQLite3Statement statement = m_db->GetPrepareStatement(wxT("DELETE FROM TAGS WHERE Kind=? AND Signature=? AND Path=? AND File=?"));
51 statement.Bind(1, kind); // Kind
52 statement.Bind(2, signature); // Signature
53 statement.Bind(3, path); // Path
54+ statement.Bind(4, file); // Path
55 statement.ExecuteUpdate();
56 } catch (wxSQLite3Exception& exc) {
57 wxUnusedVar(exc);
58@@ -881,7 +882,7 @@
59 return TagOk;
60
61 try {
62- wxSQLite3Statement statement = m_db->GetPrepareStatement(wxT("UPDATE OR REPLACE TAGS SET Name=?, File=?, Line=?, Access=?, Pattern=?, Parent=?, Inherits=?, Typeref=?, Scope=?, Return_Value=? WHERE Kind=? AND Signature=? AND Path=?"));
63+ wxSQLite3Statement statement = m_db->GetPrepareStatement(wxT("UPDATE OR REPLACE TAGS SET Name=?, File=?, Line=?, Access=?, Pattern=?, Parent=?, Inherits=?, Typeref=?, Scope=?, Return_Value=? WHERE Kind=? AND Signature=? AND Path=? AND File=?"));
64 // update
65 statement.Bind(1, tag.GetName());
66 statement.Bind(2, tag.GetFile());
67@@ -898,6 +899,7 @@
68 statement.Bind(11, tag.GetKind());
69 statement.Bind(12, tag.GetSignature());
70 statement.Bind(13, tag.GetPath());
71+ statement.Bind(14, tag.GetFile());
72
73 statement.ExecuteUpdate();
74 } catch (wxSQLite3Exception& exc) {
75diff -r dabad893d55f -r d78e7873c3ea CodeLite/tags_storage_sqlite3.h
76--- a/CodeLite/tags_storage_sqlite3.h Sun Sep 11 13:34:11 2011 +0300
77+++ b/CodeLite/tags_storage_sqlite3.h Mon Sep 12 20:17:40 2011 +0300
78@@ -33,7 +33,7 @@
79 #include <wx/wxsqlite3.h>
80 #include "codelite_exports.h"
81
82-const wxString gTagsDatabaseVersion(wxT("CodeLite Version 2.9"));
83+const wxString gTagsDatabaseVersion(wxT("CodeLite Version 2.10"));
84
85 /**
86 * TagsDatabase is a wrapper around wxSQLite3 database with tags specific functions.
87@@ -503,7 +503,7 @@
88 * @param path
89 * @return TagOk or TagError
90 */
91- virtual int DeleteTagEntry ( const wxString &kind, const wxString &signature, const wxString &path );
92+ virtual int DeleteTagEntry ( const wxString &kind, const wxString &signature, const wxString &path, const wxString &file );
93
94 /**
95 * @brief return true if type exist under a given scope.
96
97diff -r d78e7873c3ea -r 9eee87b498b0 CodeLite/language.cpp
98--- a/CodeLite/language.cpp Mon Sep 12 20:17:40 2011 +0300
99+++ b/CodeLite/language.cpp Sat Sep 17 16:10:13 2011 +0300
100@@ -1058,8 +1058,6 @@
101 // (they can be mixed). If all entries are of one of these types, test their return value,
102 // if all have the same return value, then we are ok
103 clFunction foo;
104- int classMatches (0);
105- size_t classMatchIdx(0);
106
107 for (size_t i=0; i<tags.size(); i++) {
108 TagEntryPtr tag(tags.at(i));
109@@ -1075,26 +1073,58 @@
110 }
111
112 // Dont give up yet!
113- // If in the list of matches there is a single entry of type class
114- // use it as our match
115+ // If in the list of matches there is at least one struct or class return it
116+ int foundIndex = -1;
117 for (size_t i=0; i<tags.size(); i++) {
118 if(tags.at(i)->IsClass() || tags.at(i)->IsStruct()) {
119- classMatches++;
120- classMatchIdx = i;
121+ foundIndex = i;
122+ break;
123 }
124 }
125
126- if(classMatches == 1) {
127- TagEntryPtr tag = tags.at(classMatchIdx);
128- tags.clear();
129- tags.push_back( tag );
130-
131- type = tag->GetName();
132- typeScope = tag->GetScopeName();
133+ // If in the list of matches there is at least one namespace return it
134+ if (foundIndex < 0) {
135+ for (size_t i=0; i<tags.size(); i++) {
136+ if (tags.at(i)->GetKind().IsSameAs(_("namespace"))) {
137+ foundIndex = i;
138+ break;
139+ }
140+ }
141+ }
142+ if (foundIndex < 0) {
143+ Variable var;
144+ wxString oldType;
145+ wxString oldTypeScope;
146+ for (size_t i = 0; i < tags.size(); i++) {
147+ if (
148+ (tags[i]->GetKind() != wxT("member") && tags[i]->GetKind() != wxT("variable")) ||
149+ !VariableFromPattern(tags[i]->GetPattern(), tags[i]->GetName(), var)
150+ ) {
151+ return false;
152+ }
153+ type = _U(var.m_type.c_str());
154+ typeScope = var.m_typeScope.empty() ? wxT("<global>") : _U(var.m_typeScope.c_str());
155+ if (i == 0) {
156+ oldType = type;
157+ oldTypeScope = typeScope;
158+ }
159+ if (!oldType.IsSameAs(type) || !oldTypeScope.IsSameAs(typeScope)) {
160+ return false;
161+ }
162+ oldType = type;
163+ oldTypeScope = typeScope;
164+ }
165 return true;
166 }
167-
168- return false;
169+ if (foundIndex < 0) {
170+ return false;
171+ }
172+ TagEntryPtr tag = tags.at(foundIndex);
173+ tags.clear();
174+ tags.push_back( tag );
175+ type = tag->GetName();
176+ typeScope = tag->GetScopeName();
177+ return true;
178 }
179 }
180 return false;