Skip to content

Commit 6c94c24

Browse files
committed
parser, builder: add :parse_text to the paths of .v files, printed by -print-v-files, for parse time generated snippets
1 parent 1937cdd commit 6c94c24

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

vlib/v/ast/ast.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,9 @@ pub mut:
995995
global_labels []string // from `asm { .globl labelname }`
996996
template_paths []string // all the .html/.md files that were processed with $tmpl
997997
unique_prefix string // a hash of the `.path` field, used for making anon fn generation unique
998+
//
999+
is_parse_text bool // true for files, produced by parse_text
1000+
is_template_text bool // true for files, produced by parse_comptime
9981001
}
9991002

10001003
@[unsafe]

vlib/v/builder/builder.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,19 @@ pub fn (mut b Builder) parse_imports() {
241241
b.resolve_deps()
242242
if b.pref.print_v_files {
243243
for p in b.parsed_files {
244+
if p.is_parse_text {
245+
println(p.path + ':parse_text')
246+
}
244247
println(p.path)
245248
}
246249
exit(0)
247250
}
248251
if b.pref.print_watched_files {
249252
for p in b.parsed_files {
253+
if p.is_parse_text {
254+
// a generated snippet, `v watch` does not care about those, since they are duplicates for other files
255+
continue
256+
}
250257
println(p.path)
251258
for tp in p.template_paths {
252259
println(tp)

vlib/v/parser/parser.v

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ pub fn parse_comptime(tmpl_path string, text string, mut table ast.Table, pref_
157157
errors: []errors.Error{}
158158
warnings: []errors.Warning{}
159159
}
160-
res := p.parse()
160+
mut res := p.parse()
161161
unsafe { p.free_scanner() }
162+
res.is_template_text = true
162163
return res
163164
}
164165

@@ -178,8 +179,9 @@ pub fn parse_text(text string, path string, mut table ast.Table, comments_mode s
178179
warnings: []errors.Warning{}
179180
}
180181
p.set_path(path)
181-
res := p.parse()
182+
mut res := p.parse()
182183
unsafe { p.free_scanner() }
184+
res.is_parse_text = true
183185
return res
184186
}
185187

0 commit comments

Comments
 (0)