示例#1
0
        private void AddClassifications(List <ClassificationSpan> classifications, GherkinTokenTag tag, SnapshotSpan tagSpan)
        {
            switch (tag.Token.MatchedType)
            {
            case TokenType.FeatureLine:
            case TokenType.ScenarioLine:
            case TokenType.ScenarioOutlineLine:
            case TokenType.BackgroundLine:
            case TokenType.ExamplesLine:
                classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start, tag.Token.MatchedKeyword.Length), gherkinFileEditorClassifications.Keyword));
                //classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start.Add(tag.Token.MatchedKeyword.Length + 1), tagSpan.End), gherkinFileEditorClassifications.UnboundStepText));
                break;

            case TokenType.StepLine:
                var classification = GetClassification(tag.StepType);
                classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start, tag.Token.MatchedKeyword.Length), classification));
                //classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start.Add(tag.Token.MatchedKeyword.Length), tagSpan.End), gherkinFileEditorClassifications.StepText));
                break;

            case TokenType.Comment:
            case TokenType.Language:
                classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start, tagSpan.End), gherkinFileEditorClassifications.Comment));
                break;

            case TokenType.TagLine:
                AddItemClassifications(classifications, tag, tagSpan, gherkinFileEditorClassifications.Tag);
                break;

            case TokenType.TableRow:
                AddItemClassifications(classifications, tag, tagSpan, gherkinFileEditorClassifications.TableCell);
                break;

            case TokenType.DocStringSeparator:
                classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start, tagSpan.End), gherkinFileEditorClassifications.MultilineText));
                break;

            case TokenType.Other:
                var classificationType =
                    tag.RuleTypesStarted.Contains(RuleType.DocString) ?
                    gherkinFileEditorClassifications.MultilineText :
                    gherkinFileEditorClassifications.Description;
                classifications.Add(new ClassificationSpan(new SnapshotSpan(tagSpan.Start, tagSpan.End), classificationType));
                break;

            case TokenType.Empty:
                break;
            }
        }
示例#2
0
 private static void AddItemClassifications(List <ClassificationSpan> classifications, GherkinTokenTag tag, SnapshotSpan tagSpan,
                                            IClassificationType classificationType)
 {
     foreach (var gherkinLineSpan in tag.Token.MatchedItems)
     {
         classifications.Add(
             new ClassificationSpan(
                 new SnapshotSpan(tagSpan.Start.Add(gherkinLineSpan.Column - tag.Token.Location.Column), gherkinLineSpan.Text.Length), classificationType));
     }
 }
示例#3
0
        private static TagSpan <IOutliningRegionTag> CreateOutliningRegionTag(SnapshotPoint startPoint, SnapshotPoint endPoint, GherkinTokenTag tag)
        {
            var outliningSpan = new SnapshotSpan(startPoint, endPoint);
            var collapseSpan  = new SnapshotSpan(outliningSpan.Start + tag.Token.GetTokenValue().TrimEnd().Length, outliningSpan.End);
            var hintText      = new OutliningHintTextProvider(outliningSpan);

            return(new TagSpan <IOutliningRegionTag>(collapseSpan, new OutliningRegionTag(false, false, "...", hintText)));
        }