MCPcopy Create free account
hub / github.com/SplootCode/splootcode / getAutocompleteInfo

Function getAutocompleteInfo

packages/runtime-python/src/autocomplete.ts:223–261  ·  view source on GitHub ↗
(
  program: StructuredEditorProgram,
  type: Type,
  seen?: Set<string>
)

Source from the content-addressed store, hash-verified

221}
222
223export function getAutocompleteInfo(
224 program: StructuredEditorProgram,
225 type: Type,
226 seen?: Set<string>
227): AutocompleteInfo[] {
228 if (!seen) {
229 seen = new Set()
230 }
231
232 if (type.category === TC.Module) {
233 return suggestionsForEntries(program, type.fields, seen)
234 } else if (type.category === TC.Class) {
235 const suggestions: AutocompleteInfo[] = suggestionsForEntries(program, type.details.fields, seen, type.details.name)
236
237 for (const base of type.details.baseClasses) {
238 if (base.category !== TC.Class) {
239 continue
240 }
241
242 suggestions.push(...suggestionsForEntries(program, (base as any).details.fields, seen, type.details.name))
243 }
244
245 return suggestions
246 } else if (type.category === TC.Union) {
247 const suggestions: AutocompleteInfo[] = []
248
249 for (const subtype of type.subtypes) {
250 suggestions.push(...getAutocompleteInfo(program, subtype, seen))
251 }
252
253 return suggestions
254 } else if (type.category === TC.Any || type.category === TC.Unknown) {
255 // pass
256 } else {
257 console.error('unhandled type category', type)
258 }
259
260 return []
261}

Callers 2

getExpressionTypeInfoFunction · 0.90

Calls 1

suggestionsForEntriesFunction · 0.85

Tested by

no test coverage detected