From 4280e5113d1d93153239884db2bdf36f268d5e05 Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 1 Jul 2024 22:00:09 +0800 Subject: [PATCH] fix formatting fn with super long parameters --- vlib/builtin/cfns.c.v | 3 ++- vlib/clipboard/x11/clipboard.c.v | 3 ++- vlib/db/mssql/_cdefs.c.v | 3 ++- vlib/gg/gg_ui.c.v | 3 ++- vlib/js/dom/dom.js.v | 9 ++++++--- vlib/v/ast/str.v | 6 +++--- vlib/v/checker/checker.v | 3 ++- vlib/v/fmt/tests/fn_with_long_args_keep.vv | 8 +++++++- vlib/x/templating/dtm/dynamic_template_manager.v | 6 ++++-- 9 files changed, 30 insertions(+), 14 deletions(-) diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index 36de9b8e692207..c8f9e82c5268f0 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -264,7 +264,8 @@ fn C.SendMessageTimeoutW(hWnd voidptr, msg u32, wParam &u16, lParam &u32, fuFlag lpdwResult &u64) isize fn C.CreateProcessW(lpApplicationName &u16, lpCommandLine &u16, lpProcessAttributes voidptr, - lpThreadAttributes voidptr, bInheritHandles bool, dwCreationFlags u32, lpEnvironment voidptr, lpCurrentDirectory &u16, lpStartupInfo voidptr, lpProcessInformation voidptr) bool + lpThreadAttributes voidptr, bInheritHandles bool, dwCreationFlags u32, lpEnvironment voidptr, + lpCurrentDirectory &u16, lpStartupInfo voidptr, lpProcessInformation voidptr) bool fn C.ReadFile(hFile voidptr, lpBuffer voidptr, nNumberOfBytesToRead u32, lpNumberOfBytesRead &u32, lpOverlapped voidptr) bool diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index 01d91cac84300f..846470849969c2 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -59,7 +59,8 @@ fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom, fn C.XSync(d &C.Display, discard int) int fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, - req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&u8) int + req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, + prop_return &&u8) int fn C.XDeleteProperty(d &C.Display, w Window, property Atom) int diff --git a/vlib/db/mssql/_cdefs.c.v b/vlib/db/mssql/_cdefs.c.v index efd504d6715973..851ee7ec38b862 100644 --- a/vlib/db/mssql/_cdefs.c.v +++ b/vlib/db/mssql/_cdefs.c.v @@ -12,7 +12,8 @@ fn C.SQLSetConnectAttr(connection_handle C.SQLHDBC, attribute C.SQLINTEGER, valu string_length C.SQLINTEGER) C.SQLRETURN fn C.SQLDriverConnect(hdbc C.SQLHDBC, hwnd C.SQLHWND, sz_conn_str_in &C.SQLCHAR, cb_conn_str_in C.SQLSMALLINT, - sz_conn_str_out &C.SQLCHAR, cb_conn_str_out_max C.SQLSMALLINT, pcb_conn_str_out &C.SQLSMALLINT, f_driver_completion C.SQLUSMALLINT) C.SQLRETURN + sz_conn_str_out &C.SQLCHAR, cb_conn_str_out_max C.SQLSMALLINT, pcb_conn_str_out &C.SQLSMALLINT, + f_driver_completion C.SQLUSMALLINT) C.SQLRETURN fn C.SQLDisconnect(connection_handle C.SQLHDBC) C.SQLRETURN diff --git a/vlib/gg/gg_ui.c.v b/vlib/gg/gg_ui.c.v index 15a33ce8b9952c..3876369df26a39 100644 --- a/vlib/gg/gg_ui.c.v +++ b/vlib/gg/gg_ui.c.v @@ -16,7 +16,8 @@ pub fn (ctx &Context) has_text_style() bool { } pub fn (ctx &Context) set_text_style(font_name string, font_path string, size int, color gx.Color, - align int, vertical_align int) {} + align int, vertical_align int) { +} // default draw_text (draw_text_def but without set_text_cfg) pub fn (ctx &Context) draw_text_default(x int, y int, text string) { diff --git a/vlib/js/dom/dom.js.v b/vlib/js/dom/dom.js.v index 63ecb4388490ca..a241ba33b07d96 100644 --- a/vlib/js/dom/dom.js.v +++ b/vlib/js/dom/dom.js.v @@ -48,6 +48,8 @@ mut: } pub interface JS.DOMMatrix { + JS.DOMMatrix + JS.DOMMatrix is2D JS.Boolean isIdentity JS.Boolean flipX() JS.DOMMatrix @@ -57,7 +59,7 @@ pub interface JS.DOMMatrix { rotate(rotX JS.Number, rotY JS.Number, rotZ JS.Number) JS.DOMMatrix rotateAxisAngle(x JS.Number, y JS.Number, z JS.Number, angle JS.Number) JS.DOMMatrix scale(scaleX JS.Number, scaleY JS.Number, scaleZ JS.Number, originX JS.Number, originY JS.Number, - originZ JS.Number) JS.DOMMatrix + originZ JS.Number) scale3d(scale JS.Number, originX JS.Number, originY JS.Number, originZ JS.Number) JS.DOMMatrix skewX(sx JS.Number) JS.DOMMatrix skewY(sy JS.Number) JS.DOMMatrix @@ -70,7 +72,7 @@ pub interface JS.DOMMatrix { rotateSelf(rotX JS.Number, rotY JS.Number, rotZ JS.Number) JS.DOMMatrix scale3dSelf(scale JS.Number, originX JS.Number, originY JS.Number, originZ JS.Number) JS.DOMMatrix scaleSelf(scaleX JS.Number, scaleY JS.Number, scaleZ JS.Number, originX JS.Number, originY JS.Number, - originZ JS.Number) JS.DOMMatrix + originZ JS.Number) toString() JS.String mut: a JS.Number @@ -439,6 +441,7 @@ mut: pub type FillStyle = JS.CanvasGradient | JS.CanvasPattern | JS.String pub interface JS.CanvasRenderingContext2D { + JS.CanvasGradient canvas JS.HTMLCanvasElement beginPath() clip(path JS.Path2D, fillRule JS.String) @@ -448,7 +451,7 @@ pub interface JS.CanvasRenderingContext2D { stoke(path JS.Path2D) createLinearGradient(x0 JS.Number, y0 JS.Number, x1 JS.Number, y1 JS.Number) JS.CanvasGradient createRadialGradient(x0 JS.Number, y0 JS.Number, r0 JS.Number, x1 JS.Number, y1 JS.Number, - r1 JS.Number) JS.CanvasGradient + r1 JS.Number) createPattern(image JS.CanvasImageSource, repetition JS.String) ?JS.CanvasPattern arc(x JS.Number, y JS.Number, radius JS.Number, startAngle JS.Number, endAngle JS.Number, counterclockwise JS.Boolean) diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index e67f5ac5b99fe7..eddfecfb3c89ec 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -162,7 +162,7 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m } } f.write_string('(') - mut has_wrapped := false + mut last_len := 0 for i, param in node.params { // skip receiver if node.is_method && i == 0 { @@ -229,9 +229,9 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m } } if !is_last_param { - if f.len > 90 && !has_wrapped { + if f.len - last_len > 90 { f.write_string(',\n\t') - has_wrapped = true + last_len = f.len } else { f.write_string(', ') } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 27622e4540d470..4b1898890ce33b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1972,7 +1972,8 @@ fn (mut c Checker) enum_decl(mut node ast.EnumDecl) { } fn (mut c Checker) check_enum_field_integer_literal(expr ast.IntegerLiteral, is_signed bool, - is_multi_allowed bool, styp string, pos token.Pos, mut useen []u64, umin u64, umax u64, mut iseen []i64, imin i64, imax i64) { + is_multi_allowed bool, styp string, pos token.Pos, mut useen []u64, umin u64, umax u64, mut iseen []i64, + imin i64, imax i64) { mut overflows := false mut uval := u64(0) mut ival := i64(0) diff --git a/vlib/v/fmt/tests/fn_with_long_args_keep.vv b/vlib/v/fmt/tests/fn_with_long_args_keep.vv index ccf17ead54e82d..1411b1e0a74204 100644 --- a/vlib/v/fmt/tests/fn_with_long_args_keep.vv +++ b/vlib/v/fmt/tests/fn_with_long_args_keep.vv @@ -1,6 +1,12 @@ -fn process_keyholder(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string, +fn process_keyholder1(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string, super_long_argument4 string, super_long_argument5 string) string { return '' } +fn process_keyholder2(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string, + super_long_argument4 string, super_long_argument5 string, super_long_argument6 string, super_long_argument7 string, + super_long_argument8 string) string { + return '' +} + fn main() {} diff --git a/vlib/x/templating/dtm/dynamic_template_manager.v b/vlib/x/templating/dtm/dynamic_template_manager.v index 920ee162455ecb..f3164d2453d70a 100644 --- a/vlib/x/templating/dtm/dynamic_template_manager.v +++ b/vlib/x/templating/dtm/dynamic_template_manager.v @@ -523,7 +523,8 @@ fn (mut tm DynamicTemplateManager) check_tmpl_and_placeholders_size(f_path strin // The function returns the rendered immediately, without waiting for the cache to be created or updated. // fn (mut tm DynamicTemplateManager) create_template_cache_and_display(tcs CacheRequest, last_template_mod i64, - unique_time i64, file_path string, tmpl_name string, cache_delay_expiration i64, placeholders &map[string]DtmMultiTypeMap, current_content_checksum string, tmpl_type TemplateType) string { + unique_time i64, file_path string, tmpl_name string, cache_delay_expiration i64, placeholders &map[string]DtmMultiTypeMap, + current_content_checksum string, tmpl_type TemplateType) string { // Control if cache delay expiration is correctly set. See the function itself for more details. check_if_cache_delay_iscorrect(cache_delay_expiration, tmpl_name) or { eprintln(err) @@ -1040,7 +1041,8 @@ fn check_if_cache_delay_iscorrect(cde i64, tmpl_name string) ! { // to decide whether to create a new cache, update an existing or delivered a valid cache content. // fn (mut tm DynamicTemplateManager) cache_request_route(is_cache_exist bool, neg_cache_delay_expiration i64, - last_template_mod i64, test_current_template_mod i64, cache_del_exp i64, gen_at i64, c_time i64, content_checksum string, current_content_checksum string) (CacheRequest, i64) { + last_template_mod i64, test_current_template_mod i64, cache_del_exp i64, gen_at i64, c_time i64, + content_checksum string, current_content_checksum string) (CacheRequest, i64) { if !is_cache_exist || neg_cache_delay_expiration == -1 { // Require cache creation unique_ts := get_current_unix_micro_timestamp()