99from lexers .javascript .javascriptlexer import JavaScriptLexer
1010from lexers .golang .golexer import GoLexer
1111
12+ # gustavo testando alguma coisa
13+
14+ from spice .identation import detect_indentation
1215
1316# this will read the file extension and return the correct lexer
1417def get_lexer_for_file (file_path ):
@@ -40,7 +43,7 @@ def analyze_file(file_path: str, selected_stats=None):
4043 """
4144 # default to all stats if none specified
4245 if selected_stats is None :
43- selected_stats = ["line_count" , "function_count" , "comment_line_count" ]
46+ selected_stats = ["line_count" , "function_count" , "comment_line_count" , "identation_level" ]
4447
4548 # initialize results with the file name (dont change this please)
4649 results = {
@@ -80,6 +83,8 @@ def analyze_file(file_path: str, selected_stats=None):
8083
8184 # count functions
8285 results ["function_count" ] = count_functions (ast )
86+ if "identation_level" in selected_stats :
87+ analyze_code_structure (code )
8388
8489 return results
8590
@@ -152,4 +157,14 @@ def count_comment_lines(code):
152157 if stripped and stripped .startswith ('#' ):
153158 comment_count += 1
154159
155- return comment_count
160+ return comment_count
161+
162+ def analyze_code_structure (code ):
163+ indentation_info = detect_indentation (code )
164+
165+ print (f"Detected Indentation Type: { indentation_info ['indent_type' ]} " )
166+ print (f"Detected Indentation Size: { indentation_info ['indent_size' ]} " )
167+ for line , level in indentation_info ["levels" ]:
168+ # print(f"Indentation Level {level}: {line}")
169+ print (f"Detected Indentation Type: { indentation_info ['indent_type' ]} " )
170+ print (f"Detected Indentation Size: { indentation_info ['indent_size' ]} " )
0 commit comments