@@ -86,11 +86,11 @@ def remove_unused_imports(self, sanitized_code: str) -> str:
86
86
+ Finally, remove all the unused imports from the source code and prettify it.
87
87
"""
88
88
pruned_source_code : str = deepcopy (sanitized_code )
89
- import_declerations : Captures = self .__javasitter .frame_query_and_capture_output (query = "((import_declaration) @imports)" , code_to_process = self .source_code )
89
+ import_declarations : Captures = self .__javasitter .frame_query_and_capture_output (query = "((import_declaration) @imports)" , code_to_process = self .source_code )
90
90
91
91
unused_imports : Set = set ()
92
92
ids_and_typeids : Set = set ()
93
- class_bodies : Captures = self .__javasitter .frame_query_and_capture_output (query = "((class_declaration) @class_decleration )" , code_to_process = self .source_code )
93
+ class_bodies : Captures = self .__javasitter .frame_query_and_capture_output (query = "((class_declaration) @class_declaration )" , code_to_process = self .source_code )
94
94
for class_body in class_bodies :
95
95
all_type_identifiers_in_class : Captures = self .__javasitter .frame_query_and_capture_output (
96
96
query = "((type_identifier) @type_id)" ,
@@ -103,17 +103,17 @@ def remove_unused_imports(self, sanitized_code: str) -> str:
103
103
ids_and_typeids .update ({type_id .node .text .decode () for type_id in all_type_identifiers_in_class })
104
104
ids_and_typeids .update ({other_id .node .text .decode () for other_id in all_other_identifiers_in_class })
105
105
106
- for import_decleration in import_declerations :
107
- wildcard_import : Captures = self .__javasitter .frame_query_and_capture_output (query = "((asterisk) @wildcard)" , code_to_process = import_decleration .node .text .decode ())
106
+ for import_declaration in import_declarations :
107
+ wildcard_import : Captures = self .__javasitter .frame_query_and_capture_output (query = "((asterisk) @wildcard)" , code_to_process = import_declaration .node .text .decode ())
108
108
if len (wildcard_import ) > 0 :
109
109
continue
110
110
111
111
import_statement : Captures = self .__javasitter .frame_query_and_capture_output (
112
- query = "((scoped_identifier) @scoped_identifier)" , code_to_process = import_decleration .node .text .decode ()
112
+ query = "((scoped_identifier) @scoped_identifier)" , code_to_process = import_declaration .node .text .decode ()
113
113
)
114
114
import_str = import_statement .captures [0 ].node .text .decode ()
115
115
if not import_str .split ("." )[- 1 ] in ids_and_typeids :
116
- unused_imports .add (import_decleration .node .text .decode ())
116
+ unused_imports .add (import_declaration .node .text .decode ())
117
117
118
118
for unused_import in unused_imports :
119
119
pruned_source_code = pruned_source_code .replace (unused_import , "" )
0 commit comments