Comments (2)
@pidgeon777 Currently CodeQuery is not using libclang, so it doesn't really need compilation commands and flags. cscope and ctags or similar tools only need a list of files. Nevertheless this can be considered a possible feature enhancement. I thought about writing a tool to use libclang as another frontend but I haven't got around to it yet. But I think it will be a lot slower than cscope and ctags. However, it will be more accurate.
from codequery.
This is an example of compile_commands.json
file widely used by clangd
and ccls
:
[
{
"directory": "C:/Work/Projects/Linux/Programs/Hello_World",
"command": "C:/CrossComp/bin/aarch64-none-linux-gnu-gcc.exe -Wall -Wextra -I. -isystem C:/CrossComp/aarch64-none-linux-gnu/libc/usr/include -O3 -DNDEBUG -std=c99 -o main.o -c main.c",
"file": "C:/Work/Projects/Linux/Programs/Hello_World/main.c"
},
{
"directory": "XXX",
"command": "YYY",
"file": "ZZZ"
},
...
]
The main key elements are:
-I/path/to/include/headers
: this argument specifies the folder of include headers needed to compile the source file specified by the associated "file" parameter. For each source file to be compiled, multiple-Ixxx
arguments could be specified.-isystem /path/to/system/headers
: this argument specifies the folder of system headers needed to compile the source file specified by the associated "file" parameter. For each source file to be compiled, multiple-isystem
arguments could be specified."file": "/path/to/file.c"
: the source file to compile.
To generate the cscope
database, a cscope.files
file is used, which list all of the C and H files to be parsed. Also, this could be used for generating a tags
file.
This means that by parsing a compile_commands.json
file, it could be possible to do something like this:
- Scan all of the
-Ixxx
argument paths for header files, recursively add them to the list. - Scan all of the
-isystemYYY
argument paths for system headers files, recursively add them to the list (optional?). - Add all of the C sources specified by the "file" to the list.
- Sort the list and remove duplicated elements.
By doing so, a cscope.files
could be generated, like the following:
...
C:\CrossComp\aarch64-none-linux-gnu\libc\usr\include\stdio.h
C:\Work\Projects\Linux\Programs\Hello_World\include.h
C:\Work\Projects\Linux\Programs\Hello_World\main.c
...
and it would include exactly the same files parsed through the compile_commands.json
file by clangd
or ccls
.
So, the resulting cscope/CodeQuery
database would be the most complete and accurate one.
I thought about writing a tool to use libclang as another frontend but I haven't got around to it yet. But I think it will be a lot slower than cscope and ctags. However, it will be more accurate.
This would be great and I encourage you to do so. Even better if it could work as an LSP client, thus compatible with almost every programming language.
LSP is the future of programming languages, tags based analysis is quick and fast but it is impossible to obtain the same level of accuracy and completeness provided by LSP-based solutions.
from codequery.
Related Issues (20)
- Documentation doesn't list all the required dependencies. Code fails silently when missing them HOT 1
- Why didn't the option to compile without GUI wasn't merged to v0.21.1? HOT 1
- java finding implementations of interface HOT 2
- Any open API for batch operation to generate function called graphs instead of GUI? HOT 3
- Compilation error HOT 2
- Missing a QT5 library in Ubuntu 18.04 HOT 2
- [Feature] Visual Studio Code extension HOT 3
- [Enhancement] Update of cscope to 15.9 version HOT 3
- [Feature] Highlight current function HOT 4
- Icon theme "elementary" not found. HOT 11
- Unable to get codequery on go project to cover all files HOT 3
- update german language translation HOT 1
- Unsupported cscope parameters: -c is required. -q, -b and -R are optional. The rest should not be used. HOT 8
- Call Graph is not working correctly HOT 1
- Call Graph is not working correctly HOT 1
- [Enhancement] Better 'cqsearch.exe' output results HOT 3
- [ENHANCEMENT] Please add the scripts for building the database HOT 1
- On macbook, window width is too wide and cannot be resized HOT 11
- CQSearch does not seem to work with special characters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codequery.