Skip to content

Commit

Permalink
parser changes undone. requiring args to not include type params or c…
Browse files Browse the repository at this point in the history
…onstraints
  • Loading branch information
jaredmtterminus committed Dec 13, 2024
1 parent e7c0976 commit ceb8b76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
5 changes: 1 addition & 4 deletions arguments/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func (a *ParsedArguments) parseInterfaceName(packageMode bool, args []string) {
a.InterfaceName = fullyQualifiedInterface[len(fullyQualifiedInterface)-1]
} else {
a.InterfaceName = args[1]
a.InterfaceName = strings.Split(a.InterfaceName, "[")[0]
}
}

Expand Down Expand Up @@ -142,8 +141,7 @@ func (a *ParsedArguments) parseOutputPath(packageMode bool, workingDir string, o
if strings.HasSuffix(outputPath, ".go") {
outputPathIsFilename = true
}
fakeImplName := strings.Split(a.FakeImplName, "[")[0]
snakeCaseName := strings.ToLower(camelRegexp.ReplaceAllString(fakeImplName, "${1}_${2}"))
snakeCaseName := strings.ToLower(camelRegexp.ReplaceAllString(a.FakeImplName, "${1}_${2}"))

if outputPath != "" {
if !filepath.IsAbs(outputPath) {
Expand Down Expand Up @@ -189,7 +187,6 @@ func (a *ParsedArguments) parsePackagePath(packageMode bool, args []string) {
a.PackagePath = strings.Join(fullyQualifiedInterface[:len(fullyQualifiedInterface)-1], ".")
} else {
a.InterfaceName = args[1]
a.InterfaceName = strings.Split(a.InterfaceName, "[")[0]
}

if a.PackagePath == "" {
Expand Down
19 changes: 10 additions & 9 deletions fixtures/genericinterface/genericinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ package genericinterface
type CustomTypeT any
type CustomTypeU any

//counterfeiter:generate . GenericInterface[T CustomType]
type GenericInterface[T CustomTypeT] interface {
ReturnT() T
TakeT(T)
TakeAndReturnT(T) T
DoSomething()
}
// incorrect setup. this would fail
// //counterfeiter:generate . GenericInterfaceBad[T CustomType]
// type GenericInterfaceBad[T CustomTypeT] interface {
// ReturnT() T
// TakeT(T)
// TakeAndReturnT(T) T
// DoSomething()
// }

//counterfeiter:generate . GenericInterface2
type GenericInterface2[T CustomTypeT] interface {
//counterfeiter:generate . GenericInterface
type GenericInterface[T CustomTypeT] interface {
ReturnT() T
TakeT(T)
TakeAndReturnT(T) T
Expand Down

0 comments on commit ceb8b76

Please sign in to comment.