Skip to content

Commit

Permalink
Merge pull request #1789 from alixander/compile-chain
Browse files Browse the repository at this point in the history
expose import stack
  • Loading branch information
alixander authored Dec 25, 2023
2 parents fa98423 + 336789c commit 2bb4f98
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion d2compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Compile(p string, r io.Reader, opts *CompileOptions) (*d2graph.Graph, *d2ta
return nil, nil, err
}

ir, err := d2ir.Compile(ast, &d2ir.CompileOptions{
ir, _, err := d2ir.Compile(ast, &d2ir.CompileOptions{
UTF16Pos: opts.UTF16Pos,
FS: opts.FS,
})
Expand Down
6 changes: 3 additions & 3 deletions d2ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) {
c.err.Errors = append(c.err.Errors, d2parser.Errorf(n, f, v...).(d2ast.Error))
}

func Compile(ast *d2ast.Map, opts *CompileOptions) (*Map, error) {
func Compile(ast *d2ast.Map, opts *CompileOptions) (*Map, []string, error) {
if opts == nil {
opts = &CompileOptions{}
}
Expand All @@ -78,9 +78,9 @@ func Compile(ast *d2ast.Map, opts *CompileOptions) (*Map, error) {
c.compileSubstitutions(m, nil)
c.overlayClasses(m)
if !c.err.Empty() {
return nil, c.err
return nil, nil, c.err
}
return m, nil
return m, c.importStack, nil
}

func (c *compiler) overlayClasses(m *Map) {
Expand Down
2 changes: 1 addition & 1 deletion d2ir/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func compileFS(t testing.TB, path string, mfs map[string]string) (*d2ir.Map, err
err = fs.Close()
assert.Success(t, err)
})
m, err := d2ir.Compile(ast, &d2ir.CompileOptions{
m, _, err := d2ir.Compile(ast, &d2ir.CompileOptions{
FS: fs,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion d2oracle/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
return nil
}
}
ir, err := d2ir.Compile(g.AST, &d2ir.CompileOptions{
ir, _, err := d2ir.Compile(g.AST, &d2ir.CompileOptions{
FS: g.FS,
})
if err != nil {
Expand Down

0 comments on commit 2bb4f98

Please sign in to comment.