@@ -9,6 +9,116 @@ The most common problems are timeouts, crashes,
9
9
and lack of sufficient space for [ IPC] [ ] (in Docker),
10
10
which are discussed below.
11
11
12
+ ## Missing code intel
13
+
14
+ In certain cases, precise code intel may be entirely missing despite
15
+ creating and uploading an index successfully.
16
+ There are two common failure modes for this.
17
+
18
+ ### Possibility 1: Missing documents in SCIP index
19
+
20
+ A SCIP index stores documents containing definition and reference
21
+ information for each file on disk.
22
+
23
+ [ SCIP CLI ] : https://github.com/sourcegraph/scip/releases
24
+
25
+ You can inspect the documents using the [ SCIP CLI] [ ] :
26
+
27
+ ``` bash
28
+ scip print --json index.scip | jq .documents
29
+ ```
30
+
31
+ If this prints a non-empty array, see the [ troubleshooting steps for possibility 2] ( #possibility-2-incorrect-document-paths-in-scip-index ) .
32
+
33
+ If this prints ` null ` or an empty array, it's likely
34
+ that the indexer was invoked from a directory other than the project root.
35
+ You can double-check this using:
36
+
37
+ ``` bash
38
+ scip print --json index.scip | jq .metadata.projectRoot
39
+ ```
40
+
41
+ If this points to a subdirectory and not the project root,
42
+ then the scip-clang invocation was incorrect.
43
+
44
+ Here is an example of a common project structure:
45
+
46
+ ```
47
+ /home/me/myproject
48
+ +--- .git/
49
+ +--- README.md
50
+ +--- src/
51
+ | |
52
+ | +--- A.cc
53
+ | +--- subdir/
54
+ | +--- B.cc
55
+ +--- build/ (.gitignored directory)
56
+ ```
57
+
58
+ In this case, ` scip-clang ` ** must** be invoked from ` /home/me/myproject ` ,
59
+ regardless of the contents of the compilation database file (` compile_commands.json ` ).
60
+
61
+ If you want to only index a subset of files (say under ` src/subdir ` ),
62
+ then reduce the size of the compilation database by selecting only specific files.
63
+
64
+ For example, if the compilation database looks like the following:
65
+
66
+ ``` json
67
+ [
68
+ {
69
+ "directory" : " /home/me/myproject/build" ,
70
+ "file" : " /home/me/myproject/src/A.cc" ,
71
+ "command" : " some stuff here"
72
+ },
73
+ {
74
+ "directory" : " /home/me/myproject/build" ,
75
+ "file" : " /home/me/myproject/src/subdir/B.cc" ,
76
+ "command" : " some stuff here"
77
+ }
78
+ ]
79
+ ```
80
+
81
+ And if you only want to index the files inside ` src/subdir ` , then run:
82
+
83
+ ``` bash
84
+ cat compile_commands.json | jq ' .[] | select(.file | contains("src/subdir/"))' > minimal.json
85
+ scip-clang --compdb-path=minimal.json < other args>
86
+ ```
87
+
88
+ ### Possibility 2: Incorrect document paths in SCIP index
89
+
90
+ If the output of the following command using the [ SCIP CLI] [ ]
91
+
92
+ ``` bash
93
+ scip print --json index.scip | jq .documents
94
+ ```
95
+
96
+ is a non-empty array, and you're still not seeing precise code intel
97
+ in the Sourcegraph UI, it's possible the document paths stored in the index
98
+ do not match the actual paths on disk.
99
+
100
+ Double-check that the various ` relativePath ` keys in the ` documents `
101
+ array correspond to actual files on disk relative to the ` projectRoot ` path.
102
+
103
+ - If the ` relativePath ` values are incorrect, then double-check if there
104
+ are any symlinks present in the project layout which may potentially
105
+ be causing incorrect path determination.
106
+ - If the ` relativePath ` values are correct, but you still don't see any
107
+ precise code intel for that file, check that ` occurrences ` arrays for
108
+ various documents are non-empty.
109
+ - If the ` occurrences ` arrays are empty, then report it as an
110
+ indexer bug.
111
+ - If the ` occurrences ` arrays are non-empty, then you can double-check
112
+ the precise code intel using the debug view in the Sourcegraph UI.
113
+
114
+ Click on the 🧠 icon near the top-right of the file contents view
115
+ for the commit for which the index was uploaded,
116
+ and click on 'Display debug information'.
117
+ ![ Debug information for a SCIP index] ( https://github.com/sourcegraph/scip-clang/assets/93103176/58becf36-5524-40f6-87b9-a72bc00b1e04 ) .
118
+
119
+ Then try hovering over entities which have ` ^^^ ` markers below them;
120
+ you should see precise code intel.
121
+
12
122
## Timeouts
13
123
14
124
scip-clang sets a timeout for indexing an individual translation unit,
@@ -78,4 +188,4 @@ There are 3 possible fixes for this:
78
188
3 . Reducing the number of workers:
79
189
scip-clang will automatically use fewer workers if possible,
80
190
but will print a warning when it does so.
81
- This warning can be suppressed by explicitly passing ` --jobs N ` .
191
+ This warning can be suppressed by explicitly passing ` --jobs N ` .
0 commit comments