v, vet: move now obsolete vlib vet module to cmd vet (#21445)

This commit is contained in:
Turiiya 2024-05-06 17:29:11 +02:00 committed by GitHub
parent 920ae6d50f
commit f08b333b52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 16 deletions

View File

@ -1,7 +1,5 @@
// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved. // Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license that can be found in the LICENSE file. // Use of this source code is governed by an MIT license that can be found in the LICENSE file.
module vet
import v.token import v.token
pub enum ErrorKind { pub enum ErrorKind {
@ -24,7 +22,7 @@ pub enum ErrorType {
} }
@[minify] @[minify]
pub struct Error { pub struct VetError {
pub mut: pub mut:
kind ErrorKind @[required] kind ErrorKind @[required]
pub: pub:

View File

@ -1,9 +1,8 @@
module main module main
import v.token import v.token
import v.vet
type FilteredLines = map[vet.ErrorType]map[int]bool type FilteredLines = map[ErrorType]map[int]bool
fn (mut fl FilteredLines) comments(is_multi bool, pos token.Pos) { fn (mut fl FilteredLines) comments(is_multi bool, pos token.Pos) {
if !is_multi { if !is_multi {

View File

@ -4,7 +4,6 @@ module main
import os import os
import os.cmdline import os.cmdline
import v.vet
import v.pref import v.pref
import v.parser import v.parser
import v.token import v.token
@ -15,9 +14,9 @@ import term
struct Vet { struct Vet {
mut: mut:
opt Options opt Options
errors []vet.Error errors []VetError
warns []vet.Error warns []VetError
notices []vet.Error notices []VetError
file string file string
filtered_lines FilteredLines filtered_lines FilteredLines
} }
@ -326,7 +325,7 @@ fn (vt &Vet) vprintln(s string) {
println(s) println(s)
} }
fn (vt &Vet) e2string(err vet.Error) string { fn (vt &Vet) e2string(err VetError) string {
mut kind := '${err.kind}:' mut kind := '${err.kind}:'
mut location := '${err.file_path}:${err.pos.line_nr}:' mut location := '${err.file_path}:${err.pos.line_nr}:'
if vt.opt.use_color { if vt.opt.use_color {
@ -351,11 +350,11 @@ fn (mut vt Vet) vet_in_condition(expr ast.InfixExpr) {
} }
} }
fn (mut vt Vet) error(msg string, line int, fix vet.FixKind) { fn (mut vt Vet) error(msg string, line int, fix FixKind) {
pos := token.Pos{ pos := token.Pos{
line_nr: line + 1 line_nr: line + 1
} }
vt.errors << vet.Error{ vt.errors << VetError{
message: msg message: msg
file_path: vt.file file_path: vt.file
pos: pos pos: pos
@ -365,11 +364,11 @@ fn (mut vt Vet) error(msg string, line int, fix vet.FixKind) {
} }
} }
fn (mut vt Vet) warn(msg string, line int, fix vet.FixKind) { fn (mut vt Vet) warn(msg string, line int, fix FixKind) {
pos := token.Pos{ pos := token.Pos{
line_nr: line + 1 line_nr: line + 1
} }
mut w := vet.Error{ mut w := VetError{
message: msg message: msg
file_path: vt.file file_path: vt.file
pos: pos pos: pos
@ -385,11 +384,11 @@ fn (mut vt Vet) warn(msg string, line int, fix vet.FixKind) {
} }
} }
fn (mut vt Vet) notice(msg string, line int, fix vet.FixKind) { fn (mut vt Vet) notice(msg string, line int, fix FixKind) {
pos := token.Pos{ pos := token.Pos{
line_nr: line + 1 line_nr: line + 1
} }
vt.notices << vet.Error{ vt.notices << VetError{
message: msg message: msg
file_path: vt.file file_path: vt.file
pos: pos pos: pos