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; }
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); } }
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); }
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("")); }
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)); }
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()); }