fmt: insert newline after last HashStmt (#8482)
parent
53a5aad855
commit
d660f2cc6f
|
@ -4,6 +4,7 @@ module big
|
|||
#flag -I @VROOT/thirdparty/bignum
|
||||
#flag @VROOT/thirdparty/bignum/bn.o
|
||||
#include "bn.h"
|
||||
|
||||
struct C.bn {
|
||||
mut:
|
||||
array [32]u32
|
||||
|
|
|
@ -2,6 +2,7 @@ module os
|
|||
|
||||
#include <sys/stat.h> // #include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
struct C.dirent {
|
||||
d_name [256]char
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
module os
|
||||
|
||||
#include "@VROOT/vlib/os/os_darwin.m"
|
||||
|
||||
pub const (
|
||||
sys_write = 4
|
||||
sys_open = 5
|
||||
|
|
|
@ -6,6 +6,7 @@ import strings
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
pub const (
|
||||
path_separator = '/'
|
||||
path_delimiter = ':'
|
||||
|
|
|
@ -3,6 +3,7 @@ module os
|
|||
import strings
|
||||
|
||||
#include <process.h>
|
||||
|
||||
pub const (
|
||||
path_separator = '\\'
|
||||
path_delimiter = ';'
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
module time
|
||||
|
||||
#include <time.h>
|
||||
|
||||
const (
|
||||
days_string = 'MonTueWedThuFriSatSun'
|
||||
month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module time
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
const (
|
||||
// start_time is needed on Darwin and Windows because of potential overflows
|
||||
start_time = C.mach_absolute_time()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
module time
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct C.tm {
|
||||
tm_sec int
|
||||
tm_min int
|
||||
|
|
|
@ -5,6 +5,7 @@ module time
|
|||
|
||||
#include <time.h>
|
||||
// #include <sysinfoapi.h>
|
||||
|
||||
struct C.tm {
|
||||
tm_year int
|
||||
tm_mon int
|
||||
|
|
|
@ -7,6 +7,7 @@ import v.cflag
|
|||
#flag windows -l shell32
|
||||
#flag windows -l dbghelp
|
||||
#flag windows -l advapi32
|
||||
|
||||
struct MsvcResult {
|
||||
full_cl_exe_path string
|
||||
exe_path string
|
||||
|
|
|
@ -295,6 +295,9 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
|
|||
|
||||
fn (mut f Fmt) should_insert_newline_before_stmt(stmt ast.Stmt, prev_stmt ast.Stmt) bool {
|
||||
prev_line_nr := prev_stmt.position().last_line
|
||||
if prev_stmt is ast.HashStmt && stmt !is ast.HashStmt && stmt !is ast.ExprStmt {
|
||||
return true
|
||||
}
|
||||
// The stmt either has or shouldn't have a newline before
|
||||
if stmt.position().line_nr - prev_line_nr <= 1 || f.out.last_n(2) == '\n\n' {
|
||||
return false
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#include "header.h"
|
||||
|
||||
struct Foo {}
|
|
@ -0,0 +1,2 @@
|
|||
#include "header.h"
|
||||
struct Foo {}
|
|
@ -0,0 +1,12 @@
|
|||
// comment above HashStmt
|
||||
#flag -I @VROOT/c
|
||||
#flag @VROOT/c/implementation.o
|
||||
|
||||
#include "@VROOT/c/implementation.h"
|
||||
|
||||
// comment between with newlines around
|
||||
|
||||
#include "header.h"
|
||||
// comment between without newlines
|
||||
#include "sqlite3.h"
|
||||
// comment directly after the HsahStmt
|
|
@ -1,8 +0,0 @@
|
|||
// comment above HashStmts
|
||||
#flag linux -lsdl2
|
||||
#include "stdio.h"
|
||||
|
||||
// comment between with newlines around
|
||||
|
||||
#include "header.h"
|
||||
#include "sqlite3.h"
|
|
@ -1,3 +0,0 @@
|
|||
#flag -I @VROOT/c
|
||||
#flag @VROOT/c/implementation.o
|
||||
#include "@VROOT/c/implementation.h"
|
Loading…
Reference in New Issue