Skip to content

Commit 0f42164

Browse files
authored
feat: support --disable-build-graph (#181)
1 parent a6e045f commit 0f42164

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lang/parse.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ type ParseOptions struct {
5151

5252
LspOptions map[string]string
5353

54+
DisableBuildGraph bool
55+
5456
// TS options
5557
// tsconfig string
5658
TSParseOptions
@@ -102,6 +104,13 @@ func Parse(ctx context.Context, uri string, args ParseOptions) ([]byte, error) {
102104
log.Error("Failed to collect symbols: %v\n", err)
103105
return nil, err
104106
}
107+
108+
if !args.DisableBuildGraph {
109+
if err = repo.BuildGraph(); err != nil {
110+
return nil, err
111+
}
112+
}
113+
105114
log.Info("all symbols collected, start writing to stdout...\n")
106115

107116
if args.RepoID != "" {
@@ -199,9 +208,6 @@ func collectSymbol(ctx context.Context, cli *lsp.LSPClient, repoPath string, opt
199208
}
200209
}
201210

202-
if err := repo.BuildGraph(); err != nil {
203-
return nil, err
204-
}
205211
return repo, nil
206212
}
207213

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Language Support:
186186
cmd.Flags().BoolVar(&opts.NoNeedComment, "no-need-comment", false, "Skip parsing code comments (only works for Go).")
187187
cmd.Flags().BoolVar(&opts.NotNeedTest, "no-need-test", false, "Skip test files during parsing (only works for Go).")
188188
cmd.Flags().BoolVar(&opts.LoadByPackages, "load-by-packages", false, "Load packages one by one instead of all at once (only works for Go, uses more memory).")
189+
cmd.Flags().BoolVar(&opts.DisableBuildGraph, "disable-build-graph", false, "Disable the step of building the dependency graph among AST nodes.")
189190
cmd.Flags().StringSliceVar(&opts.Excludes, "exclude", []string{}, "Files or directories to exclude from parsing (can be specified multiple times).")
190191
cmd.Flags().StringVar(&opts.RepoID, "repo-id", "", "Custom identifier for this repository (useful for multi-repo scenarios).")
191192
cmd.Flags().StringArrayVar(&opts.BuildFlags, "build-flag", []string{}, "Pass build flags to the Go parser (e.g. -tags=xxx).")

0 commit comments

Comments
 (0)