public void Background(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            var background = new BackgroundBuilder(keyword, name, description, GetFilePosition(headerSpan.StartPosition));

            stepProcessor = background;
            featureBuilder.AddBackground(background);
        }
示例#2
0
        public void Feature(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            CurrentFileBlockBuilder.SetMainData(typeof(IHeaderBlock), headerSpan.StartPosition.Line, keyword, name);

            ColorizeKeywordLine(keyword, headerSpan, classifications.FeatureTitle);
            ColorizeSpan(descriptionSpan, classifications.Description);
        }
示例#3
0
        public void TableHeader(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            foreach (var cellSpan in cellSpans)
            {
                ColorizeSpan(cellSpan, classifications.TableHeader);
            }

            Table table;

            try
            {
                table = new Table(cells);
            }
            catch (Exception)
            {
                //TODO: shall we mark it as error?
                return;
            }

            if (currentStep != null)
            {
                // RaringCoder: We only track table outlining for step tables (not example tables).
                Debug.Assert(_trackedHeaderRowForOutline == -1, "Multiple headers should not be encountered between starting and finishing a table outline.");
                _trackedHeaderRowForOutline = rowSpan.StartPosition.Line;

                currentStep.TableArgument = table;
            }
            else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && CurrentFileBlockBuilder.ExampleSets.Any())
            {
                var exampleSet = CurrentFileBlockBuilder.ExampleSets.Last();
                exampleSet.ExamplesTable = table;
            }
        }
示例#4
0
        public void Examples(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            var editorLine = headerSpan.StartPosition.Line;

            OnCloseLevel2Outlinings(CalculateRegionEndLine(editorLine));

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);

            ScenarouOutlineExampleSet exampleSet = new ScenarouOutlineExampleSet(keyword, name,
                                                                                 editorLine - CurrentFileBlockBuilder.KeywordLine);

            CurrentFileBlockBuilder.ExampleSets.Add(exampleSet);

            CloseLevel2Outlinings += regionEndLine =>
            {
                if (regionEndLine > editorLine)
                {
                    AddOutline(
                        editorLine,
                        regionEndLine,
                        exampleSet.FullTitle());
                }
            };
        }
        public void TableHeader(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            foreach (var cellSpan in cellSpans)
            {
                ColorizeSpan(cellSpan, classifications.TableHeader);
            }

            var   isStepArg = currentStep != null;
            Table table;

            try
            {
                table = isStepArg ? new Table(cells) : new ScenarioOutlineExamplesTable(cells);
            }
            catch (Exception)
            {
                //TODO: shall we mark it as error?
                return;
            }

            if (isStepArg)
            {
                currentStep.TableArgument = table;
            }
            else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && CurrentFileBlockBuilder.ExampleSets.Any())
            {
                var exampleSet = CurrentFileBlockBuilder.ExampleSets.Last();
                exampleSet.ExamplesTable = (ScenarioOutlineExamplesTable)table;
            }
        }
示例#6
0
        public void Examples(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            // RaringCoder: "Examples:" can occur in-line in a scenario block, so we have to check here to see if a
            //              table from a prior step needs creating.
            CheckTableOutline();

            var editorLine = headerSpan.StartPosition.Line;

            OnCloseLevel2Outlinings(CalculateRegionEndLine(editorLine));

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);

            ScenarioOutlineExampleSet exampleSet = new ScenarioOutlineExampleSet(keyword, name,
                                                                                 editorLine - CurrentFileBlockBuilder.KeywordLine);

            CurrentFileBlockBuilder.ExampleSets.Add(exampleSet);
            currentStep = null;

            CloseLevel2Outlinings += regionEndLine =>
            {
                if (regionEndLine > editorLine)
                {
                    AddOutline(
                        editorLine,
                        regionEndLine,
                        exampleSet.FullTitle());
                }
            };
        }
        public void Feature(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            var position = GetFilePosition(headerSpan.StartPosition);

            featureBuilder.SetHeader(keyword, name, description, FlushTags(), position);
            featureBuilder.SourceFilePath = filePath;
        }
示例#8
0
        private void RegisterKeyword(string keyword, GherkinBufferSpan headerSpan)
        {
            var keywordSpan = new GherkinBufferSpan(headerSpan.StartPosition,
                                                    headerSpan.StartPosition.ShiftByCharacters(keyword.Length));

            ColorizeSpan(keywordSpan, classifications.Keyword);
        }
        public void Scenario(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            var currentScenario = new ScenarioBuilder(keyword, name, description, FlushTags(), GetFilePosition(headerSpan.StartPosition));

            stepProcessor = currentScenario;
            featureBuilder.AddScenario(currentScenario);
        }
示例#10
0
        private int ColorizeLinePart(int from, int to, GherkinBufferSpan span, IClassificationType classificationType)
        {
            var textSpan = new GherkinBufferSpan(new GherkinBufferPosition(span.Buffer, span.StartPosition.Line, from), new GherkinBufferPosition(span.Buffer, span.StartPosition.Line, to));

            ColorizeSpan(textSpan, classificationType);
            return(to);
        }
        public void TableRow(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            foreach (var cellSpan in cellSpans)
            {
                ColorizeSpan(cellSpan, classifications.TableCell);
            }
            Table table = null;

            if (currentStep != null)
            {
                table = currentStep.TableArgument;
            }
            else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && CurrentFileBlockBuilder.ExampleSets.Any())
            {
                table = CurrentFileBlockBuilder.ExampleSets.Last().ExamplesTable;
            }

            if (table == null)
            {
                //TODO: shall we mark it as error?
                return;
            }

            try
            {
                table.AddRow(cells);
            }
            catch (Exception)
            {
                //TODO: shall we mark it as error?
                return;
            }
        }
示例#12
0
        public void Background(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            NewBlock(headerSpan.StartPosition.Line);
            CurrentFileBlockBuilder.SetMainData(typeof(IBackgroundBlock), headerSpan.StartPosition.Line, keyword, name);

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);
        }
示例#13
0
        private void ProcessScenario(string keyword, string name, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan, Type blockType)
        {
            EnsureNewScenario(headerSpan.StartPosition.Line);
            CurrentFileBlockBuilder.SetMainData(blockType, headerSpan.StartPosition.Line, keyword, name);

            ColorizeKeywordLine(keyword, headerSpan, classifications.ScenarioTitle);
            ColorizeSpan(descriptionSpan, classifications.Description);
        }
        public void TableRow(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            var position = GetFilePosition(rowSpan.StartPosition);

            AssertTableProcessor(position);

            tableProcessor.ProcessTableRow(cells, position);
        }
示例#15
0
        public void TableRow(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            foreach (var cellSpan in cellSpans)
            {
                ColorizeSpan(cellSpan, classifications.TableCell);
            }

            //TODO: register step argument
            //TODO: register outline example
        }
示例#16
0
        private static int KeywordAndWhitespaceLength(string keyword, GherkinBufferSpan stepSpan, int editorLine)
        {
            var content      = stepSpan.Buffer.GetContentFrom(editorLine);
            var indentLength = content.TakeWhile(Char.IsWhiteSpace).Count();

            return
                (indentLength
                 + keyword.Length
                 + content.Skip(indentLength + keyword.Length).TakeWhile(Char.IsWhiteSpace).Count());
        }
示例#17
0
        private void ColorizeKeywordLine(string keyword, GherkinBufferSpan headerSpan, IClassificationType classificationType)
        {
            RegisterKeyword(keyword, headerSpan);
            //colorize the rest
            var textSpan = new GherkinBufferSpan(
                headerSpan.StartPosition.ShiftByCharacters(keyword.Length),
                headerSpan.EndPosition);

            ColorizeSpan(textSpan, classificationType);
        }
        public void MultilineText(string text, GherkinBufferSpan textSpan)
        {
            var position = GetFilePosition(textSpan.StartPosition);

            if (stepBuilder == null)
            {
                throw new GherkinSemanticErrorException(
                          "Multi-line step argument can only be specified for steps.", position);
            }

            stepBuilder.SetMultilineArg(text);
        }
        public void MultilineText(string text, GherkinBufferSpan textSpan)
        {
            ColorizeSpan(textSpan, classifications.MultilineText);

            if (currentStep != null)
            {
                currentStep.MultilineTextArgument = text;
            }
            else
            {
                //TODO: shall we mark it as error?
            }
        }
        public void Examples(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            var position       = GetFilePosition(headerSpan.StartPosition);
            var exampleBuilder = new ExampleBuilder(keyword, name, description, FlushTags(), position);

            tableProcessor = exampleBuilder;

            if (exampleProcessor == null)
            {
                throw new GherkinSemanticErrorException(
                          "Examples can only be specified for a scenario outline.", position);
            }
            exampleProcessor.ProcessExample(exampleBuilder);
        }
示例#21
0
        private void ColorizeLinePart(string value, GherkinBufferSpan span, IClassificationType classificationType)
        {
            var textPosition = gherkinBuffer.IndexOfTextForLine(value, span.StartPosition.Line);

            if (textPosition == null)
            {
                return;
            }

            var textSpan = new GherkinBufferSpan(
                textPosition,
                textPosition.ShiftByCharacters(value.Length));

            ColorizeSpan(textSpan, classificationType);
        }
示例#22
0
        private void ColorizeSpan(GherkinBufferSpan span, IClassificationType classificationType)
        {
            if (span == null)
            {
                return;
            }

            var startLine = textSnapshot.GetLineFromLineNumber(span.StartPosition.Line);
            var endLine   = span.StartPosition.Line == span.EndPosition.Line ?
                            startLine : textSnapshot.GetLineFromLineNumber(span.EndPosition.Line);
            var startIndex      = startLine.Start + span.StartPosition.LinePosition;
            var endLinePosition = span.EndPosition.LinePosition == endLine.Length ?
                                  endLine.LengthIncludingLineBreak : span.EndPosition.LinePosition;
            var length = endLine.Start + endLinePosition - startIndex;

            AddClassification(classificationType, startIndex, length);
        }
 public void TableRow(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
 {
     foreach (var cellSpan in cellSpans)
     {
         ColorizeSpan(cellSpan, classifications.TableCell);
     }
     if (currentStep != null)
     {
         try
         {
             currentStep.TableArgument.AddRow(cells);
         }
         catch (Exception)
         {
             //TODO: shall we mark it as error?
         }
     }
     //TODO: register outline example
 }
        public void Comment(string commentText, GherkinBufferSpan commentSpan)
        {
            if (GherkinDialectServices.IsLanguageLine(commentText))
            {
                return;
            }

            var    position       = GetFilePosition(commentSpan.StartPosition);
            string trimmedComment = commentText.TrimStart(' ', '#', '\t');

            position.Column += commentText.Length - trimmedComment.Length;
            trimmedComment   = trimmedComment.Trim();

            if (trimmedComment.Length == 0)
            {
                return;
            }

            featureBuilder.AddComment(trimmedComment, position);
        }
        public void TableRow(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            foreach (var cellSpan in cellSpans)
            {
                ColorizeSpan(cellSpan, classifications.TableCell);
            }
            Table table = null;

            if (currentStep != null)
            {
                table = currentStep.TableArgument;
            }
            else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && CurrentFileBlockBuilder.ExampleSets.Any())
            {
                table = CurrentFileBlockBuilder.ExampleSets.Last().ExamplesTable;
            }

            if (table == null)
            {
                //TODO: shall we mark it as error?
                return;
            }

            try
            {
                table.AddRow(cells);
                var tableWithRowPositions = table as ITableWithRowPositions;
                if (tableWithRowPositions != null)
                {
                    tableWithRowPositions.SetBlockRelativePosition(table.RowCount - 1, rowSpan.StartPosition.Line - CurrentFileBlockBuilder.KeywordLine);
                }
            }
            catch (Exception)
            {
                //TODO: shall we mark it as error?
                return;
            }
        }
示例#26
0
        public void TableRow(string[] cells, GherkinBufferSpan rowSpan, GherkinBufferSpan[] cellSpans)
        {
            foreach (var cellSpan in cellSpans)
            {
                ColorizeSpan(cellSpan, classifications.TableCell);
            }
            Table table = null;

            if (currentStep != null)
            {
                // RaringCoder: We only track table outlining for step tables (not example tables).
                Debug.Assert(_trackedHeaderRowForOutline != -1, "If we are tracking the last row, I'd assume we have a header row!");
                _trackedLastRowForOutline = rowSpan.StartPosition.Line;

                table = currentStep.TableArgument;
                _trackedTableForOutline = table;
            }
            else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && CurrentFileBlockBuilder.ExampleSets.Any())
            {
                table = CurrentFileBlockBuilder.ExampleSets.Last().ExamplesTable;
            }

            if (table == null)
            {
                //TODO: shall we mark it as error?
                return;
            }

            try
            {
                table.AddRow(cells);
            }
            catch (Exception)
            {
                //TODO: shall we mark it as error?
                return;
            }
        }
示例#27
0
        public void MultilineText(string text, GherkinBufferSpan textSpan)
        {
            ColorizeSpan(textSpan, classifications.MultilineText);

            //TODO: register step argument
        }
示例#28
0
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

            if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock))
            {
                var matches = placeholderRe.Matches(text);
                foreach (Match match in matches)
                {
                    ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder);
                }
            }

            //TODO: register step
        }
示例#29
0
 public void ExamplesTag(string name, GherkinBufferSpan tagSpan)
 {
     ColorizeSpan(tagSpan, classifications.Tag);
 }
示例#30
0
 public void ScenarioTag(string name, GherkinBufferSpan tagSpan)
 {
     EnsureNewScenario(tagSpan.StartPosition.Line);
     ColorizeSpan(tagSpan, classifications.Tag);
 }