From 15beb42d5f6968e053a22d40458dec4e10e99503 Mon Sep 17 00:00:00 2001 From: jyelon Date: Wed, 8 Apr 2026 03:26:22 -0400 Subject: [PATCH] IWYU cleanup done --- Docs/TASKS/IWYU.md | 50 +++++++++++++++++++ .../UEWingman/Private/WingComponent.cpp | 3 -- .../Source/UEWingman/Private/WingUtils.cpp | 14 ------ .../{Private => Public}/WingLogCapture.h | 0 .../{Private => Public}/WingModule.h | 0 tools/clangd-query.py | 12 +++-- 6 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 Docs/TASKS/IWYU.md rename Plugins/UEWingman/Source/UEWingman/{Private => Public}/WingLogCapture.h (100%) rename Plugins/UEWingman/Source/UEWingman/{Private => Public}/WingModule.h (100%) diff --git a/Docs/TASKS/IWYU.md b/Docs/TASKS/IWYU.md new file mode 100644 index 00000000..e812deaa --- /dev/null +++ b/Docs/TASKS/IWYU.md @@ -0,0 +1,50 @@ +Your job is to remove unnecessary include-files from a +single C++ source file in UE Wingman, and also, add missing +includes. + +Remember: not all removals that compile are good according +to the principles of IWYU. A source file should include or +forward-define everything it uses, and should include +nothing that it doesn't. You will need to think seriously. + +To test your work, you will need to do a build: + + python3 build.py c++ + +followed by: + + tools/clangd-query.py diagnostics + +Sometimes, clangd gets desynchronized. If clangd is +reporting an error on UCLASS or on GENERATED_BODY after a +successful build, then clangd is out of sync. In that case, +you will need to refresh clangd: + + tools/clangd-query.py stop + +Then you can try again with the diagnostics. If the testing +reveals a mistake, please fix it and then redo the testing. + +Start by reading the head of TODO.txt, which lists the files +that need to be cleaned. Please clean up the first file on +the todo list, then remove that one file from the todo list. +Then you are done. + +One special exception to IWYU: all unreal code should include +CoreMinimal.h, no matter what. + +There is no need to run clangd before you begin. These +files are already clangd-clean. + +Do not be chatty about it. Just begin, get it cleaned, and +then very concisely report your results. And once again: do +not forget the principle of IWYU: not all removals that +compile are good. If a file is using a symbol, it should +include it or forward-define it, not rely on transitive +includes. Remove what should be removed, add what should be +added. + + + + + diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingComponent.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingComponent.cpp index c7457c32..b2296154 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingComponent.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingComponent.cpp @@ -1,11 +1,8 @@ #include "WingComponent.h" #include "WingTypes.h" #include "WingUtils.h" -#include "WingBasics.h" -#include "Engine/Blueprint.h" #include "Engine/SCS_Node.h" #include "Engine/SimpleConstructionScript.h" -#include "Components/ActorComponent.h" #include "Components/SceneComponent.h" #include "GameFramework/Actor.h" #include "Kismet2/BlueprintEditorUtils.h" diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp index d26ae413..638b28e5 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp @@ -1,28 +1,15 @@ #include "WingUtils.h" -#include "WingComponent.h" #include "WingProperty.h" #include "WingTypes.h" #include "WingServer.h" -#include "WingBasics.h" #include "WingTokenizer.h" #include "PropertyHandle.h" -#include "Engine/Blueprint.h" -#include "Engine/MemberReference.h" #include "Engine/World.h" -#include "Components/ActorComponent.h" #include "Engine/SCS_Node.h" -#include "EdGraph/EdGraph.h" -#include "EdGraph/EdGraphNode.h" -#include "EdGraph/EdGraphPin.h" -#include "K2Node_EditablePinBase.h" -#include "EdGraph/EdGraphSchema.h" #include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/Kismet2NameValidators.h" -#include "Kismet2/KismetEditorUtilities.h" #include "UObject/UObjectIterator.h" #include "UObject/UnrealType.h" -#include "Misc/Paths.h" -#include "Misc/PackageName.h" // Reparent validation #include "Engine/LevelScriptActor.h" @@ -36,7 +23,6 @@ // Material support #include "Materials/Material.h" -#include "Materials/MaterialExpression.h" #include "Materials/MaterialFunction.h" #include "Materials/MaterialInstanceConstant.h" #include "MaterialGraph/MaterialGraph.h" diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingLogCapture.h b/Plugins/UEWingman/Source/UEWingman/Public/WingLogCapture.h similarity index 100% rename from Plugins/UEWingman/Source/UEWingman/Private/WingLogCapture.h rename to Plugins/UEWingman/Source/UEWingman/Public/WingLogCapture.h diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingModule.h b/Plugins/UEWingman/Source/UEWingman/Public/WingModule.h similarity index 100% rename from Plugins/UEWingman/Source/UEWingman/Private/WingModule.h rename to Plugins/UEWingman/Source/UEWingman/Public/WingModule.h diff --git a/tools/clangd-query.py b/tools/clangd-query.py index 456eb091..ee5f2eaa 100755 --- a/tools/clangd-query.py +++ b/tools/clangd-query.py @@ -3,12 +3,14 @@ Usage: python3 tools/clangd-query.py symbol + python3 tools/clangd-query.py diagnostics python3 tools/clangd-query.py definition python3 tools/clangd-query.py references python3 tools/clangd-query.py stop Commands: symbol Search for symbols by name across the project. + diagnostics Report clangd diagnostics for a file. definition Find where a symbol is defined. references Find all references to a symbol. stop Stop the background daemon. @@ -22,15 +24,15 @@ Examples: How it works: The first invocation starts a background clangd daemon process. It loads - the project index from .vscode/.cache/clangd/index/ (shared with VS Code's - clangd). This takes ~10 seconds. Subsequent queries hit the warm daemon - and return in milliseconds. + the project through a dedicated .clangd-query compile-commands directory, + which gives it a separate clangd cache. This takes ~10 seconds. + Subsequent queries hit the warm daemon and return in milliseconds. Clangd configuration (binary path, flags) is read from Integration.code-workspace so it stays in sync with VS Code. - The daemon writes its PID to .clangd-query.pid and listens on a Unix - socket at .clangd-query.sock. Use 'stop' to shut it down, or just kill + The daemon writes its PID to .clangd-query/pid and listens on a Unix + socket at .clangd-query/sock. Use 'stop' to shut it down, or just kill the PID. Starting a new daemon automatically kills any existing one. """