Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: cleanup unused headers
Node codebase has evolved a lot in the more than 10 years of its
existence. As more features (and code) have been added, changed,
removed, it's sometimes hard to keep track of what gets used and what
not.

This commits attempts to clean some of those potentially left-over
headers using suggestions from  include-what-you-use

Refs: #27531
  • Loading branch information
alferpal committed Nov 28, 2019
commit 01d3211c9ab5f35a8da4785c4b689542ca09aa71
1 change: 0 additions & 1 deletion src/api/encoding.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "node.h"
#include "env-inl.h"
#include "string_bytes.h"
#include "util-inl.h"
#include "v8.h"
Expand Down
2 changes: 0 additions & 2 deletions src/api/utils.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "node.h"
#include "node_internals.h"
#include "util-inl.h"

#include <csignal>

Expand Down
1 change: 0 additions & 1 deletion src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "util-inl.h"

#include "v8.h"
#include "v8-profiler.h"

using v8::Context;
using v8::DontDelete;
Expand Down
10 changes: 7 additions & 3 deletions src/connect_wrap.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#include "connect_wrap.h"

#include "env-inl.h"
#include "req_wrap-inl.h"
#include "util-inl.h"

namespace v8 {
class Object;
template <class T> class Local;
} // namespace v8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file includes v8.h indirectly anyway, should we add this here? (ditto below?)

Like, any file that actively uses V8 APIs will have it included anyway, through node.h or otherwise…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look, remove the declarations and let you know of the result (sometime tomorrow afternoon / evening)

Copy link
Copy Markdown
Contributor Author

@alferpal alferpal Nov 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've removed the declarations you pointed, and they were as you said not needed.

Were the ones removed by my last commit all the ones you were referring to?



namespace node {

using v8::Local;
using v8::Object;

class Environment;

ConnectWrap::ConnectWrap(Environment* env,
Local<Object> req_wrap_obj,
Expand Down
9 changes: 7 additions & 2 deletions src/connect_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "env.h"
#include "req_wrap-inl.h"
#include "async_wrap.h"
#include "v8.h"

namespace v8 {
class Object;
template <class T> class Local;
} // namespace v8

namespace node {

class Environment;

class ConnectWrap : public ReqWrap<uv_connect_t> {
public:
ConnectWrap(Environment* env,
Expand Down
6 changes: 5 additions & 1 deletion src/connection_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "stream_wrap.h"
#include "v8.h"

namespace v8 {
class Object;
template <class T> class Local;
} // namespace v8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream_wrap.h is guaranteed to include v8.h because it defines a BaseObject subclass


namespace node {

Expand Down
2 changes: 0 additions & 2 deletions src/debug_utils.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "debug_utils.h"
#include "env-inl.h"
#include "util-inl.h"

#ifdef __POSIX__
#if defined(__linux__)
Expand Down
1 change: 0 additions & 1 deletion src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "node_errors.h"
#include "node_file.h"
#include "node_internals.h"
#include "node_native_module.h"
#include "node_options-inl.h"
#include "node_process.h"
#include "node_v8_platform-inl.h"
Expand Down
1 change: 0 additions & 1 deletion src/fs_event_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "async_wrap-inl.h"
#include "env-inl.h"
#include "util-inl.h"
#include "node.h"
#include "handle_wrap.h"
#include "string_bytes.h"
Expand Down
1 change: 0 additions & 1 deletion src/handle_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "async_wrap-inl.h"
#include "env-inl.h"
#include "util-inl.h"
#include "node.h"

namespace node {

Expand Down
1 change: 0 additions & 1 deletion src/js_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "async_wrap.h"
#include "env-inl.h"
#include "node_buffer.h"
#include "node_errors.h"
#include "stream_base-inl.h"
#include "util-inl.h"
Expand Down
9 changes: 8 additions & 1 deletion src/js_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@

#include "async_wrap.h"
#include "stream_base.h"
#include "v8.h"

namespace v8 {
class Context;
class Object;
class Value;
template <class T> class Local;
template <typename T> class FunctionCallbackInfo;
} // namespace v8

namespace node {

Expand Down
4 changes: 3 additions & 1 deletion src/module_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include <unordered_map>
#include <string>
#include <vector>
#include "node_url.h"
#include "base_object-inl.h"

namespace node {

class Environment;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base_object-inl.h is guaranteed to have a forward declaration of this because it uses it as a return type… however, it’s not great that base_object-inl.h is included here rather than base_object.h. Can we replace it with the latter?


namespace loader {

enum ScriptType : int {
Expand Down
11 changes: 8 additions & 3 deletions src/node_binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
#include "node.h"
#define NAPI_EXPERIMENTAL
#include "node_api.h"
#include "util.h"
#include "uv.h"
#include "v8.h"

namespace v8 {
class Context;
class Object;
class Value;
template <class T> class Local;
template <typename T> class FunctionCallbackInfo;
} // namespace v8

enum {
NM_F_BUILTIN = 1 << 0, // Unused.
Expand Down
1 change: 0 additions & 1 deletion src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "string_bytes.h"
#include "string_search.h"
#include "util-inl.h"
#include "v8-profiler.h"
#include "v8.h"

#include <cstring>
Expand Down
2 changes: 0 additions & 2 deletions src/node_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node.h"
#include "util.h"
#include "env.h"
#include "v8.h"

Expand Down
5 changes: 4 additions & 1 deletion src/node_watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "v8.h"
#include "uv.h"
#include "node_mutex.h"
#include <vector>
Expand All @@ -33,6 +32,10 @@
#include <pthread.h>
#endif

namespace v8 {
class Isolate;
}

namespace node {

class Watchdog {
Expand Down
1 change: 0 additions & 1 deletion src/stream_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include "stream_base.h"
#include "handle_wrap.h"
#include "string_bytes.h"
#include "v8.h"

namespace node {
Expand Down
1 change: 0 additions & 1 deletion src/string_decoder-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "string_decoder.h"
#include "util.h"

namespace node {

Expand Down
6 changes: 5 additions & 1 deletion src/tracing/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "libplatform/v8-tracing.h"
#include "uv.h"
#include "v8.h"
#include "util.h"
#include "node_mutex.h"

Expand All @@ -12,6 +11,11 @@
#include <string>
#include <unordered_map>

namespace v8 {
class ConvertableToTraceFormat;
class TracingController;
}
Comment thread
lundibundi marked this conversation as resolved.
Outdated

namespace node {
namespace tracing {

Expand Down
2 changes: 1 addition & 1 deletion src/udp_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "async_wrap.h"
#include "handle_wrap.h"
#include "uv.h"
#include "v8.h"

namespace node {

class AsyncWrap;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle_wrap.h is guaranteed to provide AsyncWrap because including it defines a subclass of AsyncWrap

class Environment;

class UDPWrap: public HandleWrap {
Expand Down