@@ -69,18 +69,26 @@ class Dialog extends React.Component<Props> {
6969 . iter ( )
7070 . filter ( |c| matches ! ( c. chunk_type, ChunkType :: Class ) )
7171 . collect ( ) ;
72+ let component_chunks: Vec < _ > = chunks
73+ . iter ( )
74+ . filter ( |c| matches ! ( c. chunk_type, ChunkType :: Component ) )
75+ . collect ( ) ;
7276
7377 println ! ( "Found {} total chunks" , chunks. len( ) ) ;
7478 println ! ( "Functions: {}" , function_chunks. len( ) ) ;
7579 println ! ( "Interfaces: {}" , interface_chunks. len( ) ) ;
7680 println ! ( "Classes: {}" , class_chunks. len( ) ) ;
81+ println ! ( "Components: {}" , component_chunks. len( ) ) ;
7782
7883 let all_names: Vec < & String > = chunks. iter ( ) . map ( |c| & c. name ) . collect ( ) ;
7984 println ! ( "All chunk names: {:?}" , all_names) ;
8085
8186 // Should find at least the interface and functions (React component functions)
8287 assert ! ( !interface_chunks. is_empty( ) , "Should find Props interface" ) ;
83- assert ! ( !function_chunks. is_empty( ) , "Should find function components" ) ;
88+ assert ! (
89+ !function_chunks. is_empty( ) ,
90+ "Should find function components"
91+ ) ;
8492
8593 let interface_names: Vec < & String > = interface_chunks. iter ( ) . map ( |c| & c. name ) . collect ( ) ;
8694 assert ! ( interface_names. contains( &&"Props" . to_string( ) ) ) ;
@@ -90,6 +98,10 @@ class Dialog extends React.Component<Props> {
9098 assert ! ( function_names. contains( &&"WelcomeComponent" . to_string( ) ) ) ;
9199 assert ! ( function_names. contains( &&"App" . to_string( ) ) ) ;
92100 assert ! ( function_names. contains( &&"Button" . to_string( ) ) ) ;
101+
102+ // Should also find JSX components as Component chunks
103+ let component_names: Vec < & String > = component_chunks. iter ( ) . map ( |c| & c. name ) . collect ( ) ;
104+ println ! ( "Component names: {:?}" , component_names) ;
93105}
94106
95107#[ test]
@@ -126,19 +138,44 @@ function FormComponent() {
126138 . extract_chunks ( temp_dir. path ( ) , ExtractionOptions :: default ( ) )
127139 . unwrap ( ) ;
128140
141+ println ! ( "JSX file chunks found: {}" , chunks. len( ) ) ;
142+ for chunk in & chunks {
143+ println ! (
144+ " Chunk: {} ({}:{}-{}:{})" ,
145+ chunk. name,
146+ chunk. file_path. display( ) ,
147+ chunk. start_line,
148+ chunk. end_line,
149+ chunk. chunk_type. clone( ) as u8
150+ ) ;
151+ }
152+
129153 assert ! ( !chunks. is_empty( ) , "Should find code chunks in JSX file" ) ;
130154
131155 let function_chunks: Vec < _ > = chunks
132156 . iter ( )
133157 . filter ( |c| matches ! ( c. chunk_type, ChunkType :: Function ) )
134158 . collect ( ) ;
159+ let component_chunks: Vec < _ > = chunks
160+ . iter ( )
161+ . filter ( |c| matches ! ( c. chunk_type, ChunkType :: Component ) )
162+ . collect ( ) ;
135163
136164 println ! ( "Found {} function chunks" , function_chunks. len( ) ) ;
165+ println ! ( "Found {} component chunks" , component_chunks. len( ) ) ;
137166 let function_names: Vec < & String > = function_chunks. iter ( ) . map ( |c| & c. name ) . collect ( ) ;
167+ let component_names: Vec < & String > = component_chunks. iter ( ) . map ( |c| & c. name ) . collect ( ) ;
138168 println ! ( "Function names: {:?}" , function_names) ;
169+ println ! ( "Component names: {:?}" , component_names) ;
139170
140171 assert ! ( function_names. contains( &&"ProfileCard" . to_string( ) ) ) ;
141172 assert ! ( function_names. contains( &&"FormComponent" . to_string( ) ) ) ;
173+
174+ // Should find JSX components (div, img, input, br, CustomComponent)
175+ // Note: These are HTML elements and custom components used in JSX
176+ if !component_chunks. is_empty ( ) {
177+ println ! ( "JSX components found: {:?}" , component_names) ;
178+ }
142179}
143180
144181#[ test]
@@ -216,7 +253,10 @@ export default UserList;
216253 . extract_chunks ( temp_dir. path ( ) , ExtractionOptions :: default ( ) )
217254 . unwrap ( ) ;
218255
219- assert ! ( !chunks. is_empty( ) , "Should find code chunks in mixed TSX file" ) ;
256+ assert ! (
257+ !chunks. is_empty( ) ,
258+ "Should find code chunks in mixed TSX file"
259+ ) ;
220260
221261 // Check for different types of constructs
222262 let interface_count = chunks
@@ -239,13 +279,18 @@ export default UserList;
239279 . iter ( )
240280 . filter ( |c| matches ! ( c. chunk_type, ChunkType :: Class ) )
241281 . count ( ) ;
282+ let component_count = chunks
283+ . iter ( )
284+ . filter ( |c| matches ! ( c. chunk_type, ChunkType :: Component ) )
285+ . count ( ) ;
242286
243287 println ! ( "Mixed TSX content analysis:" ) ;
244288 println ! ( " Interfaces: {}" , interface_count) ;
245289 println ! ( " Type aliases: {}" , type_alias_count) ;
246290 println ! ( " Enums: {}" , enum_count) ;
247291 println ! ( " Functions: {}" , function_count) ;
248292 println ! ( " Classes: {}" , class_count) ;
293+ println ! ( " Components: {}" , component_count) ;
249294
250295 let all_names: Vec < & String > = chunks. iter ( ) . map ( |c| & c. name ) . collect ( ) ;
251296 println ! ( " All names: {:?}" , all_names) ;
@@ -255,4 +300,4 @@ export default UserList;
255300 assert ! ( enum_count > 0 , "Should find Status enum" ) ;
256301 assert ! ( function_count > 0 , "Should find UserList component" ) ;
257302 assert ! ( class_count > 0 , "Should find ErrorBoundary class" ) ;
258- }
303+ }
0 commit comments