v/vlib/v/fmt/tests/symbol_registration_keep.vv

41 lines
1.1 KiB
V

module analyzer
import os
const (
mut_struct_keyword = 'mut:'
pub_struct_keyword = 'pub:'
pub_mut_struct_keyword = 'pub mut:'
global_struct_keyword = '__global:'
)
struct SymbolRegistration {
mut:
store &Store = &Store(0)
cursor TreeCursor
module_name string
src_text []u8
// skips the local scopes and registers only
// the top-level ones regardless of its
// visibility
is_import bool
is_script bool
first_var_decl_pos C.TSRange
}
fn (mut sr SymbolRegistration) struct_field_decl(field_access SymbolAccess, field_decl_node C.TSNode) &Symbol {
field_type_node := field_decl_node.child_by_field_name('type')
field_name_node := field_decl_node.child_by_field_name('name')
field_typ := sr.store.find_symbol_by_type_node(field_type_node, sr.src_text) or { void_type }
return &Symbol{
name: field_name_node.get_text(sr.src_text)
kind: .field
range: field_name_node.range()
access: field_access
return_type: field_typ
is_top_level: true
file_path: sr.store.cur_file_path
file_version: sr.store.cur_version
}
}