private void ParseComments(PsiBuilder builder) { while (builder.GetTokenType() == GherkinTokenTypes.COMMENT) { var commentMarker = builder.Mark(); var commentText = builder.GetTokenText(); builder.AdvanceLexer(); var match = LanguagePattern.Match(commentText); if (match.Success) { _lang = match.Groups["lang"].Value; builder.DoneBeforeWhitespaces(commentMarker, GherkinNodeTypes.LANGUAGE_COMMENT, _lang); } else { builder.Drop(commentMarker); } if (builder.GetTokenType() == GherkinTokenTypes.WHITE_SPACE || builder.GetTokenType() == GherkinTokenTypes.NEW_LINE) { builder.AdvanceLexer(); } } }
private static bool IsLineBreak(PsiBuilder builder) { if (builder.GetTokenType() != GherkinTokenTypes.WHITE_SPACE) { return(false); } return(builder.GetTokenText()?.Contains("\n") == true); }
private void ParseStep(PsiBuilder builder) { var marker = builder.Mark(); var keywordText = builder.GetTokenText(); builder.AdvanceLexer(); while (builder.GetTokenType() == GherkinTokenTypes.TEXT || builder.GetTokenType() == GherkinTokenTypes.STEP_PARAMETER_BRACE || builder.GetTokenType() == GherkinTokenTypes.STEP_PARAMETER_TEXT || builder.GetTokenType() == GherkinTokenTypes.WHITE_SPACE || builder.GetTokenType() == GherkinTokenTypes.NEW_LINE) { if (IsLineBreak(builder)) { break; } if (!ParseStepParameter(builder)) { builder.AdvanceLexer(); } } SkipGroupedWhiteSpaces(builder); var nextToken = builder.GetTokenType(1); if (nextToken == GherkinTokenTypes.PIPE) { builder.AdvanceLexer(); ParseTable(builder); } else if (nextToken == GherkinTokenTypes.PYSTRING) { builder.AdvanceLexer(); ParsePystring(builder); } var stepKind = _keywordProvider.GetStepKind(_lang, keywordText); var effectiveStepKind = stepKind; if (stepKind == GherkinStepKind.And) { effectiveStepKind = _lastStepKind; } else if (stepKind == GherkinStepKind.Given || stepKind == GherkinStepKind.When || stepKind == GherkinStepKind.Then) { _lastStepKind = effectiveStepKind; } builder.DoneBeforeWhitespaces(marker, GherkinNodeTypes.STEP, (stepKind, effectiveStepKind)); }