Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
feat: nested structs and chained completion (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ig-ra authored Feb 20, 2024
1 parent 35d8763 commit a8bde82
Show file tree
Hide file tree
Showing 15 changed files with 978 additions and 527 deletions.
13 changes: 13 additions & 0 deletions pkg/analysis/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ func LoadBuiltinsFromSource(ctx context.Context, contents []byte, path string) (
members = append(members, t.Members...)
}

funcMap := make(map[string]query.Signature, len(functions))
for _, fn := range functions {
funcMap[fn.Name] = fn
}
for i, s := range symbols {
if s.Kind == protocol.SymbolKindFunction {
if f, found := funcMap[s.Name]; found {
symbols[i].Type = f.ReturnType
symbols[i].Aux = &f
}
}
}

doc.Close()

// NewDocument returns these symbols with a location of __init__.py, which isn't helpful to anyone
Expand Down
6 changes: 2 additions & 4 deletions pkg/analysis/builtins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type testType int
const (
testTypeFunctions testType = iota
testTypeSymbols
fixtureFileName = "autokitteh-starlark.test"
)

func TestLoadBuiltinsFromFile(t *testing.T) {
Expand Down Expand Up @@ -285,17 +286,14 @@ func (f *fixture) Document(name string, content string) document.Document {
}

func (f *fixture) MainDoc(content string) document.Document {
return f.Document("Tiltfile.test", content)
return f.Document(fixtureFileName, content)
}

func (f *fixture) ParseBuiltins(content string) {
builtins, err := LoadBuiltinsFromSource(f.ctx, []byte(content), "__test__")
require.NoError(f.t, err)
f.a.builtins.Update(builtins)
f.builtins = f.a.builtins

// f.a.builtins = builtins
// f.builtins = builtins
}

func newFixture(t *testing.T) *fixture {
Expand Down
Loading

0 comments on commit a8bde82

Please sign in to comment.