From ceb8b76b4e4408b147fce6c65ed41d8c7c3fd766 Mon Sep 17 00:00:00 2001 From: Jared Ticotin Date: Fri, 13 Dec 2024 15:14:31 -0500 Subject: [PATCH] parser changes undone. requiring args to not include type params or constraints --- arguments/parser.go | 5 +---- fixtures/genericinterface/genericinterface.go | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/arguments/parser.go b/arguments/parser.go index edc32b4..7b1ec82 100644 --- a/arguments/parser.go +++ b/arguments/parser.go @@ -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] } } @@ -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) { @@ -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 == "" { diff --git a/fixtures/genericinterface/genericinterface.go b/fixtures/genericinterface/genericinterface.go index b286b78..a92313a 100644 --- a/fixtures/genericinterface/genericinterface.go +++ b/fixtures/genericinterface/genericinterface.go @@ -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