Skip to content

Commit 8c3793f

Browse files
committed
Rename EmptyObject to GlobalScope
1 parent b984c23 commit 8c3793f

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

grade/internal/domain/endorser/specifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func (c EndorserCriteria) pendingEndorsementCount() s.FieldNode {
1818
}
1919

2020
func (c EndorserCriteria) obj() s.ObjectNode {
21-
return s.Object(s.EmptyObject(), "endorser")
21+
return s.Object(s.GlobalScope(), "endorser")
2222
}
2323

2424
var endorser = EndorserCriteria{}

grade/internal/domain/seedwork/specification/evaluate_visitor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (v *EvaluateVisitor) SetCurrentValue(val []any) {
2525
v.currentValue = val
2626
}
2727

28-
func (v *EvaluateVisitor) VisitGlobalScope(n EmptyObjectNode) error {
28+
func (v *EvaluateVisitor) VisitGlobalScope(n GlobalScopeNode) error {
2929
v.SetCurrentValue([]any{v.Context})
3030
return nil
3131
}
@@ -255,7 +255,7 @@ type Context interface {
255255
func ExtractFieldPath(n FieldNode) []string {
256256
path := []string{n.Name()}
257257
var obj EmptiableObject = n.Object()
258-
for !obj.IsEmpty() {
258+
for !obj.IsRoot() {
259259
path = append([]string{obj.Name()}, path...)
260260
obj = obj.Parent()
261261
}

grade/internal/domain/seedwork/specification/nodes.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type Visitable interface {
6262
}
6363

6464
type Visitor interface {
65-
VisitGlobalScope(EmptyObjectNode) error
65+
VisitGlobalScope(GlobalScopeNode) error
6666
VisitObject(ObjectNode) error
6767
VisitWildcard(WilcardNode) error
6868
VisitItem(ItemNode) error
@@ -223,28 +223,27 @@ type EmptiableObject interface {
223223
Visitable
224224
Parent() EmptiableObject
225225
Name() string
226-
IsEmpty() bool
226+
IsRoot() bool
227227
}
228228

229-
// TODO: Rename me to GlobalScope
230-
func EmptyObject() EmptyObjectNode {
231-
return EmptyObjectNode{}
229+
func GlobalScope() GlobalScopeNode {
230+
return GlobalScopeNode{}
232231
}
233232

234-
type EmptyObjectNode struct{}
233+
type GlobalScopeNode struct{}
235234

236-
func (n EmptyObjectNode) Parent() EmptiableObject {
235+
func (n GlobalScopeNode) Parent() EmptiableObject {
237236
return n
238237
}
239238

240-
func (n EmptyObjectNode) Name() string {
239+
func (n GlobalScopeNode) Name() string {
241240
return "Empty"
242241
}
243242

244-
func (n EmptyObjectNode) IsEmpty() bool {
243+
func (n GlobalScopeNode) IsRoot() bool {
245244
return true
246245
}
247-
func (n EmptyObjectNode) Accept(v Visitor) error {
246+
func (n GlobalScopeNode) Accept(v Visitor) error {
248247
return v.VisitGlobalScope(n)
249248
}
250249

@@ -268,7 +267,7 @@ func (n ObjectNode) Name() string {
268267
return n.name
269268
}
270269

271-
func (n ObjectNode) IsEmpty() bool {
270+
func (n ObjectNode) IsRoot() bool {
272271
return false
273272
}
274273

@@ -317,7 +316,7 @@ func Item() ItemNode {
317316
type ItemNode struct{}
318317

319318
func (n ItemNode) Parent() EmptiableObject {
320-
return EmptyObject()
319+
return GlobalScope()
321320
}
322321

323322
func (n ItemNode) Name() string {

grade/internal/infrastructure/seedwork/specification/postgresql_visitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (v *PostgresqlVisitor) visit(precedenceKey string, callable func() error) e
8585
return nil
8686
}
8787

88-
func (v *PostgresqlVisitor) VisitGlobalScope(_ s.EmptyObjectNode) error {
88+
func (v *PostgresqlVisitor) VisitGlobalScope(_ s.GlobalScopeNode) error {
8989
return nil
9090
}
9191

grade/internal/infrastructure/seedwork/specification/transform_visitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type TransformVisitor struct {
2525
Context
2626
}
2727

28-
func (v *TransformVisitor) VisitGlobalScope(_ s.EmptyObjectNode) error {
28+
func (v *TransformVisitor) VisitGlobalScope(_ s.GlobalScopeNode) error {
2929
return nil
3030
}
3131

grade/internal/infrastructure/seedwork/specification/transform_visitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (sc SomethingCriteria) Id() s.FieldNode {
2020
}
2121

2222
func (sc SomethingCriteria) obj() s.ObjectNode {
23-
return s.Object(s.EmptyObject(), "something")
23+
return s.Object(s.GlobalScope(), "something")
2424
}
2525

2626
type SomethingSpecification struct {

0 commit comments

Comments
 (0)