refactor: eliminate cyclic includes

This commit is contained in:
dundargoc 2023-12-20 14:32:22 +01:00 committed by dundargoc
parent cc6a257c8c
commit 0c120307ca
61 changed files with 107 additions and 70 deletions

View File

@ -46,7 +46,6 @@ Checks: >
-cppcoreguidelines-init-variables,
-llvm-header-guard, We use #pragma once,
-llvmlibc-restrict-system-libc-headers, We want to use glibc,
-misc-header-include-cycle, Looks useful but redundant with IWYU. We may replace IWYU with this one day,
-misc-include-cleaner, Looks useful but redundant with IWYU. We may replace IWYU with this one day,
-misc-misplaced-const,
-misc-no-recursion,

View File

@ -20,6 +20,7 @@
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
#include "nvim/memory.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -21,6 +21,7 @@
#include "nvim/memory.h"
#include "nvim/option.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/deprecated.c.generated.h"

View File

@ -15,6 +15,7 @@
#include "nvim/macros_defs.h"
#include "nvim/memory.h"
#include "nvim/option.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"

View File

@ -11,6 +11,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/vimscript.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"

View File

@ -23,6 +23,7 @@
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/winfloat.h"

View File

@ -13,6 +13,7 @@
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
// Set by the apply_autocmds_group function if the given event is equal to
// EVENT_FILETYPE. Used by the readfile function in order to determine if

View File

@ -3,7 +3,6 @@
#include <stdint.h>
#include <string.h>
#include "auto/config.h"
#include "nvim/base64.h"
#include "nvim/memory.h"

View File

@ -4,16 +4,6 @@
#include <stdint.h>
#include <stdio.h>
typedef struct file_buffer buf_T;
/// Reference to a buffer that stores the value of buf_free_count.
/// bufref_valid() only needs to check "buf" when the count differs.
typedef struct {
buf_T *br_buf;
int br_fnum;
int br_buf_free_count;
} bufref_T;
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/arglist_defs.h"
@ -27,11 +17,24 @@ typedef struct {
#include "nvim/mapping_defs.h"
#include "nvim/mark_defs.h"
#include "nvim/marktree_defs.h"
#include "nvim/memline_defs.h"
#include "nvim/option_vars.h"
#include "nvim/os/fs_defs.h"
#include "nvim/pos_defs.h"
#include "nvim/regexp_defs.h"
#include "nvim/sign_defs.h"
#include "nvim/statusline_defs.h"
#include "nvim/terminal.h"
#include "nvim/undo_defs.h"
/// Reference to a buffer that stores the value of buf_free_count.
/// bufref_valid() only needs to check "buf" when the count differs.
typedef struct {
buf_T *br_buf;
int br_fnum;
int br_buf_free_count;
} bufref_T;
#define GETFILE_SUCCESS(x) ((x) <= 0)
#define MODIFIABLE(buf) (buf->b_p_ma)
@ -80,18 +83,10 @@ typedef struct {
// Mask to check for flags that prevent normal writing
#define BF_WRITE_MASK (BF_NOTEDITED + BF_NEW + BF_READERR)
typedef struct window_S win_T;
typedef struct wininfo_S wininfo_T;
typedef struct frame_S frame_T;
typedef uint64_t disptick_T; // display tick type
#include "nvim/memline_defs.h"
#include "nvim/os/fs_defs.h"
#include "nvim/regexp_defs.h"
#include "nvim/sign_defs.h"
#include "nvim/syntax_defs.h"
#include "nvim/terminal.h"
// The taggy struct is used to store the information about a :tag command.
typedef struct taggy {
char *tagname; // tag name

View File

@ -44,6 +44,7 @@
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/textformat.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"

View File

@ -34,6 +34,7 @@
#include "nvim/os/shell.h"
#include "nvim/path.h"
#include "nvim/rbuffer.h"
#include "nvim/terminal.h"
#include "nvim/types_defs.h"
#ifdef MSWIN

View File

@ -27,6 +27,7 @@
#include "nvim/path.h"
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -22,6 +22,7 @@
#include "nvim/plines.h"
#include "nvim/pos_defs.h"
#include "nvim/state.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -8,6 +8,7 @@
#include <string.h>
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/debugger.h"
@ -32,6 +33,7 @@
#include "nvim/regexp.h"
#include "nvim/runtime.h"
#include "nvim/state_defs.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
/// batch mode debugging: don't save and restore typeahead.

View File

@ -6,6 +6,7 @@
#include "nvim/api/extmark.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/buffer_defs.h"
#include "nvim/decoration.h"
#include "nvim/drawscreen.h"
#include "nvim/extmark.h"

View File

@ -5,7 +5,7 @@
#include <stdint.h>
#include "klib/kvec.h"
#include "nvim/buffer_defs.h"
#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/decoration_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
#include "nvim/marktree_defs.h"

View File

@ -10,6 +10,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/debugger.h"

View File

@ -39,6 +39,7 @@
#include "nvim/pos_defs.h"
#include "nvim/quickfix.h"
#include "nvim/runtime.h"
#include "nvim/types_defs.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"

View File

@ -6,6 +6,7 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_eval_defs.h"
#include "nvim/normal_defs.h"
#include "nvim/os/time_defs.h"
#include "nvim/pos_defs.h"
#include "nvim/regexp_defs.h"

View File

@ -34,6 +34,7 @@
#include "nvim/path.h"
#include "nvim/pos_defs.h"
#include "nvim/runtime.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"

View File

@ -39,6 +39,7 @@
#include "nvim/marktree.h"
#include "nvim/memline.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
#include "nvim/undo.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -51,6 +51,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/file_search.h"

View File

@ -36,7 +36,6 @@
#include "nvim/pos_defs.h"
#include "nvim/runtime.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"

View File

@ -15,6 +15,7 @@
#include "nvim/api/private/validate.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor_shape.h"

View File

@ -23,6 +23,7 @@
#include "nvim/search.h"
#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
// Find result cache for cpp_baseclass

View File

@ -16,6 +16,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor.h"

View File

@ -16,6 +16,7 @@
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/extmark.h"
#include "nvim/extmark_defs.h"
#include "nvim/fold.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
@ -37,6 +38,7 @@
#include "nvim/quickfix.h"
#include "nvim/strings.h"
#include "nvim/textobject.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
// This file contains routines to maintain and manipulate marks.

View File

@ -2,6 +2,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/extmark_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
#include "nvim/mark_defs.h" // IWYU pragma: export

View File

@ -60,6 +60,7 @@
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#define MEMFILE_PAGE_SIZE 4096 /// default page size

View File

@ -36,6 +36,7 @@
#include "nvim/sign.h"
#include "nvim/state_defs.h"
#include "nvim/statusline.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/ui_client.h"
#include "nvim/ui_compositor.h"

View File

@ -2,6 +2,7 @@
#include <stdbool.h>
#include <stdint.h> // IWYU pragma: keep
#include <string.h>
#include <time.h> // IWYU pragma: keep
#include "auto/config.h"

View File

@ -8,6 +8,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor.h"

View File

@ -70,6 +70,7 @@
#include "nvim/tag.h"
#include "nvim/textformat.h"
#include "nvim/textobject.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"

View File

@ -26,6 +26,7 @@
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/version.h"
#include "nvim/vim_defs.h"

View File

@ -8,6 +8,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"

View File

@ -8,6 +8,7 @@
#include "auto/config.h"
#include "klib/kvec.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"

View File

@ -7,6 +7,7 @@
#endif
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/event/defs.h"
#include "nvim/event/signal.h"

View File

@ -8,6 +8,7 @@
#include "auto/config.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/eval.h"

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/decoration.h"
#include "nvim/diff.h"

View File

@ -3,9 +3,9 @@
#include <stdbool.h>
#include <stdint.h> // IWYU pragma: keep
#include "nvim/buffer_defs.h"
#include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h"
/// Argument for lbr_chartabsize().
typedef struct {

View File

@ -38,6 +38,7 @@
#include "nvim/pos_defs.h"
#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/vim_defs.h"

View File

@ -14,6 +14,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"

View File

@ -1,5 +1,6 @@
#pragma once
#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/option_defs.h" // IWYU pragma: keep

View File

@ -15,6 +15,32 @@
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
enum {
/// The number of sub-matches is limited to 10.
/// The first one (index 0) is the whole match, referenced with "\0".
/// The second one (index 1) is the first sub-match, referenced with "\1".
/// This goes up to the tenth (index 9), referenced with "\9".
NSUBEXP = 10,
};
typedef struct regengine regengine_T;
/// Structure to be used for multi-line matching.
/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col"
/// and ends in line "endpos[no].lnum" just before column "endpos[no].col".
/// The line numbers are relative to the first line, thus startpos[0].lnum is
/// always 0.
/// When there is no match, the line number is -1.
typedef struct {
regprog_T *regprog;
lpos_T startpos[NSUBEXP];
lpos_T endpos[NSUBEXP];
colnr_T rmm_matchcol; ///< match start without "\zs"
int rmm_ic;
colnr_T rmm_maxcol; ///< when not zero: maximum column
} regmmatch_T;
/// Used for "magic_overruled".
typedef enum {
OPTION_MAGIC_NOT_SET, ///< p_magic not overruled
@ -33,14 +59,6 @@ typedef enum {
MAGIC_ALL = 4, ///< "\v" very magic
} magic_T;
enum {
/// The number of sub-matches is limited to 10.
/// The first one (index 0) is the whole match, referenced with "\0".
/// The second one (index 1) is the first sub-match, referenced with "\1".
/// This goes up to the tenth (index 9), referenced with "\9".
NSUBEXP = 10,
};
enum {
/// In the NFA engine: how many braces are allowed.
/// TODO(RE): Use dynamic memory allocation instead of static, like here
@ -61,28 +79,6 @@ enum {
NFA_ENGINE = 2,
};
typedef struct regengine regengine_T;
typedef struct regprog regprog_T;
typedef struct reg_extmatch reg_extmatch_T;
/// Structure to be used for multi-line matching.
/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col"
/// and ends in line "endpos[no].lnum" just before column "endpos[no].col".
/// The line numbers are relative to the first line, thus startpos[0].lnum is
/// always 0.
/// When there is no match, the line number is -1.
typedef struct {
regprog_T *regprog;
lpos_T startpos[NSUBEXP];
lpos_T endpos[NSUBEXP];
colnr_T rmm_matchcol; ///< match start without "\zs"
int rmm_ic;
colnr_T rmm_maxcol; ///< when not zero: maximum column
} regmmatch_T;
#include "nvim/buffer_defs.h"
/// Structure returned by vim_regcomp() to pass on to vim_regexec().
/// This is the general structure. For the actual matcher, two specific
/// structures are used. See code below.
@ -164,10 +160,10 @@ typedef struct {
/// Structure used to store external references: "\z\(\)" to "\z\1".
/// Use a reference count to avoid the need to copy this around. When it goes
/// from 1 to zero the matches need to be freed.
struct reg_extmatch {
typedef struct {
int16_t refcnt;
uint8_t *matches[NSUBEXP];
};
} reg_extmatch_T;
struct regengine {
/// bt_regcomp or nfa_regcomp

View File

@ -17,6 +17,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/debugger.h"

View File

@ -50,6 +50,7 @@
#include "nvim/search.h"
#include "nvim/shada.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/version.h"
#include "nvim/vim_defs.h"

View File

@ -264,6 +264,7 @@
#include "nvim/spell_defs.h"
#include "nvim/spellfile.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"

View File

@ -3,6 +3,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"

View File

@ -40,6 +40,7 @@
#include "nvim/state_defs.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"

View File

@ -1,6 +1,9 @@
#pragma once
#include "nvim/buffer_defs.h"
#include "nvim/garray_defs.h"
#include "nvim/highlight_defs.h"
#include "nvim/regexp_defs.h"
#define SST_MIN_ENTRIES 150 // minimal size for state stack array
#define SST_MAX_ENTRIES 1000 // maximal size for state stack array
@ -8,11 +11,6 @@
#define SST_DIST 16 // normal distance between entries
#define SST_INVALID ((synstate_T *)-1) // invalid syn_state pointer
typedef struct syn_state synstate_T;
#include "nvim/buffer_defs.h"
#include "nvim/regexp_defs.h"
// struct passed to in_id_list()
struct sp_syn {
int inc_tag; // ":syn include" unique tag

View File

@ -54,6 +54,7 @@
#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"

View File

@ -49,7 +49,6 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/channel.h"
#include "nvim/cursor.h"

View File

@ -4,13 +4,12 @@
#include <stddef.h>
#include <stdint.h>
typedef struct terminal Terminal;
#include "nvim/api/private/defs.h" // IWYU pragma: keep
typedef void (*terminal_write_cb)(const char *buffer, size_t size, void *data);
typedef void (*terminal_resize_cb)(uint16_t width, uint16_t height, void *data);
typedef void (*terminal_close_cb)(void *data);
#include "nvim/buffer_defs.h" // IWYU pragma: keep
typedef struct {
void *data; // PTY process channel
uint16_t width, height;

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
#include "nvim/edit.h"

View File

@ -55,3 +55,9 @@ typedef struct {
int add; // Number of signs added in the invalid range, negative for deleted signs.
} SignRange;
#define SIGNRANGE_INIT { 0, 0 }
typedef struct file_buffer buf_T;
typedef struct syn_state synstate_T;
typedef struct terminal Terminal;
typedef struct window_S win_T;
typedef struct regprog regprog_T;

View File

@ -14,6 +14,7 @@
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"

View File

@ -18,8 +18,6 @@ typedef struct {
colnr_T vi_curswant; ///< MAXCOL from w_curswant
} visualinfo_T;
#include "nvim/buffer_defs.h"
typedef struct u_entry u_entry_T;
struct u_entry {
u_entry_T *ue_next; ///< pointer to next entry in list

View File

@ -3,6 +3,7 @@
#include <stddef.h> // IWYU pragma: keep
#include <stdint.h>
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"

View File

@ -1,5 +1,6 @@
#pragma once
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"

View File

@ -1,13 +1,14 @@
#pragma once
#include "auto/config.h"
#include "nvim/os/os_defs.h" // IWYU pragma: keep
// Some defines from the old feature.h
#define SESSION_FILE "Session.vim"
#define MAX_MSG_HIST_LEN 200
#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
#define RUNTIME_DIRNAME "runtime"
#include "auto/config.h"
enum {
/// length of a buffer to store a number in ASCII (64 bits binary + NUL)
NUMBUFLEN = 65,
@ -56,8 +57,6 @@ typedef enum {
kCdCauseAuto, ///< On 'autochdir'.
} CdCause;
#include "nvim/os/os_defs.h" // IWYU pragma: keep
// return values for functions
#if !(defined(OK) && (OK == 1))
// OK already defined to 1 in MacOS X curses, skip this

View File

@ -19,6 +19,7 @@
#include "nvim/optionstr.h"
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"