MCPcopy Index your code
hub / github.com/bytebase/bytebase / buildCatalog

Function buildCatalog

backend/plugin/parser/mongodb/completion.go:73–96  ·  view source on GitHub ↗

buildCatalog creates an omni catalog from Bytebase completion context.

(ctx context.Context, cCtx base.CompletionContext)

Source from the content-addressed store, hash-verified

71
72// buildCatalog creates an omni catalog from Bytebase completion context.
73func buildCatalog(ctx context.Context, cCtx base.CompletionContext) *catalog.Catalog {
74 cat := catalog.New()
75
76 if cCtx.DefaultDatabase == "" || cCtx.Metadata == nil {
77 return cat
78 }
79
80 _, metadata, err := cCtx.Metadata(ctx, cCtx.InstanceID, cCtx.DefaultDatabase)
81 if err != nil || metadata == nil {
82 return cat
83 }
84
85 for _, schema := range metadata.ListSchemaNames() {
86 schemaMeta := metadata.GetSchemaMetadata(schema)
87 if schemaMeta == nil {
88 continue
89 }
90 for _, table := range schemaMeta.ListTableNames() {
91 cat.AddCollection(table)
92 }
93 }
94
95 return cat
96}
97
98// caretToByteOffset converts a 1-based line and 0-based column offset to a byte offset.
99// Note: caretOffset is treated as a rune (code point) offset, not UTF-16 code units.

Callers 1

CompletionFunction · 0.70

Calls 3

ListSchemaNamesMethod · 0.80
GetSchemaMetadataMethod · 0.80
ListTableNamesMethod · 0.80

Tested by

no test coverage detected