Repository: kyuridenamida/atcoder-tools (language: python)

Issue:
input_part_prefixが使われていない
#228 の際にinput_partで生成していた`final Scanner sc = new Scanner(System.in);`のようなコードをテンプレートに直接書いたため、#228 以降、入力形式の推論に失敗したときも上記のようなコードが生成されるようになっています。
680856a (の元となったと思われる 2e1b441)でコメントアウトされている`input_part_prefix`を使えば解決します。


Discussion / hints:

Fix patch:
diff --git a/atcodertools/codegen/code_generators/universal_generator/d.toml b/atcodertools/codegen/code_generators/universal_generator/d.toml
index 2fcc8354..41d15c05 100644
--- a/atcodertools/codegen/code_generators/universal_generator/d.toml
+++ b/atcodertools/codegen/code_generators/universal_generator/d.toml
@@ -3,7 +3,7 @@ insert_space_around_operators = false
 
 # global変数宣言時の接頭辞
 global_prefix = ""
-#input_part_prefix = "auto input = stdin.byLine.map!split.joiner;"
+input_part_prefix = "auto input = stdin.byLine.map!split.joiner;"
 newline_after_input = true
 
 # ループ
diff --git a/atcodertools/codegen/code_generators/universal_generator/java.toml b/atcodertools/codegen/code_generators/universal_generator/java.toml
index 4f96ca04..0f5e683b 100644
--- a/atcodertools/codegen/code_generators/universal_generator/java.toml
+++ b/atcodertools/codegen/code_generators/universal_generator/java.toml
@@ -3,7 +3,7 @@ insert_space_around_operators = false
 
 # global変数宣言時の接頭辞
 global_prefix = "static "
-#input_part_prefix = "final Scanner sc = new Scanner(System.in);"
+input_part_prefix = "final Scanner sc = new Scanner(System.in);"
 
 # ループ
 [loop]
diff --git a/atcodertools/codegen/code_generators/universal_generator/rust.toml b/atcodertools/codegen/code_generators/universal_generator/rust.toml
index d7f96464..fdd3c83e 100644
--- a/atcodertools/codegen/code_generators/universal_generator/rust.toml
+++ b/atcodertools/codegen/code_generators/universal_generator/rust.toml
@@ -3,7 +3,7 @@ insert_space_around_operators = false
 
 # global変数宣言時の接頭辞
 global_prefix = ""
-#input_part_prefix = "let con = read_string();\nlet mut scanner = Scanner::new(&con);"
+input_part_prefix = "let con = read_string();\nlet mut scanner = Scanner::new(&con);"
 
 # ループ
 [loop]
diff --git a/atcodertools/tools/templates/default_template.d b/atcodertools/tools/templates/default_template.d
index 54a0a1a7..2510cf3b 100644
--- a/atcodertools/tools/templates/default_template.d
+++ b/atcodertools/tools/templates/default_template.d
@@ -25,8 +25,6 @@ void solve({{ formal_arguments }}){
 {% endif %}
 // Generated by {{ atcodertools.version }} {{ atcodertools.url }}  (tips: You use the default template now. You can remove this line by using your custom template)
 int main(){
-    auto input = stdin.byLine.map!split.joiner;
-
     {% if prediction_success %}
     {{ input_part }}
     solve({{ actual_arguments }});
diff --git a/atcodertools/tools/templates/default_template.java b/atcodertools/tools/templates/default_template.java
index d4cc9e1d..135ed303 100644
--- a/atcodertools/tools/templates/default_template.java
+++ b/atcodertools/tools/templates/default_template.java
@@ -14,7 +14,6 @@ class Main {
 
     // Generated by {{ atcodertools.version }} {{ atcodertools.url }}  (tips: You use the default template now. You can remove this line by using your custom template)
     public static void main(String[] args) throws Exception {
-        final Scanner sc = new Scanner(System.in);
         {% if prediction_success %}
         {{ input_part }}
         solve({{ actual_arguments }});
diff --git a/atcodertools/tools/templates/default_template.rs b/atcodertools/tools/templates/default_template.rs
index 44a5e717..0e8862a5 100644
--- a/atcodertools/tools/templates/default_template.rs
+++ b/atcodertools/tools/templates/default_template.rs
@@ -18,8 +18,6 @@ fn solve({{ formal_arguments }}) {
 
 // Generated by {{ atcodertools.version }} {{ atcodertools.url }}  (tips: You use the default template now. You can remove this line by using your custom template)
 fn main() {
-    let con = read_string();
-    let mut scanner = Scanner::new(&con);
     {% if prediction_success %}
     {{input_part}}
     // In order to avoid potential stack overflow, spawn a new thread.


Test patch:
diff --git a/tests/resources/test_codegen/template.d b/tests/resources/test_codegen/template.d
index f8de26c5..4337967e 100644
--- a/tests/resources/test_codegen/template.d
+++ b/tests/resources/test_codegen/template.d
@@ -8,8 +8,6 @@ void solve(${formal_arguments}){
 }
 
 int main(){
-    auto input = stdin.byLine.map!split.joiner;
-
     ${input_part}
     solve(${actual_arguments});
     return 0;
diff --git a/tests/resources/test_codegen/template.java b/tests/resources/test_codegen/template.java
index 34893fa0..041de7cb 100644
--- a/tests/resources/test_codegen/template.java
+++ b/tests/resources/test_codegen/template.java
@@ -3,7 +3,6 @@
 
 class Main {
     public static void main(String[] args) throws Exception {
-        final Scanner sc = new Scanner(System.in);
         ${input_part}
         solve(${actual_arguments});
     }
diff --git a/tests/resources/test_codegen/template.rust b/tests/resources/test_codegen/template.rust
index 6819f31d..3b37d2dd 100644
--- a/tests/resources/test_codegen/template.rust
+++ b/tests/resources/test_codegen/template.rust
@@ -5,8 +5,6 @@ fn solve(${formal_arguments}) {
 }
 
 fn main() {
-    let con = read_string();
-    let mut scanner = Scanner::new(&con);
     ${input_part}
     solve(${actual_arguments});
 }
diff --git a/tests/resources/test_codegen/template_jinja.d b/tests/resources/test_codegen/template_jinja.d
index 1208e627..7f6ac821 100644
--- a/tests/resources/test_codegen/template_jinja.d
+++ b/tests/resources/test_codegen/template_jinja.d
@@ -24,8 +24,6 @@ void solve({{ formal_arguments }}){
 
 {% endif %}
 int main(){
-    auto input = stdin.byLine.map!split.joiner;
-
     {% if prediction_success %}
     {{ input_part }}
     solve({{ actual_arguments }});
diff --git a/tests/resources/test_codegen/template_jinja.java b/tests/resources/test_codegen/template_jinja.java
index 70b95b1a..6d0f1af8 100644
--- a/tests/resources/test_codegen/template_jinja.java
+++ b/tests/resources/test_codegen/template_jinja.java
@@ -12,7 +12,6 @@ class Main {
     static final String NO = "{{ no_str }}";
     {% endif %}
     public static void main(String[] args) throws Exception {
-        final Scanner sc = new Scanner(System.in);
         {{ input_part }}
         solve({{ actual_arguments }});
     }
diff --git a/tests/resources/test_codegen/template_jinja.rust b/tests/resources/test_codegen/template_jinja.rust
index a3d260d6..ef0d9de4 100644
--- a/tests/resources/test_codegen/template_jinja.rust
+++ b/tests/resources/test_codegen/template_jinja.rust
@@ -16,8 +16,6 @@ fn solve({{ formal_arguments }}) {
 {% endif %}
 
 fn main() {
-    let con = read_string();
-    let mut scanner = Scanner::new(&con);
     {% if prediction_success %}
     {{input_part}}
     solve({{ actual_arguments }});
diff --git a/tests/resources/test_codegen/test_default_code_generators_and_templates/d/echo_template.d b/tests/resources/test_codegen/test_default_code_generators_and_templates/d/echo_template.d
index a0c7022b..13d5c52b 100644
--- a/tests/resources/test_codegen/test_default_code_generators_and_templates/d/echo_template.d
+++ b/tests/resources/test_codegen/test_default_code_generators_and_templates/d/echo_template.d
@@ -41,8 +41,6 @@ void solve({{ formal_arguments }}){
 
 {% endif %}
 int main(){
-    auto input = stdin.byLine.map!split.joiner;
-
     {% if prediction_success %}
     {{ input_part }}
     solve({{ actual_arguments }});
diff --git a/tests/resources/test_codegen/test_default_code_generators_and_templates/java/echo_template.java b/tests/resources/test_codegen/test_default_code_generators_and_templates/java/echo_template.java
index 03ed77a8..f4c4df19 100644
--- a/tests/resources/test_codegen/test_default_code_generators_and_templates/java/echo_template.java
+++ b/tests/resources/test_codegen/test_default_code_generators_and_templates/java/echo_template.java
@@ -13,7 +13,6 @@ class Main {
     {% endif %}
 
     public static void main(String[] args) throws Exception {
-        final Scanner sc = new Scanner(System.in);
         {% if prediction_success %}
         {{ input_part }}
         solve({{ actual_arguments }});
diff --git a/tests/resources/test_codegen/test_default_code_generators_and_templates/rust/echo_template.rs b/tests/resources/test_codegen/test_default_code_generators_and_templates/rust/echo_template.rs
index 75dfd6f2..beb67ebe 100644
--- a/tests/resources/test_codegen/test_default_code_generators_and_templates/rust/echo_template.rs
+++ b/tests/resources/test_codegen/test_default_code_generators_and_templates/rust/echo_template.rs
@@ -42,8 +42,6 @@ fn solve({{ formal_arguments }}) {
 {% endif %}
 
 fn main() {
-    let con = read_string();
-    let mut scanner = Scanner::new(&con);
     {% if prediction_success %}
     {{input_part}}
     // In order to avoid potential stack overflow, spawn a new thread.