Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit fc57c53

Browse files
committed
sem: simplify custom Op following code review
Signed-off-by: Alexander Bezzubov <[email protected]>
1 parent fbed224 commit fc57c53

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

driver/normalizer/normalizer.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ var Normalizers = []Mapping{
136136
MapSemantic("StringLiteral", uast.String{}, MapObj(
137137
Fields{
138138
{Name: "normValue", Op: Var("val")},
139-
{Name: "value", Drop: true, Op: singleQuote{Any()}}, // only used in Annotated
139+
{Name: "value", Drop: true, Op: Check(singleQuote{}, Any())}, // only used in Annotated
140140
},
141141
Obj{
142142
"Value": Var("val"),
@@ -362,7 +362,6 @@ var Normalizers = []Mapping{
362362
}
363363

364364
type singleQuote struct {
365-
op Op
366365
}
367366

368367
func (op singleQuote) Kinds() nodes.Kind {
@@ -378,17 +377,5 @@ func (op singleQuote) Check(st *State, n nodes.Node) (bool, error) {
378377
if !strings.HasPrefix(s, `'`) || !strings.HasSuffix(s, `'`) {
379378
return false, nil
380379
}
381-
return op.op.Check(st, nodes.String(s))
382-
}
383-
384-
func (op singleQuote) Construct(st *State, n nodes.Node) (nodes.Node, error) {
385-
n, err := op.op.Construct(st, n)
386-
if err != nil {
387-
return nil, err
388-
}
389-
sn, ok := n.(nodes.String)
390-
if !ok {
391-
return nil, ErrUnexpectedType.New(nodes.String(""), n)
392-
}
393-
return sn, nil
380+
return true, nil
394381
}

0 commit comments

Comments
 (0)