Skip to content

Commit 2c0a698

Browse files
authored
fix: add IsDefaultImport meta field to identify default import (#33)
1 parent 4d4971a commit 2c0a698

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

parser-Go/uast/meta.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package uast
22

33
type Meta struct {
4-
Type Type `json:"type,omitempty"`
5-
Async bool `json:"async,omitempty"`
6-
Defer bool `json:"defer,omitempty"`
7-
IsRestElement bool `json:"isRestElement,omitempty"`
8-
ReceiveCls string `json:"ReceiveCls"`
9-
IsInterface bool `json:"isInterface,omitempty"`
4+
Type Type `json:"type,omitempty"`
5+
Async bool `json:"async,omitempty"`
6+
Defer bool `json:"defer,omitempty"`
7+
IsRestElement bool `json:"isRestElement,omitempty"`
8+
ReceiveCls string `json:"ReceiveCls"`
9+
IsInterface bool `json:"isInterface,omitempty"`
10+
IsDefaultImport bool `json:"isDefaultImport,omitempty"`
1011
}

parser-Go/uast/visitor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ func (u *Builder) VisitImportSpec(node *ast.ImportSpec) UNode {
3333
Cloned: false,
3434
VarType: &DynamicType{Type: "DynamicType"},
3535
VariableParam: false,
36+
Meta: Meta{
37+
IsDefaultImport: true,
38+
},
3639
}
3740
} else {
3841
localName := node.Name.Name
@@ -61,7 +64,7 @@ func (u *Builder) VisitImportSpec(node *ast.ImportSpec) UNode {
6164
LiteralType: "string",
6265
},
6366
}, node.Path),
64-
Cloned: true,
67+
Cloned: false,
6568
VarType: &DynamicType{Type: "DynamicType"},
6669
VariableParam: false,
6770
}

0 commit comments

Comments
 (0)