diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-22 13:32:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-22 13:32:46 +0800 |
commit | ba0fa4fa197330687b06c74a50b2ccd4800f5881 (patch) | |
tree | 13c4be404f1a3e3480a555d06ff627cb6002c5c4 | |
parent | 089b934352437ab310a6dd3b138c7ed9445a3d7b (diff) | |
download | rneovim-ba0fa4fa197330687b06c74a50b2ccd4800f5881.tar.gz rneovim-ba0fa4fa197330687b06c74a50b2ccd4800f5881.tar.bz2 rneovim-ba0fa4fa197330687b06c74a50b2ccd4800f5881.zip |
refactor(IWYU): add "private" pragma to more generated headers (#26706)
"export" only prevents IWYU from adding these headers if the headers
that export them are included, while "private" ensures that IWYU never
adds these headers.
-rw-r--r-- | src/nvim/api/private/dispatch.h | 4 | ||||
-rw-r--r-- | src/nvim/api/ui.h | 2 | ||||
-rw-r--r-- | src/nvim/generators/gen_api_dispatch.lua | 14 | ||||
-rw-r--r-- | src/nvim/generators/gen_declarations.lua | 16 | ||||
-rw-r--r-- | src/nvim/option.c | 1 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ui.h | 2 | ||||
-rw-r--r-- | src/nvim/ui_client.h | 2 |
8 files changed, 30 insertions, 13 deletions
diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h index d322c1ceca..9b167a7b9e 100644 --- a/src/nvim/api/private/dispatch.h +++ b/src/nvim/api/private/dispatch.h @@ -26,6 +26,6 @@ extern const MsgpackRpcRequestHandler method_handlers[]; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/private/dispatch.h.generated.h" -# include "api/private/dispatch_wrappers.h.generated.h" // IWYU pragma: export -# include "keysets_defs.generated.h" // IWYU pragma: export +# include "api/private/dispatch_wrappers.h.generated.h" +# include "keysets_defs.generated.h" #endif diff --git a/src/nvim/api/ui.h b/src/nvim/api/ui.h index b1f4ff97d9..9147f1d870 100644 --- a/src/nvim/api/ui.h +++ b/src/nvim/api/ui.h @@ -9,5 +9,5 @@ #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/ui.h.generated.h" -# include "ui_events_remote.h.generated.h" // IWYU pragma: export +# include "ui_events_remote.h.generated.h" #endif diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 5928999967..791edfff96 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -106,7 +106,7 @@ for i = 6, #arg do end headers[#headers + 1] = parts[#parts - 1] .. '/' .. parts[#parts] - local input = io.open(full_path, 'rb') + local input = assert(io.open(full_path, 'rb')) local tmp = c_grammar.grammar:match(input:read('*all')) for j = 1, #tmp do @@ -216,16 +216,16 @@ end -- serialize the API metadata using msgpack and embed into the resulting -- binary for easy querying by clients -local funcs_metadata_output = io.open(funcs_metadata_outputf, 'wb') +local funcs_metadata_output = assert(io.open(funcs_metadata_outputf, 'wb')) local packed = mpack.encode(exported_functions) local dump_bin_array = require('generators.dump_bin_array') dump_bin_array(funcs_metadata_output, 'funcs_metadata', packed) funcs_metadata_output:close() -- start building the dispatch wrapper output -local output = io.open(dispatch_outputf, 'wb') +local output = assert(io.open(dispatch_outputf, 'wb')) -local keysets_defs = io.open(keysets_outputf, 'wb') +local keysets_defs = assert(io.open(keysets_outputf, 'wb')) -- =========================================================================== -- NEW API FILES MUST GO HERE. @@ -257,6 +257,8 @@ output:write([[ ]]) +keysets_defs:write('// IWYU pragma: private, include "nvim/api/private/dispatch.h"\n\n') + for _, k in ipairs(keysets) do local c_name = {} @@ -633,7 +635,7 @@ output:write(hashfun) output:close() functions.keysets = keysets -local mpack_output = io.open(mpack_outputf, 'wb') +local mpack_output = assert(io.open(mpack_outputf, 'wb')) mpack_output:write(mpack.encode(functions)) mpack_output:close() @@ -653,7 +655,7 @@ local function write_shifted_output(_, str) end -- start building lua output -output = io.open(lua_c_bindings_outputf, 'wb') +output = assert(io.open(lua_c_bindings_outputf, 'wb')) output:write([[ #include <lua.h> diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index 9fd2750f52..5d1e586fe6 100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -207,6 +207,22 @@ if fname:find('.*/src/nvim/.*%.c$') then // IWYU pragma: private, include "%s" ]]):format(header_fname:gsub('.*/src/nvim/', 'nvim/')) .. non_static end +elseif non_static_fname:find('/include/api/private/dispatch_wrappers%.h%.generated%.h$') then + non_static = [[ +// IWYU pragma: private, include "nvim/api/private/dispatch.h" +]] .. non_static +elseif non_static_fname:find('/include/ui_events_call%.h%.generated%.h$') then + non_static = [[ +// IWYU pragma: private, include "nvim/ui.h" +]] .. non_static +elseif non_static_fname:find('/include/ui_events_client%.h%.generated%.h$') then + non_static = [[ +// IWYU pragma: private, include "nvim/ui_client.h" +]] .. non_static +elseif non_static_fname:find('/include/ui_events_remote%.h%.generated%.h$') then + non_static = [[ +// IWYU pragma: private, include "nvim/api/ui.h" +]] .. non_static end local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"' diff --git a/src/nvim/option.c b/src/nvim/option.c index 49a8c468d6..4969ac7f1d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2,7 +2,6 @@ // - Put it in options.lua // - For a global option: Add a variable for it in option_vars.h. // - For a buffer or window local option: -// - Add a BV_XX or WV_XX entry to option_vars.h // - Add a variable to the window or buffer struct in buffer_defs.h. // - For a window option, add some code to copy_winopt(). // - For a window string option, add code to check_winopt() diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 62c02989a2..72fb5a92fc 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -131,5 +131,5 @@ typedef enum { } OptReqScope; #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "options_enum.generated.h" // IWYU pragma: export +# include "options_enum.generated.h" #endif diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 8b00e4e917..b783e4b6d3 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -27,7 +27,7 @@ EXTERN const char *ui_ext_names[] INIT( = { // uncrustify:off #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui.h.generated.h" -# include "ui_events_call.h.generated.h" // IWYU pragma: export +# include "ui_events_call.h.generated.h" #endif // uncrustify:on diff --git a/src/nvim/ui_client.h b/src/nvim/ui_client.h index 93170ed86d..8603ae9ca1 100644 --- a/src/nvim/ui_client.h +++ b/src/nvim/ui_client.h @@ -39,6 +39,6 @@ EXTERN bool ui_client_forward_stdin INIT( = false); // uncrustify:off #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui_client.h.generated.h" -# include "ui_events_client.h.generated.h" // IWYU pragma: export +# include "ui_events_client.h.generated.h" #endif // uncrustify:on |