Skip to content

Commit 51b471b

Browse files
authored
all: replace enum field name 'xxx_' with 'xxx' (#22469)
1 parent b97b2b1 commit 51b471b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+380
-385
lines changed

cmd/tools/vdoc/highlight.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn color_highlight(code string, tb &ast.Table) string {
5555
.boolean {
5656
lit = term.bright_magenta(tok.lit)
5757
}
58-
.none_ {
58+
.none {
5959
lit = term.red(tok.lit)
6060
}
6161
.prefix {
@@ -133,7 +133,7 @@ fn color_highlight(code string, tb &ast.Table) string {
133133
tok_typ = .punctuation
134134
}
135135
.key_none {
136-
tok_typ = .none_
136+
tok_typ = .none
137137
}
138138
else {
139139
if token.is_key(tok.lit) || token.is_decl(tok.kind) {

cmd/tools/vdoc/html.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum HighlightTokenTyp {
3939
partial_string
4040
closing_string
4141
symbol
42-
none_
42+
none
4343
module_
4444
prefix
4545
}

cmd/tools/vls.v

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum UpdateSource {
2525
}
2626

2727
enum SetupKind {
28-
none_
28+
none
2929
install
3030
update
3131
}
@@ -39,7 +39,7 @@ enum OutputMode {
3939
struct VlsUpdater {
4040
mut:
4141
output OutputMode = .text
42-
setup_kind SetupKind = .none_
42+
setup_kind SetupKind = .none
4343
update_source UpdateSource = .github_releases
4444
ls_path string // --path
4545
pass_to_ls bool // --ls
@@ -348,7 +348,7 @@ fn (mut upd VlsUpdater) parse(mut fp flag.FlagParser) ! {
348348

349349
upd.ls_path = ls_path
350350

351-
if upd.setup_kind != .none_ {
351+
if upd.setup_kind != .none {
352352
upd.update_source = .local_file // use local path if both -p and --source are used
353353
}
354354
}
@@ -368,7 +368,7 @@ fn (mut upd VlsUpdater) parse(mut fp flag.FlagParser) ! {
368368
}
369369

370370
upd.ls_path = ls_path
371-
} else if upd.setup_kind == .none_ {
371+
} else if upd.setup_kind == .none {
372372
return server_not_found_err
373373
}
374374
}
@@ -455,7 +455,7 @@ fn (upd VlsUpdater) check_installation() {
455455
fn (upd VlsUpdater) run(fp flag.FlagParser) ! {
456456
if upd.is_check {
457457
upd.check_installation()
458-
} else if upd.setup_kind != .none_ {
458+
} else if upd.setup_kind != .none {
459459
upd.check_or_create_vls_folder()!
460460

461461
match upd.update_source {

cmd/tools/vrepl.v

+25-25
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ enum FnType {
7373
}
7474

7575
enum DeclType {
76-
include_ // #include ...
77-
const_ // const ...
78-
type_ // type ...
79-
enum_ // enum ...
80-
fn_ // fn ...
81-
struct // struct ...
82-
interface_ // interface ...
83-
stmt_ // statement
76+
include // #include ...
77+
const // const ...
78+
type // type ...
79+
enum // enum ...
80+
fn // fn ...
81+
struct // struct ...
82+
interface // interface ...
83+
stmt // statement
8484
}
8585

8686
fn new_repl(folder string) Repl {
@@ -249,35 +249,35 @@ fn (r &Repl) insert_source_code(typ DeclType, lines []string) string {
249249
all_lines << r.vstartup_lines.filter(!it.starts_with('print'))
250250
}
251251
all_lines << r.includes
252-
if typ == .include_ {
252+
if typ == .include {
253253
all_lines << lines
254254
}
255255
all_lines << r.types
256-
if typ == .type_ {
256+
if typ == .type {
257257
all_lines << lines
258258
}
259259
all_lines << r.enums
260-
if typ == .enum_ {
260+
if typ == .enum {
261261
all_lines << lines
262262
}
263263
all_lines << r.consts
264-
if typ == .const_ {
264+
if typ == .const {
265265
all_lines << lines
266266
}
267267
all_lines << r.structs
268268
if typ == .struct {
269269
all_lines << lines
270270
}
271271
all_lines << r.interfaces
272-
if typ == .interface_ {
272+
if typ == .interface {
273273
all_lines << lines
274274
}
275275
all_lines << r.functions
276-
if typ == .fn_ {
276+
if typ == .fn {
277277
all_lines << lines
278278
}
279279
all_lines << r.lines
280-
if typ == .stmt_ {
280+
if typ == .stmt {
281281
all_lines << lines
282282
}
283283
return all_lines.join('\n')
@@ -596,30 +596,30 @@ fn run_repl(workdir string, vrepl_prefix string) int {
596596
}
597597
} else if r.line.len == 0 {
598598
if was_func {
599-
temp_source_code = r.insert_source_code(DeclType.fn_, r.temp_lines)
599+
temp_source_code = r.insert_source_code(DeclType.fn, r.temp_lines)
600600
} else if was_struct {
601601
temp_source_code = r.insert_source_code(DeclType.struct, r.temp_lines)
602602
} else if was_enum {
603-
temp_source_code = r.insert_source_code(DeclType.enum_, r.temp_lines)
603+
temp_source_code = r.insert_source_code(DeclType.enum, r.temp_lines)
604604
} else if was_interface {
605-
temp_source_code = r.insert_source_code(DeclType.interface_, r.temp_lines)
605+
temp_source_code = r.insert_source_code(DeclType.interface, r.temp_lines)
606606
} else {
607-
temp_source_code = r.insert_source_code(DeclType.stmt_, r.temp_lines)
607+
temp_source_code = r.insert_source_code(DeclType.stmt, r.temp_lines)
608608
}
609609
} else if starts_with_include {
610-
temp_source_code = r.insert_source_code(DeclType.include_, [r.line])
610+
temp_source_code = r.insert_source_code(DeclType.include, [r.line])
611611
} else if starts_with_fn {
612-
temp_source_code = r.insert_source_code(DeclType.fn_, [r.line])
612+
temp_source_code = r.insert_source_code(DeclType.fn, [r.line])
613613
} else if starts_with_const {
614-
temp_source_code = r.insert_source_code(DeclType.const_, [r.line])
614+
temp_source_code = r.insert_source_code(DeclType.const, [r.line])
615615
} else if starts_with_enum {
616-
temp_source_code = r.insert_source_code(DeclType.enum_, [r.line])
616+
temp_source_code = r.insert_source_code(DeclType.enum, [r.line])
617617
} else if starts_with_struct {
618618
temp_source_code = r.insert_source_code(DeclType.struct, [r.line])
619619
} else if starts_with_interface {
620-
temp_source_code = r.insert_source_code(DeclType.interface_, [r.line])
620+
temp_source_code = r.insert_source_code(DeclType.interface, [r.line])
621621
} else if starts_with_type {
622-
temp_source_code = r.insert_source_code(DeclType.type_, [r.line])
622+
temp_source_code = r.insert_source_code(DeclType.type, [r.line])
623623
} else {
624624
temp_source_code = r.current_source_code(true, false) + '\n${r.line}\n'
625625
}

examples/2048/2048.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ enum TileFormat {
162162
log
163163
exponent
164164
shifts
165-
none_
165+
none
166166
end_ // To know when to wrap around
167167
}
168168

@@ -671,7 +671,7 @@ fn (app &App) draw_tiles() {
671671
size: fs2
672672
})
673673
}
674-
.none_ {} // Don't draw any text here, colors only
674+
.none {} // Don't draw any text here, colors only
675675
.end_ {} // Should never get here
676676
}
677677
}

vlib/v/ast/ast.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub mut:
141141

142142
pub enum ComptimeTypeKind {
143143
unknown
144-
map_
144+
map
145145
int
146146
float
147147
struct
@@ -150,7 +150,7 @@ pub enum ComptimeTypeKind {
150150
array_fixed
151151
array_dynamic
152152
sum_type
153-
enum_
153+
enum
154154
alias
155155
function
156156
option
@@ -166,7 +166,7 @@ pub:
166166
pub fn (cty ComptimeType) str() string {
167167
return match cty.kind {
168168
.unknown { '\$unknown' }
169-
.map_ { '\$map' }
169+
.map { '\$map' }
170170
.int { '\$int' }
171171
.float { '\$float' }
172172
.struct { '\$struct' }
@@ -175,7 +175,7 @@ pub fn (cty ComptimeType) str() string {
175175
.array_dynamic { '\$array_dynamic' }
176176
.array_fixed { '\$array_fixed' }
177177
.sum_type { '\$sumtype' }
178-
.enum_ { '\$enum' }
178+
.enum { '\$enum' }
179179
.alias { '\$alias' }
180180
.function { '\$function' }
181181
.option { '\$option' }

vlib/v/ast/table.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -1386,13 +1386,13 @@ pub fn (t &Table) is_sumtype_or_in_variant(parent Type, typ Type) bool {
13861386

13871387
@[inline]
13881388
pub fn (t &Table) is_interface_var(var ScopeObject) bool {
1389-
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface_
1390-
&& t.sym(var.smartcasts.last()).kind != .interface_
1389+
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface
1390+
&& t.sym(var.smartcasts.last()).kind != .interface
13911391
}
13921392

13931393
@[inline]
13941394
pub fn (t &Table) is_interface_smartcast(var ScopeObject) bool {
1395-
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface_
1395+
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface
13961396
&& var.smartcasts.len > 0
13971397
}
13981398

@@ -1510,7 +1510,7 @@ pub fn (t Table) does_type_implement_interface(typ Type, inter_typ Type) bool {
15101510
}
15111511
}
15121512
mut inter_sym := t.sym(inter_typ)
1513-
if sym.kind == .interface_ && inter_sym.kind == .interface_ {
1513+
if sym.kind == .interface && inter_sym.kind == .interface {
15141514
return false
15151515
}
15161516
if mut inter_sym.info is Interface {
@@ -2043,7 +2043,7 @@ pub fn (mut t Table) unwrap_generic_type_ex(typ Type, generic_names []string, co
20432043
for i in 0 .. variants.len {
20442044
if variants[i].has_flag(.generic) {
20452045
sym := t.sym(variants[i])
2046-
if sym.kind in [.struct, .sum_type, .interface_] {
2046+
if sym.kind in [.struct, .sum_type, .interface] {
20472047
variants[i] = t.unwrap_generic_type(variants[i], generic_names,
20482048
concrete_types)
20492049
} else {
@@ -2106,7 +2106,7 @@ pub fn (mut t Table) unwrap_generic_type_ex(typ Type, generic_names []string, co
21062106
info.fields = fields
21072107
info.methods = imethods
21082108
new_idx := t.register_sym(
2109-
kind: .interface_
2109+
kind: .interface
21102110
name: nrt
21112111
cname: util.no_dots(c_nrt)
21122112
mod: ts.mod

0 commit comments

Comments
 (0)