Skip to content

Commit

Permalink
change addrs.IsModuleMoveReIndex to method
Browse files Browse the repository at this point in the history
This feels more aligned with the other methods for checking move address
relations.
  • Loading branch information
jbardin committed Dec 22, 2021
1 parent ea1795a commit a4cba4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/addrs/move_endpoint_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ func (r AbsResourceInstance) MoveDestination(fromMatch, toMatch *MoveEndpointInM
}
}

// IsModuleMoveReIndex takes the From and To endpoints from a single move
// IsModuleReIndex takes the From and To endpoints from a single move
// statement, and returns true if the only changes are to module indexes, and
// all non-absolute paths remain the same.
func IsModuleMoveReIndex(from, to *MoveEndpointInModule) bool {
func (from *MoveEndpointInModule) IsModuleReIndex(to *MoveEndpointInModule) bool {
// The statements must originate from the same module.
if !from.module.Equal(to.module) {
panic("cannot compare move expressions from different modules")
Expand Down
2 changes: 1 addition & 1 deletion internal/addrs/move_endpoint_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ func TestIsModuleMoveReIndex(t *testing.T) {
relSubject: test.to,
}

if got := IsModuleMoveReIndex(from, to); got != test.expect {
if got := from.IsModuleReIndex(to); got != test.expect {
t.Errorf("expected %t, got %t", test.expect, got)
}
},
Expand Down
4 changes: 2 additions & 2 deletions internal/refactoring/move_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ func statementDependsOn(a, b *MoveStatement) bool {
// when the base name is not changing, causing a cycle in the order of
// operations.
// We only want the nested move statement to depend on the outer module
// move, so we only test this in one direction.
if addrs.IsModuleMoveReIndex(a.To, a.From) {
// move, so we only test this in the reverse direction.
if a.To.IsModuleReIndex(a.From) {
return false
}

Expand Down

0 comments on commit a4cba4d

Please sign in to comment.