Esempio n. 1
0
        public void Build(GherkinFileScope gherkinFileEditorInfo, int endLine, int contentEndLine)
        {
            VisualStudioTracer.Assert(IsComplete, "The block builder is not complete");
            int blockRelativeEndLine        = endLine - KeywordLine;
            int blockRelativeContentEndLine = contentEndLine - KeywordLine;

            if (BlockType == typeof(IInvalidFileBlock))
            {
                VisualStudioTracer.Assert(gherkinFileEditorInfo.InvalidFileEndingBlock == null, "no invalid file block");
                if (gherkinFileEditorInfo.InvalidFileEndingBlock == null)
                {
                    gherkinFileEditorInfo.InvalidFileEndingBlock =
                        new InvalidFileBlock(StartLine, endLine, blockRelativeContentEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray());
                }
            }
            else if (BlockType == typeof(IHeaderBlock))
            {
                VisualStudioTracer.Assert(gherkinFileEditorInfo.HeaderBlock == null, "no header block");
                if (gherkinFileEditorInfo.HeaderBlock == null)
                {
                    gherkinFileEditorInfo.HeaderBlock =
                        new HeaderBlock(Keyword, Title, KeywordLine, Tags.ToArray(), BlockRelativeStartLine, blockRelativeEndLine, blockRelativeContentEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray());
                }
            }
            else if (BlockType == typeof(IBackgroundBlock))
            {
                VisualStudioTracer.Assert(gherkinFileEditorInfo.BackgroundBlock == null, "no background block");
                if (gherkinFileEditorInfo.BackgroundBlock == null)
                {
                    gherkinFileEditorInfo.BackgroundBlock =
                        new BackgroundBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, blockRelativeContentEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray(), Steps.ToArray());
                }
            }
            else if (BlockType == typeof(IScenarioBlock))
            {
                var scenarioBlock = new ScenarioBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, blockRelativeContentEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray(), Steps.ToArray());
                gherkinFileEditorInfo.ScenarioBlocks.Add(scenarioBlock);
            }
            else if (BlockType == typeof(IScenarioOutlineBlock))
            {
                var scenarioBlock = new ScenarioOutlineBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, blockRelativeContentEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray(), Steps.ToArray(), ExampleSets.ToArray());
                gherkinFileEditorInfo.ScenarioBlocks.Add(scenarioBlock);
            }
            else
            {
                throw new NotSupportedException("Block type not supported: " + BlockType);
            }
        }
        public void Build(GherkinFileScope gherkinFileEditorInfo, int endLine)
        {
            Debug.Assert(IsComplete);
            int blockRelativeEndLine = endLine - KeywordLine;

            if (BlockType == typeof(IInvalidFileBlock))
            {
                Debug.Assert(gherkinFileEditorInfo.InvalidFileEndingBlock == null);
                if (gherkinFileEditorInfo.InvalidFileEndingBlock == null)
                    gherkinFileEditorInfo.InvalidFileEndingBlock =
                        new InvalidFileBlock(StartLine, endLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray());
            }
            else if (BlockType == typeof(IHeaderBlock))
            {
                Debug.Assert(gherkinFileEditorInfo.HeaderBlock == null);
                if (gherkinFileEditorInfo.HeaderBlock == null)
                    gherkinFileEditorInfo.HeaderBlock =
                        new HeaderBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray());
            }
            else if (BlockType == typeof(IBackgroundBlock))
            {
                Debug.Assert(gherkinFileEditorInfo.BackgroundBlock == null);
                if (gherkinFileEditorInfo.BackgroundBlock == null)
                    gherkinFileEditorInfo.BackgroundBlock =
                        new BackgroundBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray(), Steps.ToArray());
            }
            else if (BlockType == typeof(IScenarioBlock))
            {
                var scenarioBlock = new ScenarioBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray(), Steps.ToArray());
                gherkinFileEditorInfo.ScenarioBlocks.Add(scenarioBlock);
            }
            else if (BlockType == typeof(IScenarioOutlineBlock))
            {
                var scenarioBlock = new ScenarioOutlineBlock(Keyword, Title, KeywordLine, BlockRelativeStartLine, blockRelativeEndLine, ClassificationSpans.ToArray(), OutliningRegions.ToArray(), Errors.ToArray(), Steps.ToArray(), ExampleSets.ToArray());
                gherkinFileEditorInfo.ScenarioBlocks.Add(scenarioBlock);
            }
            else
            {
                throw new NotSupportedException("Block type not supported: " + BlockType);
            }
        }