You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Merging //UE4/Release-4.18 @ CL 3709383 to Release-Staging-4.18 (//UE4/Release-Staging-4.18)
#rb none #jira [CL 3715930 by Ben Marsh in Staging-4.18 branch]
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "XCodeSourceCodeAccessModule.h"
|
||||
#include "ISourceCodeAccessModule.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "Misc/UProjectInfo.h"
|
||||
#include "Misc/App.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "XCodeSourceCodeAccessor"
|
||||
|
||||
@@ -73,6 +75,34 @@ static const char* SaveAllXcodeDocuments =
|
||||
" end SaveAllXcodeDocuments\n"
|
||||
;
|
||||
|
||||
void FXCodeSourceCodeAccessor::Startup()
|
||||
{
|
||||
GetSolutionPath();
|
||||
}
|
||||
|
||||
void FXCodeSourceCodeAccessor::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
FString FXCodeSourceCodeAccessor::GetSolutionPath() const
|
||||
{
|
||||
if(IsInGameThread())
|
||||
{
|
||||
CachedSolutionPath = FPaths::ProjectDir();
|
||||
|
||||
if (!FUProjectDictionary(FPaths::RootDir()).IsForeignProject(CachedSolutionPath))
|
||||
{
|
||||
CachedSolutionPath = FPaths::Combine(FPaths::RootDir(), + TEXT("UE4.xcworkspace/contents.xcworkspacedata"));
|
||||
}
|
||||
else
|
||||
{
|
||||
FString BaseName = FApp::HasProjectName() ? FApp::GetProjectName() : FPaths::GetBaseFilename(CachedSolutionPath);
|
||||
CachedSolutionPath = FPaths::Combine(CachedSolutionPath, BaseName + TEXT(".xcworkspace/contents.xcworkspacedata"));
|
||||
}
|
||||
}
|
||||
return CachedSolutionPath;
|
||||
}
|
||||
|
||||
bool FXCodeSourceCodeAccessor::CanAccessSourceCode() const
|
||||
{
|
||||
return IFileManager::Get().DirectoryExists(*FPlatformMisc::GetXcodePath());
|
||||
@@ -95,19 +125,36 @@ FText FXCodeSourceCodeAccessor::GetDescriptionText() const
|
||||
|
||||
bool FXCodeSourceCodeAccessor::OpenSolution()
|
||||
{
|
||||
FString SolutionPath;
|
||||
if(FDesktopPlatformModule::Get()->GetSolutionPath(SolutionPath))
|
||||
return OpenSolutionAtPath(GetSolutionPath());
|
||||
}
|
||||
|
||||
bool FXCodeSourceCodeAccessor::OpenSolutionAtPath(const FString& InSolutionPath)
|
||||
{
|
||||
FString SolutionPath = InSolutionPath;
|
||||
FString Extension = FPaths::GetExtension(SolutionPath);
|
||||
if (!SolutionPath.EndsWith(TEXT("xcworkspacedata")))
|
||||
{
|
||||
const FString FullPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead( *SolutionPath );
|
||||
if ( FPaths::FileExists( FullPath ) )
|
||||
{
|
||||
FPlatformProcess::LaunchFileInDefaultExternalApplication( *FullPath );
|
||||
return true;
|
||||
}
|
||||
SolutionPath = SolutionPath + TEXT(".xcworkspace/contents.xcworkspacedata");
|
||||
}
|
||||
|
||||
const FString FullPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead( *SolutionPath );
|
||||
UE_LOG(LogXcodeAccessor, Display, TEXT("%s"), *FullPath);
|
||||
if ( FPaths::FileExists( FullPath ) )
|
||||
{
|
||||
FPlatformProcess::LaunchFileInDefaultExternalApplication( *FullPath );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FXCodeSourceCodeAccessor::DoesSolutionExist() const
|
||||
{
|
||||
FString SolutionPath = GetSolutionPath();
|
||||
const FString FullPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead( *SolutionPath );
|
||||
return FPaths::FileExists( FullPath );
|
||||
}
|
||||
|
||||
bool FXCodeSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber)
|
||||
{
|
||||
ISourceCodeAccessModule& SourceCodeAccessModule = FModuleManager::LoadModuleChecked<ISourceCodeAccessModule>(TEXT("SourceCodeAccess"));
|
||||
@@ -124,8 +171,7 @@ bool FXCodeSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 Lin
|
||||
|
||||
bool ExecutionSucceeded = false;
|
||||
|
||||
FString SolutionPath;
|
||||
if(FDesktopPlatformModule::Get()->GetSolutionPath(SolutionPath))
|
||||
FString SolutionPath = GetSolutionPath();
|
||||
{
|
||||
const FString ProjPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead( *SolutionPath );
|
||||
if ( FPaths::FileExists( ProjPath ) )
|
||||
@@ -266,4 +312,4 @@ void FXCodeSourceCodeAccessor::Tick(const float DeltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
class FXCodeSourceCodeAccessor : public ISourceCodeAccessor
|
||||
{
|
||||
public:
|
||||
|
||||
/** Initialise internal systems, register delegates etc. */
|
||||
void Startup();
|
||||
|
||||
/** Shut down internal systems, unregister delegates etc. */
|
||||
void Shutdown();
|
||||
|
||||
/** ISourceCodeAccessor implementation */
|
||||
virtual void RefreshAvailability() override { }
|
||||
virtual bool CanAccessSourceCode() const override;
|
||||
@@ -14,9 +21,16 @@ public:
|
||||
virtual FText GetNameText() const override;
|
||||
virtual FText GetDescriptionText() const override;
|
||||
virtual bool OpenSolution() override;
|
||||
virtual bool OpenSolutionAtPath(const FString& InSolutionPath) override;
|
||||
virtual bool DoesSolutionExist() const override;
|
||||
virtual bool OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber = 0) override;
|
||||
virtual bool OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths) override;
|
||||
virtual bool AddSourceFiles(const TArray<FString>& AbsoluteSourcePaths, const TArray<FString>& AvailableModules) override;
|
||||
virtual bool SaveAllOpenDocuments() const override;
|
||||
virtual void Tick(const float DeltaTime) override;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
FString GetSolutionPath() const;
|
||||
mutable FString CachedSolutionPath;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user