@@ -2572,14 +2572,26 @@ fn (mut p Parser) const_decl() ast.ConstDecl {
25722572 } else {
25732573 comments << p.eat_comments (same_line: true )
25742574 }
2575- return ast.ConstDecl{
2575+ const_decl := ast.ConstDecl{
25762576 pos: start_pos.extend_with_last_line (const_pos, p.prev_tok.line_nr)
25772577 fields: fields
25782578 is_pub: is_pub
25792579 end_comments: comments
25802580 is_block: is_block
25812581 attrs: attrs
25822582 }
2583+ if p.pref.is_vls {
2584+ for f in fields {
2585+ key := 'const_${f .name }'
2586+ val := ast.VLSInfo{
2587+ pos: f.pos
2588+ comments: f.comments
2589+ end_comments: f.end_comments
2590+ }
2591+ p.table.register_vls_info (key, val)
2592+ }
2593+ }
2594+ return const_decl
25832595}
25842596
25852597fn (mut p Parser) return_stmt () ast.Return {
@@ -2732,14 +2744,29 @@ fn (mut p Parser) global_decl() ast.GlobalDecl {
27322744 if is_block {
27332745 p.check (.rpar)
27342746 }
2735- return ast.GlobalDecl{
2747+ global_decl := ast.GlobalDecl{
27362748 pos: start_pos.extend (p.prev_tok.pos ())
27372749 mod: p.mod
27382750 fields: fields
27392751 end_comments: comments
27402752 is_block: is_block
27412753 attrs: attrs
27422754 }
2755+ if p.pref.is_vls {
2756+ for f in fields {
2757+ mut key := 'global_${f .name }'
2758+ val := ast.VLSInfo{
2759+ pos: global_decl.pos
2760+ comments: f.comments
2761+ }
2762+ p.table.register_vls_info (key, val)
2763+
2764+ // register another `module specific global`
2765+ key = 'global_${p .prepend_mod (f .name )}'
2766+ p.table.register_vls_info (key, val)
2767+ }
2768+ }
2769+ return global_decl
27432770}
27442771
27452772fn source_name (name string ) string {
@@ -2802,7 +2829,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
28022829 type_pos = type_pos.extend (p.tok.pos ())
28032830 comments = p.eat_comments (same_line: true )
28042831 p.attrs = []
2805- return ast.FnTypeDecl{
2832+ fn_type_decl := ast.FnTypeDecl{
28062833 name: fn_name
28072834 mod: p.mod
28082835 is_pub: is_pub
@@ -2814,6 +2841,15 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
28142841 attrs: attrs
28152842 is_markused: attrs.contains ('markused' )
28162843 }
2844+ if p.pref.is_vls {
2845+ key := 'fntype_${fn_name }'
2846+ val := ast.VLSInfo{
2847+ pos: decl_pos
2848+ comments: comments
2849+ }
2850+ p.table.register_vls_info (key, val)
2851+ }
2852+ return fn_type_decl
28172853 }
28182854 sum_variants << p.parse_sum_type_variants ()
28192855 // type SumType = Aaa | Bbb | Ccc
@@ -2862,6 +2898,13 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
28622898 is_markused: attrs.contains ('markused' )
28632899 }
28642900 p.table.register_sumtype (node)
2901+ if p.pref.is_vls {
2902+ key := 'sumtype_${p .prepend_mod (name )}'
2903+ val := ast.VLSInfo{
2904+ pos: node.pos
2905+ }
2906+ p.table.register_vls_info (key, val)
2907+ }
28652908 return node
28662909 }
28672910 // type MyType = int
@@ -2905,7 +2948,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
29052948 }
29062949 comments = sum_variants[0 ].end_comments.clone ()
29072950 p.attrs = []
2908- return ast.AliasTypeDecl{
2951+ alias_type_decl := ast.AliasTypeDecl{
29092952 name: name
29102953 is_pub: is_pub
29112954 typ: idx
@@ -2916,6 +2959,15 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
29162959 is_markused: attrs.contains ('markused' )
29172960 attrs: attrs
29182961 }
2962+ if p.pref.is_vls {
2963+ key := 'aliastype_${p .prepend_mod (name )}'
2964+ val := ast.VLSInfo{
2965+ pos: alias_type_decl.pos
2966+ comments: comments
2967+ }
2968+ p.table.register_vls_info (key, val)
2969+ }
2970+ return alias_type_decl
29192971}
29202972
29212973fn (mut p Parser) assoc () ast.Assoc {
0 commit comments