Repository: uber/piranha (language: python)

Issue:
Delete associated comment after deleting a statement/field/method/enum entry ... 
Add an option that deletes comments at the line of deletion / above the line of deletion . In the below example, we can see a number of ways in which a comment can be "associated" to a class field. 
```
class SomeClass {
     // Id of the person 
     private int Id;

     private String name;     // Name of the person 
     
    // Address of 
    // the person 
     private String address; 


      /* Zipcode of 
      the person 
     */
     private String zipcode; 

}
```

This feature is required across all languages. 


Discussion / hints:

Fix patch:
diff --git a/polyglot/piranha/demo/swift/Sample.swift b/polyglot/piranha/demo/swift/Sample.swift
index c8b761485..67d023db6 100644
--- a/polyglot/piranha/demo/swift/Sample.swift
+++ b/polyglot/piranha/demo/swift/Sample.swift
@@ -24,7 +24,8 @@ enum ExperimentNamesSwift: String, ExperimentKeying {
 
     //comment4
     case test_experiment_suffix //comment5
-    case test_second_experiment
+    // comment 11
+    case test_second_experiment 
     
     case random_flag //comment6
     case test_experiment1 // comment7
diff --git a/polyglot/piranha/demo/swift/configurations/piranha_arguments.toml b/polyglot/piranha/demo/swift/configurations/piranha_arguments.toml
index 716196406..c6af804d3 100644
--- a/polyglot/piranha/demo/swift/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/demo/swift/configurations/piranha_arguments.toml
@@ -12,4 +12,5 @@
 language = ["swift"]
 substitutions = [
     ["stale_flag_name", "test_second_experiment"],
-]
\ No newline at end of file
+]
+cleanup_comments=true
diff --git a/polyglot/piranha/src/lib.rs b/polyglot/piranha/src/lib.rs
index e2da0b3c4..046c46086 100644
--- a/polyglot/piranha/src/lib.rs
+++ b/polyglot/piranha/src/lib.rs
@@ -33,7 +33,7 @@ use regex::Regex;
 use tree_sitter::{Parser, Range};
 
 use crate::{
-  models::rule_store::RuleStore,
+  models::rule_store::{RuleStore},
   utilities::{read_file, tree_sitter_utilities::get_replace_range},
 };
 
@@ -361,6 +361,7 @@ impl FlagCleaner {
               content,
               &self.rule_store.default_substitutions(),
               path.as_path(),
+              self.rule_store.piranha_args(),
             )
           })
           // Apply the rules to this file
diff --git a/polyglot/piranha/src/models/constraint.rs b/polyglot/piranha/src/models/constraint.rs
index ceda9dffc..cab4997a1 100644
--- a/polyglot/piranha/src/models/constraint.rs
+++ b/polyglot/piranha/src/models/constraint.rs
@@ -1,3 +1,16 @@
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
 use std::collections::HashMap;
 
 use serde_derive::Deserialize;
diff --git a/polyglot/piranha/src/models/edit.rs b/polyglot/piranha/src/models/edit.rs
index bf19fe2f7..945510178 100644
--- a/polyglot/piranha/src/models/edit.rs
+++ b/polyglot/piranha/src/models/edit.rs
@@ -1,3 +1,16 @@
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
 use std::collections::HashMap;
 
 use serde_derive::Serialize;
diff --git a/polyglot/piranha/src/models/piranha_arguments.rs b/polyglot/piranha/src/models/piranha_arguments.rs
index 400fce482..f83ad5110 100644
--- a/polyglot/piranha/src/models/piranha_arguments.rs
+++ b/polyglot/piranha/src/models/piranha_arguments.rs
@@ -65,6 +65,13 @@ pub struct PiranhaArguments {
   /// parent scoped rules
   #[getset(get = "pub")]
   number_of_ancestors_in_parent_scope: u8,
+  /// The number of lines to consider for cleaning up the comments 
+  #[getset(get = "pub")]
+  cleanup_comments_buffer: usize,
+  /// The AST Kinds for which comments should be deleted
+  #[getset(get = "pub")]
+  cleanup_comments: bool,
+  
 }
 
 impl PiranhaArguments {
@@ -103,6 +110,15 @@ impl PiranhaArguments {
     if let Some(v) = piranha_args_from_config.global_tag_prefix() {
       args_builder.global_tag_prefix(v);
     }
+
+    if let Some(buffer_size) = piranha_args_from_config.cleanup_comments_buffer(){
+      args_builder.cleanup_comments_buffer(buffer_size);
+    }
+
+    if let Some(ast_kinds) = piranha_args_from_config.cleanup_comments(){
+      args_builder.cleanup_comments(ast_kinds);
+    }
+
     args_builder.build().unwrap()
   }
 }
@@ -124,6 +140,8 @@ impl Default for PiranhaArguments {
       /// @GLOBAL_TAG.class_name
       global_tag_prefix: "GLOBAL_TAG.".to_string(),
       number_of_ancestors_in_parent_scope: 4,
+      cleanup_comments_buffer: 2,
+      cleanup_comments: false,
     }
   }
 }
diff --git a/polyglot/piranha/src/models/piranha_config.rs b/polyglot/piranha/src/models/piranha_config.rs
index 49e267c12..2e67c3adf 100644
--- a/polyglot/piranha/src/models/piranha_config.rs
+++ b/polyglot/piranha/src/models/piranha_config.rs
@@ -1,5 +1,3 @@
-use std::collections::HashMap;
-
 /*
 Copyright (c) 2022 Uber Technologies, Inc.
 
@@ -12,7 +10,7 @@ Copyright (c) 2022 Uber Technologies, Inc.
  express or implied. See the License for the specific language governing permissions and
  limitations under the License.
 */
-
+use std::collections::HashMap;
 use serde_derive::Deserialize;
 
 /// Captures the Piranha arguments by from the file at `path_to_feature_flag_rules`.
@@ -23,6 +21,8 @@ pub(crate) struct PiranhaConfiguration {
   delete_file_if_empty: Option<bool>,
   delete_consecutive_new_lines: Option<bool>,
   global_tag_prefix: Option<String>,
+  cleanup_comments_buffer: Option<usize>,
+  cleanup_comments: Option<bool>
 }
 
 impl PiranhaConfiguration {
@@ -49,4 +49,12 @@ impl PiranhaConfiguration {
   pub(crate) fn global_tag_prefix(&self) -> Option<String> {
     self.global_tag_prefix.clone()
   }
+
+    pub(crate) fn cleanup_comments_buffer(&self) -> Option<usize> {
+        self.cleanup_comments_buffer
+    }
+
+    pub(crate) fn cleanup_comments(&self) -> Option<bool> {
+        self.cleanup_comments
+    }
 }
diff --git a/polyglot/piranha/src/models/piranha_output.rs b/polyglot/piranha/src/models/piranha_output.rs
index 09f9dda7c..ff3dfa017 100644
--- a/polyglot/piranha/src/models/piranha_output.rs
+++ b/polyglot/piranha/src/models/piranha_output.rs
@@ -1,3 +1,17 @@
+
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
 use std::path::PathBuf;
 
 use itertools::Itertools;
diff --git a/polyglot/piranha/src/models/rule_store.rs b/polyglot/piranha/src/models/rule_store.rs
index 81cb3a291..1043c4297 100644
--- a/polyglot/piranha/src/models/rule_store.rs
+++ b/polyglot/piranha/src/models/rule_store.rs
@@ -175,6 +175,10 @@ impl RuleStore {
       .collect();
     let _ = &self.global_tags.extend(global_substitutions);
   }
+
+  pub(crate) fn piranha_args(&self) -> &PiranhaArguments {
+      &self.piranha_args
+  }
 }
 
 #[cfg(test)]
diff --git a/polyglot/piranha/src/models/source_code_unit.rs b/polyglot/piranha/src/models/source_code_unit.rs
index 36af19760..6e4273a26 100644
--- a/polyglot/piranha/src/models/source_code_unit.rs
+++ b/polyglot/piranha/src/models/source_code_unit.rs
@@ -1,14 +1,31 @@
+
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
 use std::{
   collections::HashMap,
   fs,
   path::{Path, PathBuf},
 };
 
+use log::info;
 use regex::Regex;
 use tree_sitter::{InputEdit, Node, Parser, Range, Tree};
 use tree_sitter_traversal::{traverse, Order};
 
-use crate::utilities::{eq_without_whitespace, tree_sitter_utilities::get_tree_sitter_edit};
+use crate::utilities::{
+  eq_without_whitespace,
+  tree_sitter_utilities::{get_tree_sitter_edit, TreeSitterHelpers},
+};
 
 use super::{
   edit::Edit, matches::Match, piranha_arguments::PiranhaArguments, rule_store::RuleStore,
@@ -30,11 +47,14 @@ pub(crate) struct SourceCodeUnit {
   rewrites: Vec<Edit>,
   // Matches for the read_only rules in this source code unit
   matches: Vec<(String, Match)>,
+  // Piranha Arguments passed by the user
+  piranha_arguments: PiranhaArguments,
 }
 
 impl SourceCodeUnit {
   pub(crate) fn new(
     parser: &mut Parser, code: String, substitutions: &HashMap<String, String>, path: &Path,
+    piranha_arguments: &PiranhaArguments,
   ) -> Self {
     let ast = parser.parse(&code, None).expect("Could not parse code");
     Self {
@@ -44,6 +64,7 @@ impl SourceCodeUnit {
       path: path.to_path_buf(),
       rewrites: Vec::new(),
       matches: Vec::new(),
+      piranha_arguments: piranha_arguments.clone(),
     }
   }
 
@@ -72,12 +93,73 @@ impl SourceCodeUnit {
 
   pub(crate) fn apply_edit(&mut self, edit: &Edit, parser: &mut Parser) -> InputEdit {
     // Get the tree_sitter's input edit representation
-    self._apply_edit(
+    let mut applied_edit = self._apply_edit(
       edit.replacement_range(),
       edit.replacement_string(),
       parser,
       true,
-    )
+    );
+    // Check if the edit kind is "DELETE something"
+    if self.piranha_arguments.cleanup_comments().clone() && edit.replacement_string().is_empty() {
+      let deleted_at = edit.replacement_range().start_point.row;
+      if let Some(comment_range) = self.get_comment_at_line(
+        deleted_at,
+        self.piranha_arguments.cleanup_comments_buffer().clone(),
+        edit.replacement_range().start_byte,
+      ) {
+        info!("Deleting an associated comment");
+        applied_edit = self._apply_edit(comment_range, "", parser, false);
+      }
+    }
+    return applied_edit;
+  }
+
+  /// This function reports the range of the comment associated to the deleted element.
+  ///
+  /// # Arguments:
+  /// * row : The row number where the deleted element started
+  /// * buffer: Number of lines that we want to look up to find associated comment
+  ///
+  /// # Algorithm :
+  /// Get all the nodes that either start and end at [row]
+  /// If **all** nodes are comments
+  /// * return the range of the comment
+  /// If the [row] has no node that either starts/ends there:
+  /// * recursively call this method for [row] -1 (until buffer is positive)
+  fn get_comment_at_line(&mut self, row: usize, buffer: usize, start_byte: usize) -> Option<Range> {
+    // Get all nodes that start or end on `updated_row`.
+    let mut relevant_nodes_found = false;
+    let mut relevant_nodes_are_comments = true;
+    let mut comment_range = None;
+    // Since the previous edit was a delete, the start and end of the replacement range is [start_byte].
+    let node = self.ast.root_node()
+      .descendant_for_byte_range(start_byte, start_byte)
+      .unwrap_or(self.ast.root_node());
+
+    for node in traverse(node.walk(), Order::Post) {
+      if node.start_position().row == row || node.end_position().row == row {
+        relevant_nodes_found = true;
+        let is_comment: bool = self
+          .piranha_arguments
+          .language_name()
+          .is_comment(node.kind());
+        relevant_nodes_are_comments = relevant_nodes_are_comments && is_comment;
+        if is_comment {
+          comment_range = Some(node.range());
+        }
+      }
+    }
+
+    if relevant_nodes_found {
+      if relevant_nodes_are_comments {
+        return comment_range;
+      }
+    } else if buffer > 0 {
+      // We pass [start_byte] itself, because we know that parent of the current row is the parent of the above row too.
+      // If that's not the case, its okay, because we will not find any comments in these scenarios.
+      return self.get_comment_at_line(row - 1, buffer - 1, start_byte);
+    }
+    return None;
   }
 
   /// Applies an edit to the source code unit
diff --git a/polyglot/piranha/src/utilities/tree_sitter_utilities.rs b/polyglot/piranha/src/utilities/tree_sitter_utilities.rs
index ea1eb74f3..22b5838e8 100644
--- a/polyglot/piranha/src/utilities/tree_sitter_utilities.rs
+++ b/polyglot/piranha/src/utilities/tree_sitter_utilities.rs
@@ -32,6 +32,8 @@ pub(crate) trait TreeSitterHelpers {
   fn get_language(&self) -> Language;
   /// Compiles query string to `tree_sitter::Query`
   fn create_query(&self, language: Language) -> Query;
+  /// Determines if the given node kind is a comment for the respective language (`self`)
+  fn is_comment(&self, kind: &str) -> bool ;
 }
 
 impl TreeSitterHelpers for String {
@@ -52,6 +54,15 @@ impl TreeSitterHelpers for String {
       _ => panic!("Language not supported"),
     }
   }
+
+  fn is_comment(&self, kind: &str) -> bool {
+    match self.as_str() {
+      "java" => kind.eq("line_comment") || kind.eq("block_comment"),
+      "kt" => kind.eq("comment"),
+      "swift" => kind.eq("comment") || kind.eq("multiline_comment"),
+      _ => false,
+    }
+  }
 }
 
 #[rustfmt::skip]


Test patch:
diff --git a/polyglot/piranha/src/models/unit_tests/rule_test.rs b/polyglot/piranha/src/models/unit_tests/rule_test.rs
index fde09e967..fc26e4689 100644
--- a/polyglot/piranha/src/models/unit_tests/rule_test.rs
+++ b/polyglot/piranha/src/models/unit_tests/rule_test.rs
@@ -1,3 +1,15 @@
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
 use std::collections::HashSet;
 
 use {
@@ -78,6 +90,7 @@ fn test_get_edit_positive_recursive() {
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    rule_store.piranha_args()
   );
   let node = source_code_unit.root_node();
   let matches = rule.get_matches(&source_code_unit, &mut rule_store, node, true);
@@ -124,6 +137,7 @@ fn test_get_edit_negative_recursive() {
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    rule_store.piranha_args()
   );
   let node = source_code_unit.root_node();
   let matches = rule.get_matches(&source_code_unit, &mut rule_store, node, true);
@@ -163,6 +177,7 @@ fn test_get_edit_for_context_positive() {
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    rule_store.piranha_args()
   );
   let edit = Rule::get_edit_for_context(
     &source_code_unit,
@@ -207,6 +222,7 @@ fn test_get_edit_for_context_negative() {
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    rule_store.piranha_args()
   );
   let edit = Rule::get_edit_for_context(
     &source_code_unit,
diff --git a/polyglot/piranha/src/models/unit_tests/scopes_test.rs b/polyglot/piranha/src/models/unit_tests/scopes_test.rs
index 74366492c..28fd3303f 100644
--- a/polyglot/piranha/src/models/unit_tests/scopes_test.rs
+++ b/polyglot/piranha/src/models/unit_tests/scopes_test.rs
@@ -1,3 +1,15 @@
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
 use {
   super::{ScopeGenerator, ScopeQueryGenerator},
   crate::{
@@ -64,6 +76,7 @@ fn test_get_scope_query_positive() {
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    rule_store.piranha_args()
   );
 
   let scope_query_method = ScopeGenerator::get_scope_query(
@@ -157,6 +170,7 @@ fn test_get_scope_query_negative() {
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    rule_store.piranha_args()
   );
 
   let _ = ScopeGenerator::get_scope_query(source_code_unit, "Method", 133, 134, &mut rule_store);
diff --git a/polyglot/piranha/src/models/unit_tests/source_code_unit_test.rs b/polyglot/piranha/src/models/unit_tests/source_code_unit_test.rs
index 1c2b45c9f..9f8b7cfdd 100644
--- a/polyglot/piranha/src/models/unit_tests/source_code_unit_test.rs
+++ b/polyglot/piranha/src/models/unit_tests/source_code_unit_test.rs
@@ -1,3 +1,15 @@
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
 use std::{
   fs::{self},
   io,
@@ -20,12 +32,13 @@ use {
 };
 
 impl SourceCodeUnit {
-  pub(crate) fn dummy_unit(content: &str, parser: &mut Parser) -> Self {
+  pub(crate) fn default(content: &str, parser: &mut Parser, language_name: String) -> Self {
     SourceCodeUnit::new(
       parser,
       content.to_string(),
       &HashMap::new(),
       PathBuf::new().as_path(),
+      &PiranhaArgumentsBuilder::default().language_name(language_name).build().unwrap()
     )
   }
 }
@@ -60,14 +73,15 @@ fn test_apply_edit_positive() {
         }
       }
     }";
+  
+  let language_name = String::from("java");
+  let mut parser = get_parser(language_name.to_string());
 
-  let mut parser = get_parser(String::from("java"));
-
-  let mut source_code_unit = SourceCodeUnit::dummy_unit(source_code, &mut parser);
+  let mut source_code_unit = SourceCodeUnit::default(source_code, &mut parser, language_name);
 
   let _ = source_code_unit.apply_edit(
     &Edit::dummy_edit(range(49, 78, 3, 9, 3, 38), String::new()),
-    &mut parser,
+    &mut parser
   );
   assert!(eq_without_whitespace(
     &source_code.replace("boolean isFlagTreated = true;", ""),
@@ -88,13 +102,14 @@ fn test_apply_edit_negative() {
         }
       }
     }";
-
-  let mut parser = get_parser(String::from("java"));
-  let mut source_code_unit = SourceCodeUnit::dummy_unit(source_code, &mut parser);
+  
+  let language_name = String::from("java");
+  let mut parser = get_parser(language_name.to_string());
+  let mut source_code_unit = SourceCodeUnit::default(source_code, &mut parser, language_name);
 
   let _ = source_code_unit.apply_edit(
     &Edit::dummy_edit(range(1000, 2000, 0, 0, 0, 0), String::new()),
-    &mut parser,
+    &mut parser
   );
 }
 
@@ -109,13 +124,14 @@ fn test_apply_edit_comma_handling_via_grammar() {
       }
     }";
 
-  let mut parser = get_parser(String::from("java"));
+  let language_name = String::from("java");
+  let mut parser = get_parser(language_name.to_string());
 
-  let mut source_code_unit = SourceCodeUnit::dummy_unit(source_code, &mut parser);
+  let mut source_code_unit = SourceCodeUnit::default(source_code, &mut parser, language_name);
 
   let _ = source_code_unit.apply_edit(
     &Edit::dummy_edit(range(37, 47, 2, 26, 2, 36), String::new()),
-    &mut parser,
+    &mut parser
   );
   assert!(eq_without_whitespace(
     &source_code.replace("\"NullAway\",", ""),
@@ -135,13 +151,16 @@ fn test_apply_edit_comma_handling_via_regex() {
   }
 }";
 
-  let mut parser = get_parser(String::from("swift"));
 
-  let mut source_code_unit = SourceCodeUnit::dummy_unit(source_code, &mut parser);
+  let language_name = String::from("swift");
+
+  let mut parser = get_parser(language_name.to_string());
+
+  let mut source_code_unit = SourceCodeUnit::default(source_code, &mut parser, language_name);
 
   let _ = source_code_unit.apply_edit(
     &Edit::dummy_edit(range(59, 75, 3, 23, 3, 41), String::new()),
-    &mut parser,
+    &mut parser
   );
   assert!(eq_without_whitespace(
     &source_code.replace("name: \"BMX Bike\",", ""),
@@ -152,15 +171,18 @@ fn execute_persist_in_temp_folder(
   source_code: &str, args: &PiranhaArguments,
   check_predicate: &dyn Fn(&TempDir) -> Result<bool, io::Error>,
 ) -> Result<bool, io::Error> {
-  let mut parser = get_parser(String::from("java"));
+  let language_name = String::from("java");
+  let mut parser = get_parser(language_name.to_string());
   let tmp_dir = TempDir::new("example")?;
   let file_path = &tmp_dir.path().join("Sample1.java");
   _ = fs::write(&file_path.as_path(), source_code);
+  let piranha_args = PiranhaArgumentsBuilder::default().language_name(language_name).build().unwrap();
   let source_code_unit = SourceCodeUnit::new(
     &mut parser,
     source_code.to_string(),
     &HashMap::new(),
     file_path.as_path(),
+    &piranha_args
   );
   source_code_unit.persist(args);
   check_predicate(&tmp_dir)
diff --git a/polyglot/piranha/src/utilities/unit_tests/tree_sitter_utilities_test.rs b/polyglot/piranha/src/utilities/unit_tests/tree_sitter_utilities_test.rs
index 54b8050ea..3d442fad7 100644
--- a/polyglot/piranha/src/utilities/unit_tests/tree_sitter_utilities_test.rs
+++ b/polyglot/piranha/src/utilities/unit_tests/tree_sitter_utilities_test.rs
@@ -1,3 +1,16 @@
+
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
 use std::{
   collections::{HashMap, HashSet},
   path::PathBuf,
@@ -5,6 +18,8 @@ use std::{
 
 use tree_sitter::Query;
 
+use crate::models::piranha_arguments::{PiranhaArgumentsBuilder};
+
 use {
   super::{get_parser, substitute_tags, PiranhaHelpers, TreeSitterHelpers},
   crate::models::{
@@ -151,14 +166,15 @@ fn test_satisfies_constraints_positive() {
       }";
 
   let mut rule_store = RuleStore::dummy();
-
-  let mut parser = get_parser(String::from("java"));
-
+  let language_name = String::from("java");
+  let mut parser = get_parser(language_name.to_string());
+  let piranha_args = PiranhaArgumentsBuilder::default().language_name(language_name).build().unwrap();
   let source_code_unit = SourceCodeUnit::new(
     &mut parser,
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    &piranha_args
   );
 
   let node = &source_code_unit
@@ -214,14 +230,15 @@ fn test_satisfies_constraints_negative() {
       }";
 
   let mut rule_store = RuleStore::dummy();
-
-  let mut parser = get_parser(String::from("java"));
-
+  let language_name = String::from("java");
+  let mut parser = get_parser(language_name.to_string());
+  let piranha_arguments = &PiranhaArgumentsBuilder::default().language_name(language_name).build().unwrap();
   let source_code_unit = SourceCodeUnit::new(
     &mut parser,
     source_code.to_string(),
     &HashMap::new(),
     PathBuf::new().as_path(),
+    piranha_arguments
   );
 
   let node = &source_code_unit
diff --git a/polyglot/piranha/src/utilities/unit_tests/utilities_test.rs b/polyglot/piranha/src/utilities/unit_tests/utilities_test.rs
index c82566ffd..fe94ad556 100644
--- a/polyglot/piranha/src/utilities/unit_tests/utilities_test.rs
+++ b/polyglot/piranha/src/utilities/unit_tests/utilities_test.rs
@@ -1,3 +1,17 @@
+
+/*
+Copyright (c) 2022 Uber Technologies, Inc.
+
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+ <p>http://www.apache.org/licenses/LICENSE-2.0
+
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied. See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
 use crate::utilities::find_file;
 use serde_derive::Deserialize;
 use std::path::PathBuf;
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_1/control/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/java/feature_flag_system_1/control/configurations/piranha_arguments.toml
index 53e711d13..f2f640d92 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_1/control/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_1/control/configurations/piranha_arguments.toml
@@ -15,4 +15,5 @@ substitutions = [
     ["treated", "false"],
     ["treated_complement", "true"],
     ["namespace", "some_long_name"]
-]
\ No newline at end of file
+]
+cleanup_comments=true
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_1/control/input/XPFlagCleanerPositiveCases.java b/polyglot/piranha/test-resources/java/feature_flag_system_1/control/input/XPFlagCleanerPositiveCases.java
index 5a8dd308f..ab7bf90f3 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_1/control/input/XPFlagCleanerPositiveCases.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_1/control/input/XPFlagCleanerPositiveCases.java
@@ -24,12 +24,13 @@ class XPFlagCleanerPositiveCases {
 
   enum TestExperimentName {
     SOME_FLAG,
+    // Some stale enum
     STALE_FLAG
   }
 
   enum AnotherTestExperimentName {
     @Autorollout
-    STALE_FLAG,
+    STALE_FLAG, // Some stale enum
     SOME_OTHER_FLAG
   }
 
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/configurations/piranha_arguments.toml
index c268d5169..179cfa2ed 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/configurations/piranha_arguments.toml
@@ -15,4 +15,5 @@ substitutions = [
     ["treated", "true"],
     ["treated_complement", "false"],
     ["namespace", "some_long_name"]
-]
\ No newline at end of file
+]
+cleanup_comments= false
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/expected/XPFlagCleanerPositiveCases.java b/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/expected/XPFlagCleanerPositiveCases.java
index 88b7a969b..61bd5e606 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/expected/XPFlagCleanerPositiveCases.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/expected/XPFlagCleanerPositiveCases.java
@@ -24,9 +24,11 @@ class XPFlagCleanerPositiveCases {
 
   enum TestExperimentName {
     SOME_FLAG,
+    // Some stale enum
   }
 
   enum AnotherTestExperimentName {
+    // Some stale enum
     SOME_OTHER_FLAG
   }
 
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/input/XPFlagCleanerPositiveCases.java b/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/input/XPFlagCleanerPositiveCases.java
index 5a8dd308f..ab7bf90f3 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/input/XPFlagCleanerPositiveCases.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_1/treated/input/XPFlagCleanerPositiveCases.java
@@ -24,12 +24,13 @@ class XPFlagCleanerPositiveCases {
 
   enum TestExperimentName {
     SOME_FLAG,
+    // Some stale enum
     STALE_FLAG
   }
 
   enum AnotherTestExperimentName {
     @Autorollout
-    STALE_FLAG,
+    STALE_FLAG, // Some stale enum
     SOME_OTHER_FLAG
   }
 
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_2/control/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/java/feature_flag_system_2/control/configurations/piranha_arguments.toml
index 53e711d13..f2f640d92 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_2/control/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_2/control/configurations/piranha_arguments.toml
@@ -15,4 +15,5 @@ substitutions = [
     ["treated", "false"],
     ["treated_complement", "true"],
     ["namespace", "some_long_name"]
-]
\ No newline at end of file
+]
+cleanup_comments=true
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.java b/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.java
index 4e01a502a..a3d9f0895 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.java
@@ -21,7 +21,7 @@ class XPFlagCleanerPositiveCases {
   public void conditional_contains_stale_flag() {}
 
   public void conditional_with_else_contains_stale_flag() {
-
+    
     System.out.println("Hi world");
   }
 
@@ -70,7 +70,6 @@ public void conditional_with_else_contains_stale_flag_ftbool(int a) {
 
   public void conditional_with_else_contains_stale_flag_tbool_reassigned_ftbool(
       int a, bool abc, int z) {
-    // Currently if there is another assignment, variable will not be inlined.
 
     System.out.println("Hello World");
   }
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPMethodChainCases.java b/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPMethodChainCases.java
index 642b75a97..b544ce9a6 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPMethodChainCases.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_2/control/expected/XPMethodChainCases.java
@@ -25,7 +25,7 @@ public void testDontMatchNonInstanceNested() {
 
   public static void foobar(Parameter cp) {
     SomeParam sp = SomeParam.create(cp);
-    // Matches API
+
 
     // Matches API
     System.out.println("!!!");
@@ -57,7 +57,7 @@ public static void foobar(Parameter cp) {
     }
 
     System.out.println("done!");
-    // Matches API
+
 
     // Do not match API
     cp.put(sp.otherFlag(), true);
@@ -65,9 +65,9 @@ public static void foobar(Parameter cp) {
   }
 
   class TestMethodChainTest {
-    // Matches annotation
 
-    // Matches annotation
+
+
 
     public void testSomethingControl() {
       System.out.println();
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/configurations/piranha_arguments.toml
index c268d5169..62a4eca54 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/configurations/piranha_arguments.toml
@@ -15,4 +15,5 @@ substitutions = [
     ["treated", "true"],
     ["treated_complement", "false"],
     ["namespace", "some_long_name"]
-]
\ No newline at end of file
+]
+cleanup_comments=true
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.java b/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.java
index 41eec7973..1a53ba26c 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.java
@@ -67,7 +67,6 @@ public void conditional_with_else_contains_stale_flag_ftbool(int a) {
 
   public void conditional_with_else_contains_stale_flag_tbool_reassigned_ftbool(
       int a, bool abc, int z) {
-    // Currently if there is another assignment, variable will not be inlined.
     System.out.println("Hi world");
   }
 
diff --git a/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPMethodChainCases.java b/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPMethodChainCases.java
index 94fcd2a68..df1cca568 100644
--- a/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPMethodChainCases.java
+++ b/polyglot/piranha/test-resources/java/feature_flag_system_2/treated/expected/XPMethodChainCases.java
@@ -27,7 +27,7 @@ public static void foobar(Parameter cp) {
     SomeParam sp = SomeParam.create(cp);
     // Matches API
     System.out.println("!");
-    // Matches API
+
 
     // Does not match API
     if (sp.otherFlag().getCachedValue()) {
@@ -57,7 +57,7 @@ public static void foobar(Parameter cp) {
     }
 
     System.out.println("done!");
-    // Matches API
+    
 
     // Do not match API
     cp.put(sp.otherFlag(), true);
@@ -65,12 +65,12 @@ public static void foobar(Parameter cp) {
   }
 
   class TestMethodChainTest {
-    // Matches annotation
+    
     public void testSomethingTreated() {
       System.out.println();
     }
 
-    // Matches annotation
+    
 
     // Does not match annotation
     @ParameterValue(ns = "some_long_name", key = "other_flag", val = "false")
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_1/control/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/kt/feature_flag_system_1/control/configurations/piranha_arguments.toml
index 5adbe1637..09a520989 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_1/control/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_1/control/configurations/piranha_arguments.toml
@@ -14,4 +14,4 @@ substitutions = [
     ["stale_flag_name", "STALE_FLAG"],
     ["treated", "false"],
     ["treated_complement", "true"]
-]
\ No newline at end of file
+]
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/configurations/piranha_arguments.toml
index 493c51e49..4f4f9153e 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/configurations/piranha_arguments.toml
@@ -15,4 +15,5 @@ substitutions = [
     ["treated", "false"],
     ["treated_complement", "true"],
     ["namespace", "some_long_name"]
-]
\ No newline at end of file
+]
+cleanup_comments=true
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.kt b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.kt
index 04a8c7cc0..86608e756 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.kt
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPFlagCleanerInterfaceMethod.kt
@@ -70,12 +70,12 @@ internal class XPFlagCleanerPositiveCases {
     }
 
     fun conditional_with_else_contains_stale_flag_tbool_reassigned_ftbool(a: Int, z: Int) {
-        // Currently if there is another assignment, variable will not be inlined.
+   
         println("Hello World")
     }
 
     fun conditional_with_else_contains_stale_flag_tbool_reassigned_ftbool_1(a: Int, z: Int) {
-        // Currently if there is another assignment, variable will not be inlined.
+     
         println("Hello World")
     }
 
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPMethodChainCases.kt b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPMethodChainCases.kt
index 4827101cc..fe438fe48 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPMethodChainCases.kt
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/expected/XPMethodChainCases.kt
@@ -29,7 +29,7 @@ internal class XPMethodChainCases {
     companion object {
         fun foobar(cp: Parameter) {
             val sp = SomeParameter.create()
-            // Matches API
+
             // Matches API
             println("!!!")
             // Does not match API
@@ -60,6 +60,7 @@ internal class XPMethodChainCases {
             }
             println("done!")
             // Matches API
+            if (someCond()) {}
             // Do not match API
             cp.put(sp.isOtherFlag(), true)
             cp.put(sp.isOtherFlag(), false)
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/input/XPMethodChainCases.kt b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/input/XPMethodChainCases.kt
index 3a1a867b1..ca05f4b2d 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/input/XPMethodChainCases.kt
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/control/input/XPMethodChainCases.kt
@@ -67,7 +67,7 @@ internal class XPMethodChainCases {
             }
             println("done!")
             // Matches API
-            cp.put(sp.isStaleFeature(), true)
+            if (someCond()) {cp.put(sp.isStaleFeature(), true)}
             cp.put(sp.isStaleFeature(), false)
             // Do not match API
             cp.put(sp.isOtherFlag(), true)
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/configurations/piranha_arguments.toml
index 4826f4f5c..ebed19909 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/configurations/piranha_arguments.toml
@@ -15,4 +15,5 @@ substitutions = [
     ["treated", "true"],
     ["treated_complement", "false"],
     ["namespace", "some_long_name"]
-]
\ No newline at end of file
+]
+cleanup_comments=true
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.kt b/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.kt
index f62f0812e..e27a71d29 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.kt
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPFlagCleanerInterfaceMethod.kt
@@ -64,12 +64,12 @@ internal class XPFlagCleanerPositiveCases {
     }
 
     fun conditional_with_else_contains_stale_flag_tbool_reassigned_ftbool(a: Int, z: Int) {
-        // Currently if there is another assignment, variable will not be inlined.
+       
         println("Hi world")
     }
 
     fun conditional_with_else_contains_stale_flag_tbool_reassigned_ftbool_1(a: Int, z: Int) {
-        // Currently if there is another assignment, variable will not be inlined.
+       
         println("Hi world")
     }
 
diff --git a/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPMethodChainCases.kt b/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPMethodChainCases.kt
index 39f7ea590..ecc36ff9d 100644
--- a/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPMethodChainCases.kt
+++ b/polyglot/piranha/test-resources/kt/feature_flag_system_2/treated/expected/XPMethodChainCases.kt
@@ -31,7 +31,7 @@ internal class XPMethodChainCases {
             val sp = SomeParameter.create()
             // Matches API
             println("!")
-            // Matches API
+
             // Does not match API
             if (sp.isOtherFlag().cachedValue) {
                 println("!!!")
@@ -59,7 +59,7 @@ internal class XPMethodChainCases {
                 print("!!")
             }
             println("done!")
-            // Matches API
+
             // Do not match API
             cp.put(sp.isOtherFlag(), true)
             cp.put(sp.isOtherFlag(), false)
diff --git a/polyglot/piranha/test-resources/swift/cascade_file_delete/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/swift/cascade_file_delete/configurations/piranha_arguments.toml
index e50dc64ef..7df91b243 100644
--- a/polyglot/piranha/test-resources/swift/cascade_file_delete/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/swift/cascade_file_delete/configurations/piranha_arguments.toml
@@ -13,3 +13,4 @@ language = ["swift"]
 substitutions = [
     ["stale_flag_name", "Premium-Icon"],
 ]
+cleanup_comments=true
diff --git a/polyglot/piranha/test-resources/swift/cascade_file_delete/input/Experiment.swift b/polyglot/piranha/test-resources/swift/cascade_file_delete/input/Experiment.swift
index e702a23e1..0bbc501e7 100644
--- a/polyglot/piranha/test-resources/swift/cascade_file_delete/input/Experiment.swift
+++ b/polyglot/piranha/test-resources/swift/cascade_file_delete/input/Experiment.swift
@@ -16,7 +16,7 @@ import Experiment
 
 public enum SomePluginSwitch: PluginSwitch {
     case defaultIcon
-    case premiumIcon
+    case premiumIcon // premium icon
     case defaultTitle
     case premiumTitle
 
diff --git a/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/configurations/piranha_arguments.toml b/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/configurations/piranha_arguments.toml
index 4cb0bb43d..f339cf669 100644
--- a/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/configurations/piranha_arguments.toml
+++ b/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/configurations/piranha_arguments.toml
@@ -14,3 +14,5 @@ substitutions = [
     ["stale_flag_name", "Premium-Icon"],
 ]
 global_tag_prefix = "universal_tag."
+cleanup_comments=true
+cleanup_comments_buffer=3
diff --git a/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/input/Experiment.swift b/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/input/Experiment.swift
index e702a23e1..306f97c85 100644
--- a/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/input/Experiment.swift
+++ b/polyglot/piranha/test-resources/swift/cascade_file_delete_custom_global_tag/input/Experiment.swift
@@ -16,6 +16,9 @@ import Experiment
 
 public enum SomePluginSwitch: PluginSwitch {
     case defaultIcon
+    // Premium icon
+
+    
     case premiumIcon
     case defaultTitle
     case premiumTitle
diff --git a/polyglot/piranha/tests/tests.py b/polyglot/piranha/tests/tests.py
index 200cd74be..71d32ef88 100644
--- a/polyglot/piranha/tests/tests.py
+++ b/polyglot/piranha/tests/tests.py
@@ -1,3 +1,16 @@
+# Copyright (c) 2022 Uber Technologies, Inc.
+
+# <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of the License at
+# <p>http://www.apache.org/licenses/LICENSE-2.0
+
+# <p>Unless required by applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+# express or implied. See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+
 from polyglot_piranha import run_piranha_cli
 from os.path import join, basename
 from os import listdir