private void BeforeSaveClangFormat(Document aDocument)
        {
            var clangFormatOptionPage = SettingsProvider.ClangFormatSettings;
            var tidyOptionPage        = SettingsProvider.TidySettings;

            if (currentCommand == CommandIds.kTidyFixId && running && tidyOptionPage.FormatAfterTidy && clangFormatOptionPage.EnableFormatOnSave)
            {
                mFormatAfterTidyFlag = true;
                return;
            }

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

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

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

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

            FormatCommand.Instance.FormatOnSave(aDocument);
        }
        private void BeforeSaveClangFormat(Document aDocument)
        {
            FormatSettingsModel formatSettings = settingsProvider.GetFormatSettingsModel();
            TidySettingsModel   tidySettings   = settingsProvider.GetTidySettingsModel();

            if (currentCommand == CommandIds.kTidyFixId && running && tidySettings.FormatAfterTidy && formatSettings.FormatOnSave)
            {
                mFormatAfterTidyFlag = true;
                return;
            }

            if (false == formatSettings.FormatOnSave)
            {
                return;
            }

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

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

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

            FormatCommand.Instance.FormatOnSave(aDocument);
        }
Ejemplo n.º 3
0
        private void BeforeSaveClangFormat(Document aDocument)
        {
            var formatSettings = SettingsProvider.FormatSettingsModel;
            var tidySettings   = SettingsProvider.TidySettingsModel;

            if (currentCommand == CommandIds.kTidyFixId && running && tidySettings.FormatAfterTidy && formatSettings.FormatOnSave)
            {
                mFormatAfterTidyFlag = true;
                return;
            }

            if (false == formatSettings.FormatOnSave)
            {
                return;
            }

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

            FormatCommand.Instance.FormatOnSave(aDocument);
        }
        private void BeforeSaveClangFormat(Document aDocument)
        {
            var clangFormatOptionPage = SettingsProvider.GetSettingsPage(typeof(ClangFormatOptionsView)) as ClangFormatOptionsView;
            var tidyOptionPage        = SettingsProvider.GetSettingsPage(typeof(ClangTidyOptionsView)) as ClangTidyOptionsView;

            if (CurrentCommand == CommandIds.kTidyFixId && Running && tidyOptionPage.FormatAfterTidy && clangFormatOptionPage.EnableFormatOnSave)
            {
                mDocument            = aDocument;
                mFormatAfterTidyFlag = true;
                return;
            }

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

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

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

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

            var option = (SettingsProvider.GetSettingsPage(typeof(ClangFormatOptionsView)) as ClangFormatOptionsView).Clone();

            option.FallbackStyle = ClangFormatFallbackStyle.none;
            ClangFormatCommand.Instance.FormatDocument(aDocument, option);
        }