You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/12/20 18:05:49 UTC

[GitHub] [beam] pabloem commented on a change in pull request #16172: [BEAM-13417] [Playground] Add java preparator for run katas

pabloem commented on a change in pull request #16172:
URL: https://github.com/apache/beam/pull/16172#discussion_r772570287



##########
File path: playground/backend/internal/preparators/java_preparators.go
##########
@@ -33,19 +38,50 @@ const (
 	newLinePattern                    = "\n"
 	pathSeparatorPattern              = os.PathSeparator
 	tmpFileSuffix                     = "tmp"
+	publicClassNamePattern            = "public class (.*?) [{|implements(.*)]"
 )
 
 // GetJavaPreparators returns preparation methods that should be applied to Java code
 func GetJavaPreparators(filePath string) *[]Preparator {
-	publicClassModification := Preparator{
-		Prepare: replace,
+	removePublicClassPreparator := Preparator{
+		Prepare: removePublicClassModifier,
 		Args:    []interface{}{filePath, classWithPublicModifierPattern, classWithoutPublicModifierPattern},
 	}
-	additionalPackage := Preparator{
-		Prepare: replace,
+	changePackagePreparator := Preparator{
+		Prepare: changePackage,
 		Args:    []interface{}{filePath, packagePattern, importStringPattern},
 	}
-	return &[]Preparator{publicClassModification, additionalPackage}
+	removePackagePreparator := Preparator{
+		Prepare: removePackage,
+		Args:    []interface{}{filePath, packagePattern, newLinePattern},
+	}
+	unitTestFileNameChanger := Preparator{
+		Prepare: changeJavaTestFileName,
+		Args:    []interface{}{filePath},
+	}
+	return &[]Preparator{removePublicClassPreparator, changePackagePreparator, removePackagePreparator, unitTestFileNameChanger}
+}
+
+//changePackage changes the 'package' to 'import' and the last directory in the package value to '*'
+func changePackage(args ...interface{}) error {

Review comment:
       I worry that several of these methods take `args....` but in fact they expect fixed arguments. Could we make them have fixed arguments so that they're more understabdable?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org