Ejemplo n.º 1
0
        /// <summary>
        /// Builds the URI for the given template based on the containing project VSIX manifest identifier.
        /// </summary>
        internal static Uri BuildUri(IItemContainer selectedItem)
        {
            var manifest      = selectedItem.GetToolkitManifest();
            var owningProject = selectedItem.Traverse(x => x.Parent, item => item.Kind == ItemKind.Project);

            tracer.Info(Properties.Resources.TextTemplateUriEditor_TraceReadingManifest, manifest.GetLogicalPath());

            string vsixId;

            try
            {
                vsixId = Vsix.ReadManifestIdentifier(manifest.PhysicalPath);
            }
            catch (Exception e)
            {
                tracer.Error(e,
                             String.Format(CultureInfo.CurrentCulture, Properties.Resources.TextTemplateUriEditor_TraceReadingManifestFailed, manifest.GetLogicalPath()));
                throw;
            }

            var path = GetLogicalPath(selectedItem).Replace(owningProject.GetLogicalPath(), string.Empty);

            // Use alternative name if IncludeInVSIXAs defined
            var templateItem = (IItem)selectedItem;

            if (IsIncludeInVSIXAs(templateItem))
            {
                path = Path.Combine(Path.GetDirectoryName(path), templateItem.Data.IncludeInVSIXAs);
            }

            return(new Uri(new Uri(TextTemplateUri.UriHostPrefix), new Uri(vsixId + path, UriKind.Relative)));
        }
Ejemplo n.º 2
0
        public override void OnBeforeSave(object sender, Document aDocument)
        {
            var clangFormatOptionPage = GetUserOptions();

            if (false == clangFormatOptionPage.EnableFormatOnSave)
            {
                return;
            }

            if (false == Vsix.IsDocumentDirty(aDocument))
            {
                return;
            }

            if (false == FileHasExtension(aDocument.FullName, clangFormatOptionPage.FileExtensions))
            {
                return;
            }

            if (true == SkipFile(aDocument.FullName, clangFormatOptionPage.SkipFiles))
            {
                return;
            }

            var option = GetUserOptions().Clone();

            option.FallbackStyle = "none";

            FormatDocument(aDocument, option);
        }
Ejemplo n.º 3
0
            public void WhenUnzip_ThenContainsNestedFiles()
            {
                var targetDir = new DirectoryInfo("Target").FullName;

                Vsix.Unzip("Common.IntegrationTests.Content\\Toolkit1.vsix", targetDir);

                Assert.True(File.Exists(Path.Combine(targetDir, "Automation\\Templates\\Projects\\ToolkitCustomization.zip")));
            }
Ejemplo n.º 4
0
            public void WhenReadingManifest_ThenGetsFullInfo()
            {
                var extension = Vsix.ReadManifest("Common.IntegrationTests.Content\\GivenAVsixManifestFile\\extension.vsixmanifest");

                Assert.Equal("Toolkit1", extension.Header.Name);
                Assert.Equal(1, extension.Content.Where(c => c.ContentTypeName == VsixContentTypeMefComponent).Count());
                Assert.Equal(1, extension.Content.Where(c => c.ContentTypeName == VsixContentTypeProjectTemplate).Count());
                Assert.Equal(1, extension.Content.Where(c => c.ContentTypeName == "NuPattern.Toolkit.PatternModel").Count());
            }
Ejemplo n.º 5
0
            public void WhenUnzip_ThenContainsTopLevelFiles()
            {
                var targetDir = new DirectoryInfo("Target").FullName;

                Vsix.Unzip("Common.IntegrationTests.Content\\Toolkit1.vsix", targetDir);

                Assert.True(File.Exists(Path.Combine(targetDir, "extension.vsixmanifest")));
                Assert.True(File.Exists(Path.Combine(targetDir, "Toolkit1.dll")));
            }
Ejemplo n.º 6
0
            public void WhenUnzipFromStream_ThenItIsCreated()
            {
                using (FileStream vsixFile = File.OpenRead("Common.IntegrationTests.Content\\Toolkit1.vsix"))
                {
                    var vsixStreams = Vsix.Unzip(vsixFile);

                    Assert.NotNull(vsixStreams);
                    Assert.NotEqual(0, vsixStreams.Count);
                    Assert.Contains <string>("/extension.vsixmanifest", vsixStreams.Keys);
                }
            }
Ejemplo n.º 7
0
            public void Initialize()
            {
                var deployedVsixItemPath = Path.Combine(this.TestContext.DeploymentDirectory, this.DeployedVsixItemPath);

                this.VsixInfo = Vsix.ReadManifest(deployedVsixItemPath);

                // Unzip VSIX content to target dir
                this.TargetDir = new DirectoryInfo("Target").FullName;
                Vsix.Unzip(deployedVsixItemPath, this.TargetDir);

                this.VsixIdentifier = Vsix.ReadManifestIdentifier(Path.Combine(this.TargetDir, "extension.vsixmanifest"));
            }
Ejemplo n.º 8
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void RunClangFormat(object sender, EventArgs e)
        {
            try
            {
                if (null == mClangFormatPage)
                {
                    FormatAllSelectedDocuments();
                    return;
                }

                var view = Vsix.GetDocumentView(mDocument);
                if (view == null)
                {
                    return;
                }

                var text    = FormatEndOfFile(view, out string dirPath, out string filePath);
                var process = CreateProcess(text, 0, text.Length, dirPath, filePath, mClangFormatPage);

                try
                {
                    process.Start();
                }
                catch (Exception exception)
                {
                    throw new Exception(
                              $"Cannot execute {process.StartInfo.FileName}.\n{exception.Message}.");
                }

                process.StandardInput.Write(text);
                process.StandardInput.Close();

                var output = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (0 != process.ExitCode)
                {
                    throw new Exception(process.StandardError.ReadToEnd());
                }

                ApplyClangFormat(output, view);
            }
            catch (Exception exception)
            {
                VsShellUtilities.ShowMessageBox(Package, exception.Message, "Error while running clang-format",
                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
            finally
            {
                mDocument        = null;
                mClangFormatPage = null;
            }
        }
Ejemplo n.º 9
0
            public void WhenReadingVsixFromStream_ThenGetsFullInfo()
            {
                using (FileStream vsixFile = File.OpenRead("Common.IntegrationTests.Content\\Toolkit1.vsix"))
                {
                    var extension = Vsix.ReadManifest(vsixFile);

                    Assert.Equal("Toolkit1", extension.Header.Name);
                    Assert.Equal(1, extension.Content.Where(c => c.ContentTypeName == VsixContentTypeMefComponent).Count());
                    Assert.Equal(1, extension.Content.Where(c => c.ContentTypeName == VsixContentTypeProjectTemplate).Count());
                    Assert.Equal(1, extension.Content.Where(c => c.ContentTypeName == "NuPattern.Toolkit.PatternModel").Count());
                }
            }
Ejemplo n.º 10
0
            public void WhenUnzipToNonExistingFolder_ThenItIsCreated()
            {
                var targetDir = new DirectoryInfo("Target");

                if (targetDir.Exists)
                {
                    targetDir.Delete(true);
                }

                Vsix.Unzip("Common.IntegrationTests.Content\\Toolkit1.vsix", targetDir.FullName);

                Assert.True(Directory.Exists(targetDir.FullName));
            }
Ejemplo n.º 11
0
        private string FormatEndOfFile(IWpfTextView aView, out string aDirPath, out string aFilePath)
        {
            aFilePath = Vsix.GetDocumentPath(aView);
            aDirPath  = Path.GetDirectoryName(aFilePath);

            var text    = aView.TextBuffer.CurrentSnapshot.GetText();
            var newline = text.Contains(Environment.NewLine) ? Environment.NewLine : "\n";

            if (!text.EndsWith(newline))
            {
                aView.TextBuffer.Insert(aView.TextBuffer.CurrentSnapshot.Length, newline);
                text += newline;
            }

            return(text);
        }
Ejemplo n.º 12
0
        public VsixItem(Vsix v, byte[] content)
        {
            this.ManifestVersion = v.Version;
            this.VsixId          = v.Identifier.Id;
            this.VsixVersion     = v.Identifier.Version;
            this.Publisher       = v.Identifier.Author;
            this.DisplayName     = v.Identifier.Name;
            this.Description     = v.Identifier.Description;
            this.Icon            = v.Identifier.Icon;
            this.PreviewImage    = v.Identifier.PreviewImage;
            this.MoreInfo        = v.Identifier.MoreInfoUrl;
            this.Content         = content;

            this.IconContent         = this.GetResourceContent(this.Icon);
            this.PreviewImageContent = this.GetResourceContent(this.PreviewImage);
        }
Ejemplo n.º 13
0
            public void WhenUnzipToExistingFolder_ThenTargetFolderIsCleaned()
            {
                var targetDir    = new DirectoryInfo("Target");
                var existingFile = Path.Combine(targetDir.FullName, "Foo.txt");

                if (targetDir.Exists)
                {
                    targetDir.Delete(true);
                }

                targetDir.Create();
                File.WriteAllText(existingFile, "Foo");

                Vsix.Unzip("Common.IntegrationTests.Content\\Toolkit1.vsix", targetDir.FullName);

                Assert.False(File.Exists(existingFile));
            }
Ejemplo n.º 14
0
        private bool ValidExecution(out IWpfTextView view)
        {
            SettingsProvider    settingsProvider = new SettingsProvider();
            FormatSettingsModel formatSettings   = settingsProvider.GetFormatSettingsModel();

            view = Vsix.GetDocumentView(mDocument);
            if (view == null)
            {
                return(false);
            }

            if (false == FileHasExtension(mDocument.FullName, formatSettings.FileExtensions))
            {
                return(false);
            }

            if (true == SkipFile(mDocument.FullName, formatSettings.FilesToIgnore))
            {
                return(false);
            }

            if (ScriptConstants.kCMakeConfigFile == mDocument.Name.ToLower())
            {
                return(false);
            }

            if (IsFileFormatSelected(formatSettings))
            {
                var filePath = Vsix.GetDocumentParent(view);
                if (DoesClangFormatFileExist(filePath) == false)
                {
                    OnFormatFile(new FormatCommandEventArgs()
                    {
                        CanFormat = false
                    });
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 15
0
        private void ExecuteFormatCommand()
        {
            try
            {
                if (ValidExecution(out IWpfTextView view) == false)
                {
                    return;
                }

                var dirPath  = string.Empty;
                var filePath = Vsix.GetDocumentPath(view);
                var text     = view.TextBuffer.CurrentSnapshot.GetText();

                var startPosition = 0;
                var length        = text.Length;

                if (false == view.Selection.StreamSelectionSpan.IsEmpty)
                {
                    // get the necessary elements for format selection
                    FindStartPositionAndLengthOfSelectedText(view, text, out startPosition, out length);
                    dirPath = Vsix.GetDocumentParent(view);
                }
                else
                {
                    // format the end of the file for format document
                    text = FormatEndOfFile(view, filePath, out dirPath);
                }

                string output = RunFormatProcess(dirPath, filePath, text, startPosition, length);

                ApplyClangFormat(output, view);
            }
            catch (Exception exception)
            {
                VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error while running clang-format",
                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
        }
        // Public Methods (1)

        /// <summary>
        /// Creates extension.vsixmanifest file's content.
        /// </summary>
        public static string GetVsixManifest(OptionsGui data)
        {
            var vsix = new Vsix
            {
                Version    = "1.0.0",
                Identifier =
                {
                    Id      = data.ProductName + "." + Guid.NewGuid(),
                    Name    = data.ProductName,
                    Version = data.Version,
                    Author  = data.CompanyName
                }
            };

            if (string.IsNullOrEmpty(vsix.Identifier.Author))
            {
                vsix.Identifier.Author = "Author";
            }

            vsix.Identifier.Description             = data.ProductDescription;
            vsix.Identifier.InstalledByMsiSpecified = true;
            vsix.Identifier.InstalledByMsi          = false;
            vsix.Identifier.Locale = 1033;

            vsix.Identifier.SupportedFrameworkRuntimeEdition.MaxVersion = data.ShouldSupportVS2012 ? "4.5" : "4.0";
            vsix.Identifier.SupportedFrameworkRuntimeEdition.MinVersion = "4.0";

            vsix.Identifier.SupportedProducts = new List <object>();
            if (data.ShouldSupportVS2010)
            {
                vsix.Identifier.SupportedProducts.Add(new VsixIdentifierVisualStudio
                {
                    Version = "10.0",
                    Edition = new List <string> {
                        "Ultimate", "Premium", "Pro", "Express_All"
                    }
                });
            }

            if (data.ShouldSupportVS2012)
            {
                vsix.Identifier.SupportedProducts.Add(new VsixIdentifierVisualStudio
                {
                    Version = "11.0",
                    Edition = new List <string> {
                        "Ultimate", "Premium", "Pro", "Express_All"
                    }
                });
            }

            if (data.ShouldSupportVS2013)
            {
                vsix.Identifier.SupportedProducts.Add(new VsixIdentifierVisualStudio
                {
                    Version = "12.0",
                    Edition = new List <string> {
                        "Ultimate", "Premium", "Pro", "Express_All"
                    }
                });
            }

            if (data.ShouldSupportVS2015)
            {
                vsix.Identifier.SupportedProducts.Add(new VsixIdentifierVisualStudio
                {
                    Version = "14.0",
                    Edition = new List <string> {
                        "Ultimate", "Premium", "Pro", "Express_All", "Community"
                    }
                });
            }

            if (data.ShouldSupportVS2017)
            {
                vsix.Identifier.SupportedProducts.Add(new VsixIdentifierVisualStudio
                {
                    Version = "15.0",
                    Edition = new List <string> {
                        "Ultimate", "Premium", "Pro", "Express_All", "Enterprise", "Community"
                    }
                });
            }

            if (!string.IsNullOrEmpty(data.GettingStartedGuideUrl))
            {
                vsix.Identifier.GettingStartedGuide = Uri.EscapeUriString(data.GettingStartedGuideUrl);
            }

            vsix.Identifier.PreviewImage = "__Template_large.png";
            vsix.Identifier.Icon         = "__Template_small.png";

            vsix.Identifier.License = Uri.EscapeUriString(!string.IsNullOrEmpty(data.LicenseFilePath) ?
                                                          data.LicenseFilePath.GetFileName() : "MIT.txt");

            var list = new List <ItemsChoiceType> {
                ItemsChoiceType.ProjectTemplate, ItemsChoiceType.Assembly
            };

            vsix.Content.ItemsElementName = list.ToArray();

            var list2 = new List <object> {
                TemplatePath
            };

            list2.Add(new VsixAssembly
            {
                AssemblyName = typeof(SafeRootProjectWizard.ChildWizard).Assembly.FullName,
                Value        = typeof(SafeRootProjectWizard.ChildWizard).Assembly.Location.GetFileName()
            });
            vsix.Content.Items = list2.ToArray();

            return(Serializer.Serialize(vsix));
        }
Ejemplo n.º 17
0
        private void ExecuteFormatCommand()
        {
            try
            {
                if (ValidExecution(out IWpfTextView view) == false)
                {
                    return;
                }

                var dirPath  = string.Empty;
                var filePath = Vsix.GetDocumentPath(view);
                var text     = view.TextBuffer.CurrentSnapshot.GetText();

                var startPosition = 0;
                var length        = text.Length;

                if (false == view.Selection.StreamSelectionSpan.IsEmpty)
                {
                    // get the necessary elements for format selection
                    FindStartPositionAndLengthOfSelectedText(view, text, out startPosition, out length);
                    dirPath = Vsix.GetDocumentParent(view);
                }
                else
                {
                    // format the end of the file for format document
                    text = FormatEndOfFile(view, filePath, out dirPath);
                }

                var process = CreateProcess(text, startPosition, length, dirPath, filePath);

                try
                {
                    process.Start();
                }
                catch (Exception exception)
                {
                    throw new Exception(
                              $"Cannot execute {process.StartInfo.FileName}.\n{exception.Message}.");
                }

                process.StandardInput.Write(text);
                process.StandardInput.Close();

                var output = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (0 != process.ExitCode)
                {
                    throw new Exception(process.StandardError.ReadToEnd());
                }

                ApplyClangFormat(output, view);
            }
            catch (Exception exception)
            {
                VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error while running clang-format",
                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }

            OnFormatFile(new FormatCommandEventArgs()
            {
                CanFormat = true
            });
        }
Ejemplo n.º 18
0
            public void WhenReadingManifestId_ThenGetsIdentifier()
            {
                var extension = Vsix.ReadManifestIdentifier("Common.IntegrationTests.Content\\GivenAVsixManifestFile\\extension.vsixmanifest");

                Assert.Equal("ef4561f7-a3ea-4666-a080-bc2f195451e3", extension);
            }
Ejemplo n.º 19
0
 public void WhenVsixFileIsEmpty_ThenThrowsArgumentOutOfRangeException()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Vsix.Unzip(string.Empty, "Target"));
 }
Ejemplo n.º 20
0
 public void WhenVsixFileIsNull_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => Vsix.Unzip(null, "Target"));
 }
Ejemplo n.º 21
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void RunClangFormat(object sender, EventArgs e)
        {
            try
            {
                if (null == mClangFormatView)
                {
                    FormatAllSelectedDocuments();
                    return;
                }

                var view = Vsix.GetDocumentView(mDocument);
                if (view == null)
                {
                    return;
                }

                System.Diagnostics.Process process;
                var dirPath  = string.Empty;
                var filePath = Vsix.GetDocumentPath(view);
                var text     = view.TextBuffer.CurrentSnapshot.GetText();

                var startPosition = 0;
                var length        = text.Length;

                if (false == view.Selection.StreamSelectionSpan.IsEmpty)
                {
                    // get the necessary elements for format selection
                    FindStartPositionAndLengthOfSelectedText(view, text, out startPosition, out length);
                    dirPath          = Vsix.GetDocumentParent(view);
                    mClangFormatView = GetUserOptions();
                }
                else
                {
                    // format the end of the file for format document
                    text = FormatEndOfFile(view, filePath, out dirPath);
                }

                process = CreateProcess(text, startPosition, length, dirPath, filePath, mClangFormatView);

                try
                {
                    process.Start();
                }
                catch (Exception exception)
                {
                    throw new Exception(
                              $"Cannot execute {process.StartInfo.FileName}.\n{exception.Message}.");
                }

                process.StandardInput.Write(text);
                process.StandardInput.Close();

                var output = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (0 != process.ExitCode)
                {
                    throw new Exception(process.StandardError.ReadToEnd());
                }

                ApplyClangFormat(output, view);
            }
            catch (Exception exception)
            {
                VsShellUtilities.ShowMessageBox(Package, exception.Message, "Error while running clang-format",
                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
            finally
            {
                mDocument        = null;
                mClangFormatView = null;
            }
        }
Ejemplo n.º 22
0
 public void WhenTargetDirIsEmpty_ThenArgumentOutOfRangeException()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Vsix.Unzip("Common.IntegrationTests.Content\\Toolkit1.vsix", string.Empty));
 }
Ejemplo n.º 23
0
        private bool ValidExecution(out IWpfTextView view)
        {
            var formatSettings = SettingsProvider.FormatSettingsModel;

            view = Vsix.GetDocumentView(mDocument);
            if (view == null)
            {
                return(false);
            }

            if (IsFileStyleSelected(formatSettings))
            {
                var fileToFormatPath = Vsix.GetDocumentParent(view);
                if (!FileSystem.SearchAllTopDirectories(fileToFormatPath, FileSystem.ConfigClangFormatFileTypes))
                {
                    OnFormatFile(new FormatCommandEventArgs()
                    {
                        Clear             = clearOutput,
                        FormatConfigFound = false
                    });

                    if (clearOutput)
                    {
                        clearOutput = false;
                    }

                    return(false);
                }
            }

            if (FileHasExtension(mDocument.FullName, formatSettings.FileExtensions) == false)
            {
                OnFormatFile(new FormatCommandEventArgs()
                {
                    IgnoreExtension = true,
                    FileName        = mDocument.Name,
                    Clear           = clearOutput
                });

                if (clearOutput)
                {
                    clearOutput = false;
                }

                return(false);
            }

            var ignoreItem = new IgnoreItem();

            if (ignoreItem.Check(mDocument))
            {
                OnFormatFile(new FormatCommandEventArgs()
                {
                    IgnoreFile = true,
                    FileName   = mDocument.Name,
                    Clear      = clearOutput
                });

                if (clearOutput)
                {
                    clearOutput = false;
                }

                OnIgnoreItem(new ClangCommandMessageEventArgs(ignoreItem.IgnoreFormatMessage, false));

                return(false);
            }

            if (ScriptConstants.kCMakeConfigFile == mDocument.Name.ToLower())
            {
                return(false);
            }

            OnFormatFile(new FormatCommandEventArgs()
            {
                Clear = true
            });

            return(true);
        }
Ejemplo n.º 24
0
 public void WhenTargetDirIsNull_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => Vsix.Unzip("Common.IntegrationTests.Content\\Toolkit1.vsix", null));
 }
Ejemplo n.º 25
0
        public void RunClangFormat(CommandUILocation commandUILocation)
        {
            try
            {
                if (mClangFormatView == null)
                {
                    FormatAllSelectedDocuments(commandUILocation);
                    return;
                }

                if (ScriptConstants.kCMakeConfigFile == mDocument.Name.ToLower())
                {
                    return;
                }

                var view = Vsix.GetDocumentView(mDocument);
                if (view == null)
                {
                    return;
                }

                StatusBarHandler.Status("Clang-Format started...", 1, vsStatusAnimation.vsStatusAnimationBuild, 1);

                System.Diagnostics.Process process;
                var dirPath  = string.Empty;
                var filePath = Vsix.GetDocumentPath(view);
                var text     = view.TextBuffer.CurrentSnapshot.GetText();

                var startPosition = 0;
                var length        = text.Length;

                if (false == view.Selection.StreamSelectionSpan.IsEmpty)
                {
                    // get the necessary elements for format selection
                    FindStartPositionAndLengthOfSelectedText(view, text, out startPosition, out length);
                    dirPath          = Vsix.GetDocumentParent(view);
                    mClangFormatView = SettingsProvider.ClangFormatSettings;
                }
                else
                {
                    // format the end of the file for format document
                    text = FormatEndOfFile(view, filePath, out dirPath);
                }

                process = CreateProcess(text, startPosition, length, dirPath, filePath, mClangFormatView);

                try
                {
                    process.Start();
                }
                catch (Exception exception)
                {
                    throw new Exception(
                              $"Cannot execute {process.StartInfo.FileName}.\n{exception.Message}.");
                }

                process.StandardInput.Write(text);
                process.StandardInput.Close();

                var output = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (0 != process.ExitCode)
                {
                    throw new Exception(process.StandardError.ReadToEnd());
                }

                ApplyClangFormat(output, view);
            }
            catch (Exception exception)
            {
                VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error while running clang-format",
                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
            finally
            {
                mDocument        = null;
                mClangFormatView = null;
                StatusBarHandler.Status("Clang-Format finished", 0, vsStatusAnimation.vsStatusAnimationBuild, 0);
            }
        }