Пример #1
0
        private void OnFileNameChanged(object sender, EventArgs e)
        {
            var indentationStrategy = TextEditor.TextArea.IndentationStrategy;

            if (GherkinUtil.IsFeatureFile(Document.FileName))
            {
                if (!(indentationStrategy is GherkinIndentationStrategy))
                {
                    TextEditor.TextArea.IndentationStrategy = new GherkinIndentationStrategy(TextEditor, SubTextEditor);
                }
                TextEditor.TextArea.Options.EditTableByTableEditorCmd = EditTableByTableEditorCmd;
                TextEditor.TextArea.Options.ReplaceTableFromGridCmd   = ReplaceTableFromGridCmd;
                TextEditor.TextArea.Options.PasteTableFromGridCmd     = PasteTableFromGridCmd;
            }
            else
            {
                if (GherkinUtil.IsCSharpFile(Document.FileName))
                {
                    if (!(indentationStrategy is CSharpIndentationStrategy))
                    {
                        TextEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(TextEditor.Options);
                    }
                }

                TextEditor.TextArea.Options.EditTableByTableEditorCmd = null;
                TextEditor.TextArea.Options.ReplaceTableFromGridCmd   = null;
                TextEditor.TextArea.Options.PasteTableFromGridCmd     = null;
            }
        }
        public void UpdateGherkinHighlighing(bool installFolding = true)
        {
            if (string.IsNullOrEmpty(CurrentFilePath) || (MainGherkinEditor == null))
            {
                return;
            }

            try
            {
                if (GherkinUtil.IsFeatureFile(CurrentFilePath))
                {
                    GherkinUtil.RegisterGherkinHighlighting(CurrentLanguage);
                    IHighlightingDefinition highlighting = GetHighlightingDefinition();
                    UpdateEditorProperty(nameof(GherkinEditor.SyntaxHighlighting), highlighting);

                    if (installFolding && (FoldingExecutor != null))
                    {
                        FoldingExecutor.InstallFoldingManager(CurrentFilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                EventAggregator <StatusChangedArg> .Instance.Publish(this, new StatusChangedArg(ex.Message));
            }
        }
Пример #3
0
        private static void WriteTextFile(string language_key, string content)
        {
            string appDirectory = FileUtil.StartupFolder();
            string file         = GherkinUtil.GherkinHighlightingName(language_key) + ".xshd";
            string outputFile   = Path.Combine(appDirectory, file);

            File.WriteAllText(outputFile, content, Encoding.UTF8);
        }
Пример #4
0
        public GherkinSettingViewModel(IAppSettings appSettings, SettingPropertyGridViewModel editorSettingViewModel)
        {
            m_AppSettings         = appSettings;
            PropertyGridViewModel = editorSettingViewModel;
            GherkinUtil.RegisterGherkinHighlighting();

            EventAggregator <CurrentGherkinLanguageArg> .Instance.Event += OnGherkinLanguage;
        }
Пример #5
0
        private bool IsXMLFile(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }
            var ext = Path.GetExtension(filePath);

            return(GherkinUtil.HasExtension(filePath, ".xml") ||
                   GherkinUtil.HasExtension(filePath, ".xaml") ||
                   GherkinUtil.HasExtension(filePath, ".config"));
        }
Пример #6
0
        private void CreateFoldingStrategy(string filePath)
        {
            GherkinFoldingStrategy = null;
            XmlFoldingStrategy     = null;

            if (GherkinUtil.IsFeatureFile(filePath))
            {
                GherkinFoldingStrategy = new GherkinFoldingStrategy();
            }
            else if (IsXMLFile(filePath))
            {
                XmlFoldingStrategy = new XmlFoldingStrategy();
            }
        }
        private void SetSyntaxHighlighting(string filePath)
        {
            IHighlightingDefinition highlighting;

            if (GherkinUtil.IsFeatureFile(filePath))
            {
                highlighting = HighlightingManager.Instance.GetDefinition(GherkinUtil.GherkinHighlightingName(CurrentLanguage));
            }
            else
            {
                highlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(filePath));
            }

            UpdateEditorProperty(nameof(GherkinEditor.SyntaxHighlighting), highlighting);
        }
Пример #8
0
        private static string MakeGherkinHighlightingContent(string xshd_template, GherkinLanguage language)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<?xml version=\"1.0\"?>")
            .AppendLine("<SyntaxDefinition name=\"" + GherkinUtil.GherkinHighlightingName(language.key) + "\" xmlns=\"http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008\">")
            .AppendLine(xshd_template)

            .AppendLine(MakeGherkinKeyword(language))
            .AppendLine()
            .AppendLine(MakeStepKeyword(language))

            .AppendLine("  </RuleSet>")
            .AppendLine("</SyntaxDefinition>");

            return(sb.ToString());
        }
        private void UpdateEditor(string filePath)
        {
            bool isOldFileFeatureFile = GherkinUtil.IsFeatureFile(Document.FileName);

            SetSyntaxHighlighting(filePath);
            FoldingExecutor?.InstallFoldingManager(filePath);
            CurrentFilePath   = filePath;
            Document.FileName = filePath;
            FileNameChangedEvent?.Invoke(filePath);
            if (isOldFileFeatureFile != IsFeatureFile)
            {
                HideScenarioIndex = !IsFeatureFile;
            }

            if (CurrentFilePath != filePath)
            {
                EventAggregator <FileSavedAsArg> .Instance.Publish(this, new FileSavedAsArg(CurrentFilePath));
            }
        }
Пример #10
0
 private bool CanPasteTableFromGrid()
 {
     return(GherkinUtil.IsFeatureFile(Document.FileName));
 }
Пример #11
0
 private bool CanReplaceTableFromGrid()
 {
     return(GherkinUtil.IsFeatureFile(Document.FileName) && IsCurrentLineTableRow());
 }
Пример #12
0
 private bool CanEditTableByTableEditor()
 {
     return(GherkinUtil.IsFeatureFile(Document.FileName) && IsCurrentLineTableRow());
 }
 private bool NeedShowVSplitView(string filePath) => m_AppSettings.EditorSettings.ShowSplitVerticalViewByDefault && GherkinUtil.IsFeatureFile(filePath);
        private IHighlightingDefinition GetHighlightingDefinition()
        {
            IHighlightingDefinition highlighting = HighlightingManager.Instance.GetDefinition(GherkinUtil.GherkinHighlightingName(CurrentLanguage));

            string[] colorNames = { "Keyword", "StepWord", "Table", "Tag", "DocString", "Mock", "Constants" };
            foreach (string color_name in colorNames)
            {
                ConfigHighlightColor(highlighting, color_name);
            }

            return(highlighting);
        }
Пример #15
0
 private bool CanCommentOutSelectedLines()
 {
     return(GherkinUtil.IsFeatureFile(CurrentEditor?.Document?.FileName));
 }
Пример #16
0
 private bool HasFoldingStrategy(string filePath)
 {
     return(GherkinUtil.IsFeatureFile(filePath) || IsXMLFile(filePath));
 }