pavel-avilov commented on a change in pull request #16172:
URL: https://github.com/apache/beam/pull/16172#discussion_r766673556



##########
File path: playground/backend/internal/code_processing/code_processing.go
##########
@@ -95,7 +95,7 @@ func Process(ctx context.Context, cacheService cache.Cache, 
lc *fs_tool.LifeCycl
        // Prepare
        logger.Infof("%s: Prepare() ...\n", pipelineId)
        prepareFunc := executor.Prepare()
-       go prepareFunc(successChannel, errorChannel)
+       go prepareFunc(successChannel, errorChannel, &validationResults, 
lc.GetAbsoluteSourceFilePath())

Review comment:
       Done

##########
File path: playground/backend/internal/preparators/java_preparators.go
##########
@@ -37,15 +39,55 @@ const (
 
 // GetJavaPreparators returns preparation methods that should be applied to 
Java code
 func GetJavaPreparators(filePath string) *[]Preparator {
-       publicClassModification := Preparator{
-               Prepare: replace,
+       removePublicClassPreparator := Preparator{
+               Prepare: removePublicClass,
                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},
+       }
+       return &[]Preparator{removePublicClassPreparator, 
changePackagePreparator, removePackagePreparator}
+}
+
+//removePublicClass changes the 'public class' in the code to 'class'
+func removePublicClass(args ...interface{}) error {
+       err := replace(args...)
+       if err != nil {
+               return err
+       }
+       return nil
+}
+
+//changePackage changes the 'package' to 'import' and the last directory in 
the package value to '*'
+func changePackage(args ...interface{}) error {
+       valRes := args[3].(*sync.Map)
+       isKata, ok := valRes.Load(validators.KatasValidatorName)
+       if ok && isKata.(bool) {
+               return nil
+       }
+       err := replace(args...)
+       if err != nil {
+               return err
+       }
+       return nil
+}
+
+//removePackage remove the package line in the katas.
+func removePackage(args ...interface{}) error {
+       valRes := args[3].(*sync.Map)
+       isKata, ok := valRes.Load(validators.KatasValidatorName)
+       if ok && isKata.(bool) {
+               err := replace(args...)
+               if err != nil {
+                       return err
+               }

Review comment:
       Done

##########
File path: playground/backend/internal/preparators/java_preparators.go
##########
@@ -37,15 +39,55 @@ const (
 
 // GetJavaPreparators returns preparation methods that should be applied to 
Java code
 func GetJavaPreparators(filePath string) *[]Preparator {
-       publicClassModification := Preparator{
-               Prepare: replace,
+       removePublicClassPreparator := Preparator{
+               Prepare: removePublicClass,
                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},
+       }
+       return &[]Preparator{removePublicClassPreparator, 
changePackagePreparator, removePackagePreparator}
+}
+
+//removePublicClass changes the 'public class' in the code to 'class'
+func removePublicClass(args ...interface{}) error {
+       err := replace(args...)
+       if err != nil {
+               return err
+       }
+       return nil
+}
+
+//changePackage changes the 'package' to 'import' and the last directory in 
the package value to '*'
+func changePackage(args ...interface{}) error {
+       valRes := args[3].(*sync.Map)
+       isKata, ok := valRes.Load(validators.KatasValidatorName)
+       if ok && isKata.(bool) {
+               return nil
+       }
+       err := replace(args...)
+       if err != nil {
+               return err
+       }
+       return nil

Review comment:
       Done




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to