示例#1
0
        private void ConfirmIfGivenOfFeature(DocumentLine line)
        {
            var document_line = line;

            while (document_line != null)
            {
                string text  = GherkinFormatUtil.GetText(Document, document_line);
                Token  token = Parser.ParseToken(text);
                switch (token.MatchedType)
                {
                case TokenType.BackgroundLine:
                    IsFeatureGivenStep = false;
                    return;

                case TokenType.ScenarioLine:
                case TokenType.ScenarioOutlineLine:
                    IsFeatureGivenStep = true;
                    return;
                }

                document_line = document_line.PreviousLine;
            }

            IsFeatureGivenStep = false;
        }
示例#2
0
        private void BuildFolder()
        {
            if (StackedFolderStartingOffsets.Count == 0)
            {
                return;
            }

            FoldingStarting startOffset = StackedFolderStartingOffsets.Pop();

            if (startOffset.Offset < last_step_tablerow_offset)
            {
                NewFolding folding = new NewFolding(startOffset.Offset, last_step_tablerow_offset);
                if (startOffset.Type == FoldingType.Scenario)
                {
                    folding.DefaultClosed = IsCloseScenarioFolding;
                    folding.IsDefinition  = true;
                }
                else
                {
                    folding.DefaultClosed = IsCloseTablesFolding;
                }

                DocumentLine start_line = Document.GetLineByOffset(startOffset.Offset);
                folding.Name = GherkinFormatUtil.GetText(Document, start_line);
                newFoldings.Add(folding);
            }
        }
示例#3
0
        private bool IsLeadingTextOfCurrentLineWhiteSpace()
        {
            var    line         = Document.GetLineByNumber(TextEnteredPosition.Line);
            string text         = GherkinFormatUtil.GetText(Document, line);
            string leading_text = text.Substring(0, TextEnteredPosition.Column - 1);

            return(leading_text.Trim().Length == 0);
        }
示例#4
0
        private Token GetLastEffectiveToken()
        {
            if (TextEnteredPosition.Line > 1)
            {
                Token lastDocStringSeparator = null;
                int   lineNo        = TextEnteredPosition.Line - 1;
                var   document_line = Document.GetLineByNumber(lineNo);
                while (document_line != null)
                {
                    string text  = GherkinFormatUtil.GetText(Document, document_line);
                    Token  token = Parser.ParseToken(text);
                    switch (token.MatchedType)
                    {
                    case TokenType.Language:
                    case TokenType.FeatureLine:
                    case TokenType.BackgroundLine:
                    case TokenType.ScenarioLine:
                    case TokenType.ScenarioOutlineLine:
                    case TokenType.ExamplesLine:
                        return(lastDocStringSeparator ?? token);

                    case TokenType.StepLine:
                        if (lastDocStringSeparator != null)
                        {
                            return(lastDocStringSeparator);
                        }
                        else if (IsGiven(token))
                        {
                            ConfirmIfGivenOfFeature(document_line.PreviousLine);
                            return(token);
                        }
                        else if (IsWhen(token) || IsThen(token))
                        {
                            return(token);
                        }
                        break;

                    case TokenType.DocStringSeparator:
                        if (lastDocStringSeparator != null)
                        {
                            lastDocStringSeparator = null;
                        }
                        else
                        {
                            lastDocStringSeparator = token;
                        }
                        break;
                    }

                    document_line = document_line.PreviousLine;
                }
            }

            return(Parser.ParseToken(""));
        }
示例#5
0
        private bool CanShowCodeCompletion()
        {
            if (!GherkinUtil.IsFeatureFile(Document.FileName))
            {
                return(false);
            }

            var    caret = TextEditor.TextArea.Caret;
            var    line  = Document.GetLineByNumber(caret.Line);
            string text  = GherkinFormatUtil.GetText(Document, line);

            return(string.IsNullOrWhiteSpace(text));
        }
示例#6
0
        private bool IsLeadingTextWhiteSpace()
        {
            for (int i = 1; i < TextEnteredPosition.Line - 1; i++)
            {
                string leading_text = GherkinFormatUtil.GetText(Document, Document.GetLineByNumber(i));
                if ((leading_text.Trim().Length > 0))
                {
                    return(false);
                }
            }

            return(IsLeadingTextOfCurrentLineWhiteSpace());
        }