// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Containers/UnrealString.h" #include "CoreGlobals.h" #include "DataValidationModule.h" #include "EditorValidatorBase.h" #include "HAL/Platform.h" #include "Logging/LogVerbosity.h" #include "Misc/OutputDevice.h" #include "Misc/OutputDeviceRedirector.h" #include "UObject/NameTypes.h" #include "UObject/UObjectGlobals.h" #include "EditorValidator.generated.h" class UObject; class FLyraValidationMessageGatherer : public FOutputDevice { public: FLyraValidationMessageGatherer() : FOutputDevice() { GLog->AddOutputDevice(this); } virtual ~FLyraValidationMessageGatherer() { GLog->RemoveOutputDevice(this); } virtual void Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category) override { if (Verbosity <= ELogVerbosity::Warning) { FString MessageString(V); bool bIgnored = false; for (const FString& IgnorePattern : IgnorePatterns) { if (MessageString.Contains(IgnorePattern)) { bIgnored = true; break; } } if (!bIgnored) { AllWarningsAndErrors.Add(MessageString); if (Verbosity == ELogVerbosity::Warning) { AllWarnings.Add(MessageString); } } } } const TArray& GetAllWarningsAndErrors() const { return AllWarningsAndErrors; } const TArray& GetAllWarnings() const { return AllWarnings; } static void AddIgnorePatterns(const TArray& NewPatterns) { IgnorePatterns.Append(NewPatterns); } static void RemoveIgnorePatterns(const TArray& PatternsToRemove) { for (const FString& PatternToRemove : PatternsToRemove) { IgnorePatterns.RemoveSingleSwap(PatternToRemove); } } private: TArray AllWarningsAndErrors; TArray AllWarnings; static TArray IgnorePatterns; }; UCLASS(Abstract) class UEditorValidator : public UEditorValidatorBase { GENERATED_BODY() public: UEditorValidator(); static void ValidateCheckedOutContent(bool bInteractive, const EDataValidationUsecase InValidationUsecase); static bool ValidatePackages(const TArray& ExistingPackageNames, const TArray& DeletedPackageNames, int32 MaxPackagesToLoad, TArray& OutAllWarningsAndErrors, const EDataValidationUsecase InValidationUsecase); static bool ValidateProjectSettings(); static bool IsInUncookedFolder(const FString& PackageName, FString* OutUncookedFolderName = nullptr); static bool ShouldAllowFullValidation(); static void GetChangedAssetsForCode(class IAssetRegistry& AssetRegistry, const FString& ChangedHeaderLocalFilename, TArray& OutChangedPackageNames); protected: virtual bool CanValidateAsset_Implementation(UObject* InAsset) const override; static TArray TestMapsFolders; private: /** * Used by some validators to determine if it is okay to load referencing assets or other slow tasks. * This is not okay for fast operations like saving, but is fine for slower "check everything thoroughly" tests */ static bool bAllowFullValidationInEditor; };