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));
            }
        }
예제 #2
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;
            }
        }
예제 #3
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);
        }
        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));
            }
        }
예제 #6
0
 private bool CanPasteTableFromGrid()
 {
     return(GherkinUtil.IsFeatureFile(Document.FileName));
 }
예제 #7
0
 private bool CanReplaceTableFromGrid()
 {
     return(GherkinUtil.IsFeatureFile(Document.FileName) && IsCurrentLineTableRow());
 }
예제 #8
0
 private bool CanEditTableByTableEditor()
 {
     return(GherkinUtil.IsFeatureFile(Document.FileName) && IsCurrentLineTableRow());
 }
 private bool NeedShowVSplitView(string filePath) => m_AppSettings.EditorSettings.ShowSplitVerticalViewByDefault && GherkinUtil.IsFeatureFile(filePath);
예제 #10
0
 private bool CanCommentOutSelectedLines()
 {
     return(GherkinUtil.IsFeatureFile(CurrentEditor?.Document?.FileName));
 }
예제 #11
0
 private bool HasFoldingStrategy(string filePath)
 {
     return(GherkinUtil.IsFeatureFile(filePath) || IsXMLFile(filePath));
 }