public Action <ITextControl> GenerateAndUpdateDesignerDocument(IProjectModelEditor projectModelEditor) { var designerCode = GenerateDesignerCode(); var designerFilePath = _aspCodeBehindGenerator.GeneratedProjectFileLocation; var(targetFile, created) = GetOrCreateTargetFile(_project, designerFilePath, projectModelEditor); targetFile.GetDocument().SetText(designerCode); return(textControl => { var message = $"{(created ? "Created" : "Updated")} '{targetFile.GetPresentableProjectPath()}'."; _updateAspDesignerFileService._tooltipManager.Show(message, textControl.PopupWindowContextFactory.ForCaret()); }); }
private static (IProjectFile, bool Created) GetOrCreateTargetFile( IProject project, VirtualFileSystemPath targetFilePath, IProjectModelEditor projectModelEditor) { var targetFile = FindSingleProjectItemByLocation <IProjectFile>(project, targetFilePath); if (targetFile != null) { return(targetFile, Created : false); } var projectFolder = FindSingleProjectItemByLocation <IProjectFolder>(project, targetFilePath.Directory) .NotNull("Cannot find parent folder"); var newProjectFile = projectModelEditor.AddFile(projectFolder, targetFilePath); return(newProjectFile, Created : true); }