Make ctags and cscope more compatible.
David Blume

David Blume commited on 2017-12-30 13:35:25
Showing 4 changed files, with 38 additions and 2 deletions.

... ...
@@ -3,6 +3,13 @@
3 3
 
4 4
 #define MY_LIB_DEFINE 0
5 5
 
6
+class my_lib_rect {
7
+    int width_, height_;
8
+public:
9
+    my_lib_rect(int width, int height);
10
+    int area() const;
11
+};
12
+
6 13
 int my_lib_fn();
7 14
 int my_lib_fn(int x);
8 15
 
... ...
@@ -3,4 +3,11 @@ set -eu -o pipefail # See: https://sipb.mit.edu/doc/safe-shell/
3 3
 
4 4
 find $PWD -regex ".*\.[hcHC]\(pp\|xx\)?" | \
5 5
     grep -v " \|/generated/" > cscope.files
6
-cscope -q -b
6
+
7
+# -b = Build database.
8
+# -q = Enable fast symbol lookup via an inverted index.
9
+# -R = (Instead of using cscope.files) Recurse subdirectories.
10
+# -k = Kernel mode. (Ignore /usr/include)
11
+cscope -q -b -k
12
+
13
+echo "You can now use \`cscope -d\`  # Run cscope without updating cross reference"
... ...
@@ -2,12 +2,14 @@
2 2
 set -eu -o pipefail # See: https://sipb.mit.edu/doc/safe-shell/
3 3
 
4 4
 ctags -n --if0=yes --langmap=c++:+.inl --c++-kinds=+p --file-tags=yes -R --extra=fq \
5
+    --exclude=.git \
5 6
     --exclude='obj/*' \
6 7
     --exclude='lib/*' \
7 8
     --exclude='*generated/*'
8 9
 
9 10
 find . -mindepth 1 \
10 11
         '(' -path './include' ')' -prune \
12
+    -or '(' -path './.git' ')' -prune \
11 13
     -or '(' -path './lib' ')' -prune \
12 14
     -or '(' -path '*/generated' ')' -prune \
13 15
     -or '(' -type d ')' -print | while read i
... ...
@@ -3,12 +3,32 @@
3 3
 
4 4
 using namespace std;
5 5
 
6
+namespace {
7
+
8
+  int my_lib_helper_fn(int x) {
9
+    cout << "The function " << __func__ << " with parameter " << x << " was called." << endl;
10
+    return x + 1;
11
+  }
12
+
13
+}
14
+
15
+my_lib_rect::my_lib_rect(int width, int height):
16
+  width_(width),
17
+  height_(height)
18
+{}
19
+
20
+int my_lib_rect::area() const
21
+{
22
+	return width_ * height_;
23
+}
24
+
6 25
 int my_lib_fn() {
7 26
     cout << "The function " << __func__ << " was called." << endl;
8 27
     return 0;
9 28
 }
10 29
 
11 30
 int my_lib_fn(int x) {
31
+    int a = my_lib_helper_fn(x);
12 32
     cout << "The function " << __PRETTY_FUNCTION__ << " with parameter " << x << " was called." << endl;
13
-    return x+1;
33
+    return x + a;
14 34
 }
15 35