bool FCodeLiteSourceCodeAccessor::OpenSolution() { FString Filename = FPaths::GetBaseFilename(GetSolutionPath()) + ".workspace"; FString Directory = FPaths::GetPath(GetSolutionPath()); FString Solution = "\"" + Directory + "/" + Filename + "\""; FString CodeLitePath; if(!CanRunCodeLite(CodeLitePath)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSolution: Cannot find CodeLite binary")); return false; } UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSolution: %s %s"), *CodeLitePath, *Solution); #ifdef USE_DBUS // // TODO Somehow codelite is not opening the workspace using GetWorkspace()->Open(...) // DBusMessage* message = nullptr; DBusMessageIter args; // Create new message. message = dbus_message_new_signal ("/org/codelite/command", "org.codelite.command", "OpenWorkSpace"); char* fileName = TCHAR_TO_ANSI(*Solution); // Add parameters to the message. dbus_message_iter_init_append(message, &args); if(!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &fileName)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("Sdbus_message_iter_append_basic failed.")); return false; } // Send the message. dbus_connection_send(DBusConnection, message, nullptr); if(dbus_error_is_set(&DBusError)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("dbus_connection_send failed: %s"), DBusError.message); return false; } // Free the message resources. dbus_message_unref(message); return true; #else FProcHandle Proc = FPlatformProcess::CreateProc(*CodeLitePath, *Solution, true, false, false, nullptr, 0, nullptr, nullptr); if(Proc.IsValid()) { FPlatformProcess::CloseProc(Proc); return true; } return false; #endif }
bool FCodeLiteSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber) { FString CodeLitePath; if(!CanRunCodeLite(CodeLitePath)) { UE_LOG(LogCodeLiteAccessor,Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenFileAtLine: Cannot find CodeLite binary")); return false; } #ifdef USE_DBUS DBusMessage* message = nullptr; DBusMessageIter args; // Create new message. message = dbus_message_new_signal ("/org/codelite/command", "org.codelite.command", "OpenFileAtLine"); char* fileName = TCHAR_TO_ANSI(*FullPath); // Add parameters to the message. dbus_message_iter_init_append(message, &args); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &fileName)) { printf("FCodeLiteSourceCodeAccessor::OpenFileAtLine: dbus_message_iter_append_basic failed.\n"); } if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &LineNumber)) { printf("FCodeLiteSourceCodeAccessor::OpenFileAtLine: dbus_message_iter_append_basic failed.\n"); } // Send the message. dbus_connection_send(DBusConnection, message, nullptr); if(dbus_error_is_set(&DBusError)) { printf("dbus_connection_send failed (%s)\n", DBusError.message); return false; } dbus_connection_flush(DBusConnection); // Free the message resources. dbus_message_unref (message); #else const FString Path = FString::Printf(TEXT("\"%s --line=%d\""), *FullPath, LineNumber); if(FPlatformProcess::CreateProc(*CodeLitePath, *Path, true, true, false, nullptr, 0, nullptr, nullptr).IsValid()) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSolution: Cannot find CodeLite binary")); } #endif UE_LOG(LogCodeLiteAccessor, Warning, TEXT("CodeLiteSourceCodeAccessor::OpenFileAtLine: %s %d"), *FullPath, LineNumber); return true; }
bool FCodeLiteSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber) { FString CodeLitePath; if(!CanRunCodeLite(CodeLitePath)) { UE_LOG(LogCodeLiteAccessor,Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenFileAtLine: Cannot find CodeLite binary")); return false; } const FString Path = FString::Printf(TEXT("\"%s --line=%d\""), *FullPath, LineNumber); if(FPlatformProcess::CreateProc(*CodeLitePath, *Path, true, true, false, nullptr, 0, nullptr, nullptr).IsValid()) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSolution: Cannot find CodeLite binary")); } UE_LOG(LogCodeLiteAccessor, Warning, TEXT("CodeLiteSourceCodeAccessor::OpenFileAtLine: %s %d"), *FullPath, LineNumber); return true; }
bool FCodeLiteSourceCodeAccessor::OpenSolution() { FString Filename = FPaths::GetBaseFilename(GetSolutionPath()) + ".workspace"; FString Directory = FPaths::GetPath(GetSolutionPath()); FString Solution = "\"" + Directory + "/" + Filename + "\""; FString CodeLitePath; if(!CanRunCodeLite(CodeLitePath)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSolution: Cannot find CodeLite binary")); return false; } UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSolution: %s %s"), *CodeLitePath, *Solution); FProcHandle Proc = FPlatformProcess::CreateProc(*CodeLitePath, *Solution, true, false, false, nullptr, 0, nullptr, nullptr); if(Proc.IsValid()) { FPlatformProcess::CloseProc(Proc); return true; } return false; }
bool FCodeLiteSourceCodeAccessor::OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths) { FString CodeLitePath; if(!CanRunCodeLite(CodeLitePath)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSourceFiles: Cannot find CodeLite binary")); return false; } for(const auto& SourcePath : AbsoluteSourcePaths) { const FString Path = FString::Printf(TEXT("\"%s\""), *SourcePath); FProcHandle Proc = FPlatformProcess::CreateProc(*CodeLitePath, *Path, true, false, false, nullptr, 0, nullptr, nullptr); if(Proc.IsValid()) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("CodeLiteSourceCodeAccessor::OpenSourceFiles: %s"), *Path); FPlatformProcess::CloseProc(Proc); return true; } } return false; }
bool FCodeLiteSourceCodeAccessor::CanAccessSourceCode() const { FString Path; return CanRunCodeLite(Path); }
bool FCodeLiteSourceCodeAccessor::OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths) { FString CodeLitePath; if(!CanRunCodeLite(CodeLitePath)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("FCodeLiteSourceCodeAccessor::OpenSourceFiles: Cannot find CodeLite binary")); return false; } #ifdef USE_DBUS for(const auto& SourcePath : AbsoluteSourcePaths) { DBusMessage* message = nullptr; DBusMessageIter args; // Create new message. message = dbus_message_new_signal ("/org/codelite/command", "org.codelite.command", "OpenFile"); char* fileName = TCHAR_TO_ANSI(*SourcePath); // Add parameters to the message. dbus_message_iter_init_append(message, &args); if(!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &fileName)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("Sdbus_message_iter_append_basic failed.")); return false; } // Send the message. dbus_connection_send(DBusConnection, message, nullptr); if(dbus_error_is_set(&DBusError)) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("dbus_connection_send failed: %s"), DBusError.message); return false; } // Free the message resources. dbus_message_unref(message); } dbus_connection_flush(DBusConnection); return true; #else for(const auto& SourcePath : AbsoluteSourcePaths) { const FString Path = FString::Printf(TEXT("\"%s\""), *SourcePath); FProcHandle Proc = FPlatformProcess::CreateProc(*CodeLitePath, *Path, true, false, false, nullptr, 0, nullptr, nullptr); if(Proc.IsValid()) { UE_LOG(LogCodeLiteAccessor, Warning, TEXT("CodeLiteSourceCodeAccessor::OpenSourceFiles: %s"), *Path); FPlatformProcess::CloseProc(Proc); return true; } } #endif return false; }