| 1 | module analyzer |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | const mut_struct_keyword = 'mut:' |
| 6 | const pub_struct_keyword = 'pub:' |
| 7 | const pub_mut_struct_keyword = 'pub mut:' |
| 8 | const global_struct_keyword = '__global:' |
| 9 | |
| 10 | struct SymbolRegistration { |
| 11 | mut: |
| 12 | store &Store = &Store(0) |
| 13 | cursor TreeCursor |
| 14 | module_name string |
| 15 | src_text []u8 |
| 16 | // skips the local scopes and registers only |
| 17 | // the top-level ones regardless of its |
| 18 | // visibility |
| 19 | is_import bool |
| 20 | is_script bool |
| 21 | first_var_decl_pos C.TSRange |
| 22 | } |
| 23 | |
| 24 | fn (mut sr SymbolRegistration) struct_field_decl(field_access SymbolAccess, field_decl_node C.TSNode) &Symbol { |
| 25 | field_type_node := field_decl_node.child_by_field_name('type') |
| 26 | field_name_node := field_decl_node.child_by_field_name('name') |
| 27 | field_typ := sr.store.find_symbol_by_type_node(field_type_node, sr.src_text) or { void_type } |
| 28 | return &Symbol{ |
| 29 | name: field_name_node.get_text(sr.src_text) |
| 30 | kind: .field |
| 31 | range: field_name_node.range() |
| 32 | access: field_access |
| 33 | return_type: field_typ |
| 34 | is_top_level: true |
| 35 | file_path: sr.store.cur_file_path |
| 36 | file_version: sr.store.cur_version |
| 37 | } |
| 38 | } |
| 39 | |