Skip to content

Commit

Permalink
fix: extract variable check to pattern base
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed Aug 12, 2024
1 parent 51accea commit 563a48d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func getVariableFor(
}

for i, variable := range variables {
if node.Content() == variable.DummyValue {
if patternLanguage.IsVariable(node, variable.DummyValue) {
return &variables[i]
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/scanner/language/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,7 @@ type Pattern interface {

// Handle missing errors
FixupMissing(node *tree.Node) string

// Check if node represents variable with given dummy value
IsVariable(node *tree.Node, dummyValue string) bool
}
4 changes: 4 additions & 0 deletions pkg/scanner/language/patternbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ func (*PatternBase) AdjustInput(input string) string {
func (*PatternBase) FixupMissing(node *tree.Node) string {
return ""
}

func (*PatternBase) IsVariable(node *tree.Node, dummyValue string) bool {
return node.Content() == dummyValue
}

0 comments on commit 563a48d

Please sign in to comment.