aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-05 20:05:12 +0800
committerGitHub <noreply@github.com>2023-12-05 20:05:12 +0800
commit14572727261278e5bf68080c9369a8507f3d564f (patch)
treec918aa050d5d0735d0f055b37c721649eba3bc6c
parent0b74ad0a641f28d9d3da5353e98372d87078bd9d (diff)
downloadrneovim-14572727261278e5bf68080c9369a8507f3d564f.tar.gz
rneovim-14572727261278e5bf68080c9369a8507f3d564f.tar.bz2
rneovim-14572727261278e5bf68080c9369a8507f3d564f.zip
refactor(IWYU): move marktree types to marktree_defs.h (#26402)
-rw-r--r--Makefile5
-rwxr-xr-xsrc/clint.py5
-rw-r--r--src/nvim/api/buffer.c1
-rw-r--r--src/nvim/api/keysets_defs.h8
-rw-r--r--src/nvim/autocmd.h6
-rw-r--r--src/nvim/buffer_defs.h2
-rw-r--r--src/nvim/decoration.c1
-rw-r--r--src/nvim/decoration.h2
-rw-r--r--src/nvim/extmark.h8
-rw-r--r--src/nvim/marktree.c15
-rw-r--r--src/nvim/marktree.h83
-rw-r--r--src/nvim/marktree_defs.h83
-rw-r--r--src/nvim/plines.c1
-rw-r--r--src/nvim/plines.h4
14 files changed, 112 insertions, 112 deletions
diff --git a/Makefile b/Makefile
index 9d9c0c7816..0a807e65da 100644
--- a/Makefile
+++ b/Makefile
@@ -142,16 +142,13 @@ iwyu: build/.ran-cmake
cmake --preset iwyu
cmake --build build > build/iwyu.log
iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\
- |src/nvim/api/extmark.h\
|src/nvim/api/private/helpers.h\
|src/nvim/api/private/validate.h\
|src/nvim/assert_defs.h\
- |src/nvim/autocmd.h\
|src/nvim/buffer.h\
|src/nvim/buffer_defs.h\
|src/nvim/channel.h\
|src/nvim/charset.h\
- |src/nvim/decoration.h\
|src/nvim/drawline.h\
|src/nvim/eval.h\
|src/nvim/eval/encode.h\
@@ -169,7 +166,6 @@ iwyu: build/.ran-cmake
|src/nvim/event/stream.h\
|src/nvim/event/time.h\
|src/nvim/event/wstream.h\
- |src/nvim/extmark.h\
|src/nvim/garray.h\
|src/nvim/globals.h\
|src/nvim/grid.h\
@@ -188,7 +184,6 @@ iwyu: build/.ran-cmake
|src/nvim/os/pty_conpty_win.h\
|src/nvim/os/pty_process_unix.h\
|src/nvim/os/pty_process_win.h\
- |src/nvim/plines.h\
|src/nvim/tui/input.h\
|src/nvim/ui.h\
|src/nvim/viml/parser/expressions.h\
diff --git a/src/clint.py b/src/clint.py
index 596e2d8a26..ed5aaf43d2 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -900,16 +900,13 @@ def CheckIncludes(filename, lines, error):
# These should be synced with the ignored headers in the `iwyu` target in
# the Makefile.
check_includes_ignore = [
- "src/nvim/api/extmark.h",
"src/nvim/api/private/helpers.h",
"src/nvim/api/private/validate.h",
"src/nvim/assert_defs.h",
- "src/nvim/autocmd.h",
"src/nvim/buffer.h",
"src/nvim/buffer_defs.h",
"src/nvim/channel.h",
"src/nvim/charset.h",
- "src/nvim/decoration.h",
"src/nvim/drawline.h",
"src/nvim/eval.h",
"src/nvim/eval/encode.h",
@@ -927,7 +924,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/event/stream.h",
"src/nvim/event/time.h",
"src/nvim/event/wstream.h",
- "src/nvim/extmark.h",
"src/nvim/garray.h",
"src/nvim/globals.h",
"src/nvim/grid.h",
@@ -946,7 +942,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/os/pty_conpty_win.h",
"src/nvim/os/pty_process_unix.h",
"src/nvim/os/pty_process_win.h",
- "src/nvim/plines.h",
"src/nvim/tui/input.h",
"src/nvim/ui.h",
"src/nvim/viml/parser/expressions.h",
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index e0dd265167..99d261e73d 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -12,6 +12,7 @@
#include "nvim/api/buffer.h"
#include "nvim/api/keysets_defs.h"
#include "nvim/api/private/defs.h"
+#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
#include "nvim/ascii_defs.h"
diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h
index 5aae88f7b3..d1cbe43de0 100644
--- a/src/nvim/api/keysets_defs.h
+++ b/src/nvim/api/keysets_defs.h
@@ -3,6 +3,10 @@
#include "nvim/api/private/defs.h"
typedef struct {
+ OptionalKeys is_set__empty_;
+} Dict(empty);
+
+typedef struct {
OptionalKeys is_set__context_;
Array types;
} Dict(context);
@@ -338,10 +342,6 @@ typedef struct {
} Dict(buf_delete);
typedef struct {
- OptionalKeys is_set__empty_;
-} Dict(empty);
-
-typedef struct {
OptionalKeys is_set__open_term_;
LuaRef on_input;
} Dict(open_term);
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h
index 8ff4d75ddf..ea8f32feb2 100644
--- a/src/nvim/autocmd.h
+++ b/src/nvim/autocmd.h
@@ -1,9 +1,10 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
+#include <stddef.h> // IWYU pragma: keep
+#include <stdint.h> // IWYU pragma: keep
+#include "klib/kvec.h"
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/autocmd_defs.h" // IWYU pragma: export
#include "nvim/buffer_defs.h"
@@ -12,7 +13,6 @@
#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
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index b26d42385b..7402e66403 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -26,7 +26,7 @@ typedef struct {
#include "nvim/map_defs.h"
#include "nvim/mapping_defs.h"
#include "nvim/mark_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h"
#include "nvim/option_vars.h"
#include "nvim/pos_defs.h"
#include "nvim/statusline_defs.h"
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 11204a1b31..ccba8bd607 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -14,6 +14,7 @@
#include "nvim/grid.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
+#include "nvim/marktree.h"
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option_vars.h"
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index e5bac169dc..92e0cbc76b 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -8,7 +8,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/decoration_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h"
diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h
index 1a7a1ddeff..5ba079bd12 100644
--- a/src/nvim/extmark.h
+++ b/src/nvim/extmark.h
@@ -1,17 +1,15 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
#include <stdint.h>
#include "klib/kvec.h"
-#include "nvim/buffer_defs.h"
-#include "nvim/decoration.h"
+#include "nvim/buffer_defs.h" // IWYU pragma: keep
+#include "nvim/decoration_defs.h" // IWYU pragma: keep
#include "nvim/extmark_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h" // IWYU pragma: keep
#include "nvim/pos_defs.h"
-#include "nvim/types_defs.h"
EXTERN int curbuf_splice_pending INIT( = 0);
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index f14da1b605..fa5e7dcbe2 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -50,15 +50,15 @@
#include <sys/types.h>
#include "klib/kvec.h"
-#include "nvim/garray.h"
+#include "nvim/macros_defs.h"
+#include "nvim/map_defs.h"
#include "nvim/marktree.h"
#include "nvim/memory.h"
#include "nvim/pos_defs.h"
// only for debug functions
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/garray_defs.h"
-#include "nvim/macros_defs.h"
+#include "nvim/garray.h"
#define T MT_BRANCH_FACTOR
#define ILEN (sizeof(MTNode) + (2 * T) * sizeof(void *))
@@ -2200,7 +2200,12 @@ String mt_inspect(MarkTree *b, bool keys, bool dot)
return ga_take_string(ga);
}
-void mt_inspect_node(MarkTree *b, garray_T *ga, bool keys, MTNode *n, MTPos off)
+static inline uint64_t mt_dbg_id(uint64_t id)
+{
+ return (id >> 1) & 0xffffffff;
+}
+
+static void mt_inspect_node(MarkTree *b, garray_T *ga, bool keys, MTNode *n, MTPos off)
{
static char buf[1024];
GA_PUT("[");
@@ -2240,7 +2245,7 @@ void mt_inspect_node(MarkTree *b, garray_T *ga, bool keys, MTNode *n, MTPos off)
ga_concat(ga, "]");
}
-void mt_inspect_dotfile_node(MarkTree *b, garray_T *ga, MTNode *n, MTPos off, char *parent)
+static void mt_inspect_dotfile_node(MarkTree *b, garray_T *ga, MTNode *n, MTPos off, char *parent)
{
static char buf[1024];
char namebuf[64];
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index c76359d3f9..46d60a2b69 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -1,69 +1,15 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
+#include <stddef.h> // IWYU pragma: keep
#include <stdint.h>
-#include "klib/kvec.h"
#include "nvim/decoration_defs.h"
-#include "nvim/garray_defs.h" // IWYU pragma: keep
-#include "nvim/map_defs.h"
+#include "nvim/marktree_defs.h" // IWYU pragma: export
#include "nvim/pos_defs.h" // IWYU pragma: keep
// only for debug functions:
#include "nvim/api/private/defs.h" // IWYU pragma: keep
-#define MT_MAX_DEPTH 20
-#define MT_BRANCH_FACTOR 10
-// note max branch is actually 2*MT_BRANCH_FACTOR
-// and strictly this is ceil(log2(2*MT_BRANCH_FACTOR + 1))
-// as we need a pseudo-index for "right before this node"
-#define MT_LOG2_BRANCH 5
-
-typedef struct {
- int32_t row;
- int32_t col;
-} MTPos;
-#define MTPos(r, c) ((MTPos){ .row = (r), .col = (c) })
-
-typedef struct mtnode_s MTNode;
-
-typedef struct {
- MTPos pos;
- int lvl;
- MTNode *x;
- int i;
- struct {
- int oldcol;
- int i;
- } s[MT_MAX_DEPTH];
-
- size_t intersect_idx;
- MTPos intersect_pos;
- MTPos intersect_pos_x;
-} MarkTreeIter;
-
-#define marktree_itr_valid(itr) ((itr)->x != NULL)
-// access raw key: flags in MT_FLAG_EXTERNAL_MASK and decor_data are safe to modify.
-#define mt_itr_rawkey(itr) ((itr)->x->key[(itr)->i])
-
-// Internal storage
-//
-// NB: actual marks have flags > 0, so we can use (row,col,0) pseudo-key for
-// "space before (row,col)"
-typedef struct {
- MTPos pos;
- uint32_t ns;
- uint32_t id;
- uint16_t flags;
- DecorInlineData decor_data; // "ext" tag in flags
-} MTKey;
-
-typedef struct {
- MTKey start;
- MTPos end_pos;
- bool end_right_gravity;
-} MTPair;
-
#define MT_INVALID_KEY (MTKey) { { -1, -1 }, 0, 0, 0, { .hl = DECOR_HIGHLIGHT_INLINE_INIT } }
#define MT_FLAG_REAL (((uint16_t)1) << 0)
@@ -179,31 +125,6 @@ static inline DecorInline mt_decor(MTKey key)
return (DecorInline){ .ext = key.flags & MT_FLAG_DECOR_EXT, .data = key.decor_data };
}
-typedef kvec_withinit_t(uint64_t, 4) Intersection;
-
-struct mtnode_s {
- int32_t n;
- int16_t level;
- int16_t p_idx; // index in parent
- Intersection intersect;
- // TODO(bfredl): we could consider having a only-sometimes-valid
- // index into parent for faster "cached" lookup.
- MTNode *parent;
- MTKey key[2 * MT_BRANCH_FACTOR - 1];
- MTNode *ptr[];
-};
-
-static inline uint64_t mt_dbg_id(uint64_t id)
-{
- return (id>>1)&0xffffffff;
-}
-
-typedef struct {
- MTNode *root;
- size_t n_keys, n_nodes;
- PMap(uint64_t) id2node[1];
-} MarkTree;
-
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "marktree.h.generated.h"
#endif
diff --git a/src/nvim/marktree_defs.h b/src/nvim/marktree_defs.h
new file mode 100644
index 0000000000..8aa1b1e376
--- /dev/null
+++ b/src/nvim/marktree_defs.h
@@ -0,0 +1,83 @@
+#pragma once
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "klib/kvec.h"
+#include "nvim/decoration_defs.h"
+#include "nvim/map_defs.h"
+
+enum {
+ MT_MAX_DEPTH = 20,
+ MT_BRANCH_FACTOR = 10,
+ // note max branch is actually 2*MT_BRANCH_FACTOR
+ // and strictly this is ceil(log2(2*MT_BRANCH_FACTOR + 1))
+ // as we need a pseudo-index for "right before this node"
+ MT_LOG2_BRANCH = 5,
+};
+
+typedef struct {
+ int32_t row;
+ int32_t col;
+} MTPos;
+#define MTPos(r, c) ((MTPos){ .row = (r), .col = (c) })
+
+typedef struct mtnode_s MTNode;
+
+typedef struct {
+ MTPos pos;
+ int lvl;
+ MTNode *x;
+ int i;
+ struct {
+ int oldcol;
+ int i;
+ } s[MT_MAX_DEPTH];
+
+ size_t intersect_idx;
+ MTPos intersect_pos;
+ MTPos intersect_pos_x;
+} MarkTreeIter;
+
+#define marktree_itr_valid(itr) ((itr)->x != NULL)
+// access raw key: flags in MT_FLAG_EXTERNAL_MASK and decor_data are safe to modify.
+#define mt_itr_rawkey(itr) ((itr)->x->key[(itr)->i])
+
+// Internal storage
+//
+// NB: actual marks have flags > 0, so we can use (row,col,0) pseudo-key for
+// "space before (row,col)"
+typedef struct {
+ MTPos pos;
+ uint32_t ns;
+ uint32_t id;
+ uint16_t flags;
+ DecorInlineData decor_data; // "ext" tag in flags
+} MTKey;
+
+typedef struct {
+ MTKey start;
+ MTPos end_pos;
+ bool end_right_gravity;
+} MTPair;
+
+typedef kvec_withinit_t(uint64_t, 4) Intersection;
+
+struct mtnode_s {
+ int32_t n;
+ int16_t level;
+ int16_t p_idx; // index in parent
+ Intersection intersect;
+ // TODO(bfredl): we could consider having a only-sometimes-valid
+ // index into parent for faster "cached" lookup.
+ MTNode *parent;
+ MTKey key[2 * MT_BRANCH_FACTOR - 1];
+ MTNode *ptr[];
+};
+
+typedef struct {
+ MTNode *root;
+ size_t n_keys, n_nodes;
+ PMap(uint64_t) id2node[1];
+} MarkTree;
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index fbddb1ab4a..cbfaa4ace3 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -14,6 +14,7 @@
#include "nvim/indent.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
+#include "nvim/marktree.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/move.h"
diff --git a/src/nvim/plines.h b/src/nvim/plines.h
index 6aede88c8b..7227db4524 100644
--- a/src/nvim/plines.h
+++ b/src/nvim/plines.h
@@ -1,10 +1,10 @@
#pragma once
#include <stdbool.h>
-#include <stdint.h>
+#include <stdint.h> // IWYU pragma: keep
#include "nvim/buffer_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" // IWYU pragma: keep
/// Argument for lbr_chartabsize().