Skip to content

Commit 7e80be5

Browse files
committed
fix: fix hardcode in export.go
1 parent 8544a9d commit 7e80be5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lang/collect/export.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func (c *Collector) fileLine(loc Location) uniast.FileLine {
4848
}
4949
}
5050

51-
func newModule(name string, dir string) *uniast.Module {
52-
ret := uniast.NewModule(name, dir, uniast.Rust)
51+
func newModule(name string, dir string, lang uniast.Language) *uniast.Module {
52+
ret := uniast.NewModule(name, dir, lang)
5353
return ret
5454
}
5555

@@ -67,7 +67,7 @@ func (c *Collector) Export(ctx context.Context) (*uniast.Repository, error) {
6767
if err != nil {
6868
return nil, err
6969
}
70-
repo.Modules[name] = newModule(name, rel)
70+
repo.Modules[name] = newModule(name, rel, c.Language)
7171
}
7272

7373
// not allow local symbols inside another symbol
@@ -83,11 +83,13 @@ func (c *Collector) Export(ctx context.Context) (*uniast.Repository, error) {
8383
}
8484

8585
// patch module
86-
for p, m := range repo.Modules {
87-
if p == "" || strings.Contains(p, "@") {
88-
continue
86+
if c.modPatcher != nil {
87+
for p, m := range repo.Modules {
88+
if p == "" || strings.Contains(p, "@") {
89+
continue
90+
}
91+
c.modPatcher.Patch(m)
8992
}
90-
c.modPatcher.Patch(m)
9193
}
9294

9395
return &repo, nil
@@ -140,7 +142,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
140142
}
141143

142144
if repo.Modules[mod] == nil {
143-
repo.Modules[mod] = newModule(mod, "")
145+
repo.Modules[mod] = newModule(mod, "", c.Language)
144146
}
145147
module := repo.Modules[mod]
146148
if repo.Modules[mod].Packages[path] == nil {

0 commit comments

Comments
 (0)