diff --git a/lang/parse.go b/lang/parse.go index e323af0c..d2c751c4 100644 --- a/lang/parse.go +++ b/lang/parse.go @@ -51,6 +51,8 @@ type ParseOptions struct { LspOptions map[string]string + DisableBuildGraph bool + // TS options // tsconfig string TSParseOptions @@ -102,6 +104,13 @@ func Parse(ctx context.Context, uri string, args ParseOptions) ([]byte, error) { log.Error("Failed to collect symbols: %v\n", err) return nil, err } + + if !args.DisableBuildGraph { + if err = repo.BuildGraph(); err != nil { + return nil, err + } + } + log.Info("all symbols collected, start writing to stdout...\n") if args.RepoID != "" { @@ -199,9 +208,6 @@ func collectSymbol(ctx context.Context, cli *lsp.LSPClient, repoPath string, opt } } - if err := repo.BuildGraph(); err != nil { - return nil, err - } return repo, nil } diff --git a/main.go b/main.go index 13acf1be..ffaf10a7 100644 --- a/main.go +++ b/main.go @@ -186,6 +186,7 @@ Language Support: cmd.Flags().BoolVar(&opts.NoNeedComment, "no-need-comment", false, "Skip parsing code comments (only works for Go).") cmd.Flags().BoolVar(&opts.NotNeedTest, "no-need-test", false, "Skip test files during parsing (only works for Go).") 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).") + cmd.Flags().BoolVar(&opts.DisableBuildGraph, "disable-build-graph", false, "Disable the step of building the dependency graph among AST nodes.") cmd.Flags().StringSliceVar(&opts.Excludes, "exclude", []string{}, "Files or directories to exclude from parsing (can be specified multiple times).") cmd.Flags().StringVar(&opts.RepoID, "repo-id", "", "Custom identifier for this repository (useful for multi-repo scenarios).") cmd.Flags().StringArrayVar(&opts.BuildFlags, "build-flag", []string{}, "Pass build flags to the Go parser (e.g. -tags=xxx).")