File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Top Open diff view settings Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Top Open diff view settings Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ type CompilationDatabase struct {
3333// CompilationCommand keeps track of a single run of a compile command
3434type CompilationCommand struct {
3535 Directory string `json:"directory"`
36- Arguments []string `json:"arguments"`
36+ Command string `json:"command,omitempty"`
37+ Arguments []string `json:"arguments,omitempty"`
3738 File string `json:"file"`
3839}
3940
@@ -44,6 +45,19 @@ func NewCompilationDatabase(filename *paths.Path) *CompilationDatabase {
4445 }
4546}
4647
48+ // LoadCompilationDatabase reads a compilation database from a file
49+ func LoadCompilationDatabase (file * paths.Path ) (* CompilationDatabase , error ) {
50+ f , err := file .ReadFile ()
51+ if err != nil {
52+ return nil , err
53+ }
54+ res := & CompilationDatabase {
55+ File : file ,
56+ Contents : []CompilationCommand {},
57+ }
58+ return res , json .Unmarshal (f , & res .Contents )
59+ }
60+
4761// SaveToFile save the CompilationDatabase to file as a clangd-compatible compile_commands.json,
4862// see https://clang.llvm.org/docs/JSONCompilationDatabase.html
4963func (db * CompilationDatabase ) SaveToFile () {
You can’t perform that action at this time.
0 commit comments