private static bool RegenerateProjectUsingSystemUVS(Lifetime lifetime, ISolution solution, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile) { if (PlatformUtil.RuntimePlatform != PlatformUtil.Platform.Windows || uprojectFile.IsNullOrEmpty()) { return(false); } var programFiles = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); if (programFiles.IsNullOrEmpty()) { return(false); } var programFilesPath = VirtualFileSystemPath.Parse(programFiles, solution.GetInteractionContext()); if (!programFilesPath.ExistsDirectory) { return(false); } var pathToUnrealVersionSelector = programFilesPath / "Epic Games" / "Launcher" / "Engine" / "Binaries" / "Win64" / "UnrealVersionSelector.exe"; return(RegenerateProjectUsingUVS(lifetime, unrealHost, uprojectFile, pathToUnrealVersionSelector)); }
private static bool IsInstalledBuild(VirtualFileSystemPath engineRoot) { var installedBuildTxt = engineRoot / "Engine" / "Build" / "InstalledBuild.txt"; var isInstalledBuild = installedBuildTxt.ExistsFile; return(isInstalledBuild); }
private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder) { ISolution solution = projectFile.GetSolution(); // creates a new T4PsiModule for the file var lifetimeDefinition = Lifetime.Define(_lifetime, T4FilePsiModule.Prefix + projectFile.Name); var psiModule = new T4FilePsiModule( lifetimeDefinition.Lifetime, projectFile, _changeManager, _shellLocks, _t4Environment, PrimaryTargetFrameworkId ); _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition); psiModule.AddBaseReferences(); changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.Added); changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.Added); // Invalidate files that had this specific files as an include, // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager. // Those files will be reparsed with the new source file. var fileManager = solution.GetComponent <T4OutsideSolutionSourceFileManager>(); VirtualFileSystemPath location = projectFile.Location; if (fileManager.HasSourceFile(location)) { fileManager.DeleteSourceFile(location); } }
public void DoRenameTest(string testFile, int typeSequenceInFile = 1, params string[] expectedRenamedTests) { ExecuteWithinSettingsTransaction((settingsStore => { this.RunGuarded((Action)(() => Lifetime.Using((Action <Lifetime>)(lifetime => { ConfigureForTestCopStrategy(settingsStore); settingsStore.SetValue <TestFileAnalysisSettings, bool>(s => s.SupportRenameRefactor, true); ISolution solution; using (Locks.UsingWriteLock()) { VirtualFileSystemPath solutionPath = this.VirtualTestDataPath.Combine(this.SolutionName); solution = (ISolution)this.SolutionManager.OpenExistingSolution(solutionPath); } lifetime.OnTermination(() => SolutionManager.CloseSolution(solution)); var findFirstTypeInFile = FindTypeInFile(solution, testFile, typeSequenceInFile); var fileRenames = new RenameTestFilesTooRefactoring().GetFileRenames(findFirstTypeInFile, "NewClass"); var filesToRename = fileRenames.Select(f => f.ProjectItem.GetPresentableProjectPath() + "->" + f.NewName).ToList(); Assert.AreEqual(expectedRenamedTests.Length, filesToRename.Count); foreach (string expectation in expectedRenamedTests) { CollectionAssert.Contains(filesToRename, expectation); } })))); })); }
private bool PatchUpluginFileAfterInstallation(VirtualFileSystemPath pluginBuildOutput) { var upluginFile = pluginBuildOutput / "RiderLink.uplugin"; if (!upluginFile.ExistsFile) { return(false); } var jsonText = File.ReadAllText(upluginFile.FullPath); try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonText) as JObject; if (jsonObject == null) { myLogger.Warn($"[UnrealLink]: {upluginFile} is not a JSON file, couldn't patch it"); return(false); } jsonObject["EnabledByDefault"] = true; jsonObject["Installed"] = false; File.WriteAllText(upluginFile.FullPath, jsonObject.ToString()); } catch (Exception e) { myLogger.Warn($"[UnrealLink]: Couldn't patch 'EnableByDefault' field of {upluginFile}", e); return(false); } return(true); }
private void RememberExecution([NotNull] VirtualFileSystemPath path, bool withProgress) { var definition = Lifetime.CreateNested(); if (withProgress) { var progress = new ProgressIndicator(definition.Lifetime); IProgressIndicator iProgress = progress; iProgress.Start(1); progress.Advance(); var task = RiderBackgroundTaskBuilder .FromProgressIndicator(progress) .AsIndeterminate() .WithHeader("Executing template") .WithDescription($"{path.Name}") .Build(); Solution.Locks.ExecuteOrQueueEx( definition.Lifetime, "T4 execution progress launching", () => BackgroundTaskHost.AddNewTask(definition.Lifetime, task) ); } RunningFiles[path] = new T4EnvDTEHost(definition, Solution); }
private IList <VirtualFileSystemPath> ReadIncludePaths() { string registryKey = _vsEnvironmentInformation.VisualStudioGlobalRegistryPath + @"_Config\TextTemplating\IncludeFolders\.tt"; using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryKey)) { if (key == null) { return(EmptyList <VirtualFileSystemPath> .InstanceList); } string[] valueNames = key.GetValueNames(); if (valueNames.Length == 0) { return(EmptyList <VirtualFileSystemPath> .InstanceList); } var paths = new List <VirtualFileSystemPath>(valueNames.Length); foreach (string valueName in valueNames) { var value = key.GetValue(valueName) as string; if (String.IsNullOrEmpty(value)) { continue; } var path = VirtualFileSystemPath.TryParse(value, InteractionContext.SolutionContext); if (!path.IsEmpty && path.IsAbsolute) { paths.Add(path); } } return(paths); } }
public void SavePreprocessResults(IT4File file, string text) { Locks.AssertReadAccessAllowed(); var sourceFile = file.PhysicalPsiSourceFile.NotNull(); var projectFile = sourceFile.ToProjectFile().NotNull(); Locks.AssertWriteAccessAllowed(); VirtualFileSystemPath destinationLocation = null; IProjectFile destination = null; Solution.InvokeUnderTransaction(cookie => { string destinationName = GetPreprocessingTargetFileName(file); destination = GetOrCreateSameDestinationFile(cookie, file, destinationName); destinationLocation = destination.Location; RemoveLastGenOutputIfDifferent(file, cookie, destinationLocation); TemplateMetadataManager.UpdateTemplateMetadata( cookie, projectFile, T4TemplateKind.Preprocessed, destinationLocation ); TemplateMetadataManager.UpdateGeneratedFileMetadata(cookie, destination, projectFile); }); destinationLocation.WriteAllText(text); OutputFileRefresher.Refresh(destination); }
private static VirtualFileSystemPath GetPathToCmd() { var comspec = InteractionContext.SolutionContext.EnvironmentInteraction.GetEnvironmentVariable("COMSPEC"); var pathToCmd = VirtualFileSystemPath.Parse(comspec, InteractionContext.SolutionContext); return(pathToCmd); }
private ILinkResponse TryParseFullPath([NotNull] string input, [NotNull] StringRange range) { try { var path = ConvertToAbsolutePath(VirtualFileSystemPath.Parse(input, InteractionContext.SolutionContext)); if (path == null) { return(null); } if (path.ExtensionNoDot == "umap") { //TO-DO return(null); } if (path.ExtensionNoDot == "uasset") { return(new LinkResponseBlueprint(new FString(path.ToUri().AbsolutePath), range)); } return(new LinkResponseFilePath(new FString(path.ToUri().AbsolutePath), range)); } catch (InvalidPathException e) { _logger.Warn(e); } catch (Exception e) { _logger.Error(e, "occured while trying parse full path"); } return(null); }
public BackupDir(VirtualFileSystemPath oldDir, string backupFolderPrefix) { myOldDir = oldDir; myBackupDir = VirtualFileSystemDefinition.CreateTemporaryDirectory(InteractionContext.SolutionContext, null, backupFolderPrefix); myOldDir.CopyDirectory(myBackupDir); myOldDir.Delete(); }
private static bool RegenerateProjectUsingUBT(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile, VirtualFileSystemPath pathToUnrealBuildToolBin, VirtualFileSystemPath engineRoot) { if (uprojectFile.IsNullOrEmpty()) { return(false); } bool isInstalledBuild = IsInstalledBuild(engineRoot); var pipeStreams = CreatePipeStreams(unrealHost, "[UBT]:"); var startInfo = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUnrealBuildToolBin, pathToUnrealBuildToolBin.Directory, "-ProjectFiles", $"-project=\"{uprojectFile.FullPath}\"", "-game", isInstalledBuild ? "-rocket" : "-engine"); try { var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0; if (!result) { ourLogger.Warn($"[UnrealLink]: Failed refresh project files: calling {startInfo.Arguments}"); } return(result); } catch (ErrorLevelException errorLevelException) { ourLogger.Error(errorLevelException, $"[UnrealLink]: Failed refresh project files: calling {startInfo.Arguments}"); return(false); } }
public T4OutsideSolutionNavigationInfo( [NotNull] VirtualFileSystemPath fileSystemPath, DocumentRange documentRange ) { FileSystemPath = fileSystemPath; DocumentRange = documentRange; }
private bool BuildPlugin(Lifetime lifetime, VirtualFileSystemPath upluginPath, VirtualFileSystemPath outputDir, VirtualFileSystemPath engineRoot, Action <double> progressPump) { var runUatName = $"RunUAT.{CmdUtils.GetPlatformCmdExtension()}"; var pathToUat = engineRoot / "Engine" / "Build" / "BatchFiles" / runUatName; if (!pathToUat.ExistsFile) { myLogger.Warn($"[UnrealLink]: Failed build plugin: {runUatName} is not available"); var text = $"{runUatName} is not available is not available at expected destination: {pathToUat}<br>"; myUnrealHost.myModel.RiderLinkInstallMessage( new InstallMessage($"Failed to build RiderLink plugin for {engineRoot}", ContentType.Error)); myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(text, ContentType.Error)); return(false); } try { var pipeStreams = CreatePipeStreams("[UAT]:", progressPump); var startInfo = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUat, null, "BuildPlugin", "-Unversioned", $"-Plugin=\"{upluginPath.FullPath}\"", $"-Package=\"{outputDir.FullPath}\""); myLogger.Info($"[UnrealLink]: Building UnrealLink plugin with: {startInfo.Arguments}"); myLogger.Verbose("[UnrealLink]: Start building UnrealLink"); var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, myLogger); myLogger.Verbose("[UnrealLink]: Stop building UnrealLink"); lifetime.ToCancellationToken().ThrowIfCancellationRequested(); if (result != 0) { myLogger.Warn($"[UnrealLink]: Failed to build plugin for {engineRoot}"); myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage("Failed to build RiderLink plugin", ContentType.Error)); return(false); } } catch (OperationCanceledException) { myLogger.Verbose("[UnrealLink]: Build cancelled"); throw; } catch (Exception exception) { myLogger.Verbose("[UnrealLink]: Stop building UnrealLink"); myLogger.Warn(exception, $"[UnrealLink]: Failed to build plugin for {engineRoot}"); myUnrealHost.myModel.RiderLinkInstallMessage( new InstallMessage($"Failed to build RiderLink plugin for {engineRoot}", ContentType.Error)); return(false); } return(true); }
private T4AssemblyReferenceInfo?Resolve([NotNull] VirtualFileSystemPath path) { var info = AssemblyInfoDatabase.GetAssemblyName(path); if (info == null) { return(null); } return(new T4AssemblyReferenceInfo(info.FullName, path)); }
public T4FileReference( [NotNull] IT4DirectiveAttribute owner, [NotNull] ITreeNode node, [NotNull] VirtualFileSystemPath path ) : base( owner, null, node, SelectRange(node) ) => Path = path;
private IProject GetProject(VirtualFileSystemPath projectFilePath) { var projectsHostContainer = _solution.ProjectsHostContainer(); var solutionStructureContainer = projectsHostContainer.GetComponent <ISolutionStructureContainer>(); var projectMark = solutionStructureContainer .GetProjectsByLocation(projectFilePath) .First(); return(_solution.GetProjectByMark(projectMark).NotNull()); }
public TestFileNameSpaceWarning(IProjectItem offendingProjectItem, IAccessRightsOwnerDeclaration declaration , string expectedNameSpace , IProject targetProject, VirtualFileSystemPath targetFolder) { _offendingProjectItem = offendingProjectItem; _declaration = declaration; _expectedNameSpace = expectedNameSpace; _targetProject = targetProject; _targetFolder = targetFolder; }
public GitRepositoryInfo FetchGitRepositoryInfo(VirtualFileSystemPath directory) { var gitDirectory = FindGitDirectory(directory); if (gitDirectory == null) { return(null); } return(new GitRepositoryInfo(gitDirectory)); }
private bool TryAddProjectReference([NotNull] VirtualFileSystemPath path) { var project = ProjectReferenceResolver.TryResolveProject(path); if (project == null) { return(false); } MyProjectReferences.Add(path, project); return(true); }
private bool TryAddAssemblyReference([NotNull] VirtualFileSystemPath path) { var cookie = AssemblyFactory.AddRef(new AssemblyLocation(path), "T4", ResolveContext); if (cookie == null) { return(false); } MyAssemblyReferences.Add(path, cookie); return(true); }
public void TryEndProcessing([CanBeNull] VirtualFileSystemPath file) { if (file == null) { return; } if (EqualityComparer <VirtualFileSystemPath> .Default.Equals(FilesBeingProcessed.Peek(), file)) { FilesBeingProcessed.Pop(); } }
public bool Navigate(VirtualFileSystemPath assetPath, UEObjectExport objectExport) { var model = myBackendToUnrealEditor.EditorModel; if (model == null) { return(false); } model.OpenBlueprint.Fire(new BlueprintReference(new FString(assetPath.NormalizeSeparators(FileSystemPathEx.SeparatorStyle.Unix)))); return(true); }
private IProjectFile UpdateProjectModel( [NotNull] IT4File file, [NotNull] VirtualFileSystemPath result, [NotNull] IProjectModelTransactionCookie cookie ) { Locks.AssertReadAccessAllowed(); Locks.AssertWriteAccessAllowed(); var destination = GetOrCreateSameDestinationFile(cookie, file, result); return(destination); }
private static bool RegenerateProjectUsingBundledUVS(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile, VirtualFileSystemPath engineRoot) { if (PlatformUtil.RuntimePlatform != PlatformUtil.Platform.Windows) { return(false); } var pathToUnrealVersionSelector = engineRoot / "Engine" / "Binaries" / "Win64" / "UnrealVersionSelector.exe"; return(RegenerateProjectUsingUVS(lifetime, unrealHost, uprojectFile, pathToUnrealVersionSelector)); }
public IPsiSourceFile GetOrCreateSourceFile([NotNull] VirtualFileSystemPath path) { Assertion.Assert(path.IsAbsolute, "path.IsAbsolute"); return(SourceFiles.GetOrAdd(path, _ => new T4OutsideSolutionSourceFile( ProjectFileExtensions, PsiProjectFileTypeCoordinator, PsiModule, path, sf => sf.Location.ExistsFile, sf => new T4OutsideSolutionSourceFileProperties(), DocumentManager, EmptyResolveContext.Instance) )); }
public IPsiSourceFile FindMostSuitableFile(VirtualFileSystemPath path, IPsiSourceFile requester) { var psf = TryFindFileInSolution(path, requester); if (psf != null) { return(psf); } if (path.ExistsFile) { return(OutsideSolutionManager.GetOrCreateSourceFile(path)); } return(null); }
public static InvokeChildProcess.StartInfo GetProcessStartInfo([NotNull] InvokeChildProcess.PipeStreams pipeStreams, [NotNull] VirtualFileSystemPath cmd, [CanBeNull] VirtualFileSystemPath workindDir, params string[] args) { var command = GetPlatformCommand(cmd); var commandLine = GetPlatformCommandLine(cmd, args); var startInfo = new InvokeChildProcess.StartInfo(command.ToNativeFileSystemPath()) { Arguments = commandLine, Pipe = pipeStreams, CurrentDirectory = workindDir?.ToNativeFileSystemPath() }; return(startInfo); }
private static Dictionary <string, VirtualFileSystemPath> FindEnvDteAssemblies() { var lifetimeDirectory = VirtualFileSystemPath .Parse(typeof(Lifetime).Assembly.Location, InteractionContext.SolutionContext) .Parent; var envDteAssembliesInLifetimeDirectory = FindEnvDteAssemblies(lifetimeDirectory); if (!envDteAssembliesInLifetimeDirectory.IsEmpty()) { return(envDteAssembliesInLifetimeDirectory); } var envDteAssembliesInLifetimeDirectoryParent = FindEnvDteAssemblies(lifetimeDirectory.Parent); return(envDteAssembliesInLifetimeDirectoryParent); }
public override void OnProjectFileChanged( IProjectFile projectFile, VirtualFileSystemPath oldLocation, PsiModuleChange.ChangeType changeType, PsiModuleChangeBuilder changeBuilder ) { var requestedChange = _t4PsiModuleProvider.OnProjectFileChanged(projectFile, changeType, changeBuilder); if (requestedChange == null) { return; } base.OnProjectFileChanged(projectFile, oldLocation, requestedChange.Value, changeBuilder); }