private DeveroomTag CreateDefinitionBlockTag(IHasDescription astNode, string tagType, ITextSnapshot fileSnapshot, int lastLine, DeveroomTag parentTag = null)
        {
            var span     = GetBlockSpan(fileSnapshot, ((IHasLocation)astNode).Location, lastLine);
            var blockTag = new DeveroomTag(tagType, span, astNode);

            parentTag?.AddChild(blockTag);
            blockTag.AddChild(CreateDefinitionLineKeyword(fileSnapshot, astNode));
            if (astNode is IHasTags hasTags)
            {
                foreach (var gherkinTag in hasTags.Tags)
                {
                    blockTag.AddChild(
                        new DeveroomTag(DeveroomTagTypes.Tag,
                                        GetTextSpan(fileSnapshot, gherkinTag.Location, gherkinTag.Name),
                                        gherkinTag));
                }
            }

            if (!string.IsNullOrEmpty(astNode.Description))
            {
                var startLineNumber = ((IHasLocation)astNode).Location.Line + 1;
                while (string.IsNullOrWhiteSpace(fileSnapshot.GetLineFromLineNumber(GetSnapshotLineNumber(startLineNumber, fileSnapshot)).GetText()))
                {
                    startLineNumber++;
                }
                blockTag.AddChild(
                    new DeveroomTag(DeveroomTagTypes.Description,
                                    GetBlockSpan(fileSnapshot, startLineNumber,
                                                 CountLines(astNode.Description))));
            }

            return(blockTag);
        }
Пример #2
0
 public void parameter(string name, Action action)
 {
     Console.WriteLine("-- parameter: {0}", name);
     var parameter = new Parameter {Name = name};
     Template.Add(parameter);
     current = parameter;
     action();
 }
Пример #3
0
 private void FormatHasDescription(IHasDescription hasDescription, StringBuilder result)
 {
     FormatHasLocation(hasDescription as IHasLocation, result);
     result.AppendFormat("{0}: {1}", hasDescription.Keyword, hasDescription.Title);
     result.AppendLine();
     if (hasDescription.Description != null)
     {
         result.AppendLine(hasDescription.Description);
     }
 }
Пример #4
0
        private void WriteDescription(IHasDescription element, object parent = null)
        {
            if (element.Description != null && IsDescriptionAllowed())
            {
                foreach (string line in element.Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    WriteLine("# " + EscapeString(line), indent: GetElementIndent());
                }
            }

            Indent GetElementIndent()
            {
                switch (element)
                {
                case GraphQLDirective _:
                case GraphQLType _:
                    return(Indent.None);

                case GraphQLArgument _:
                    return(parent is GraphQLDirective ? Indent.Single : Indent.Double);

                default:
                    return(Indent.Single);
                }
            }

            bool IsDescriptionAllowed()
            {
                switch (element)
                {
                case GraphQLType _:
                    return(_options.TypeComments);

                case GraphQLEnumValue _:
                    return(_options.EnumValuesComments);

                case GraphQLField _:
                case GraphQLInputField _:
                    return(_options.FieldComments);

                case GraphQLArgument _:
                    return(parent is GraphQLDirective ? _options.DirectiveComments : _options.ArgumentComments);

                case GraphQLDirective _:
                    return(_options.DirectiveComments);

                default:
                    throw new NotSupportedException($"Unknown element '{element.GetType().Name}'");
                }
            }
        }
Пример #5
0
 public static string GetShortDescription(this IHasDescription obj, int maxLength = 150)
 {
     return(obj.Description.Length > maxLength
         ? obj.Description.Substring(0, maxLength - 3) + "..."
         : obj.Description);
 }
 private DeveroomTag CreateDefinitionLineKeyword(ITextSnapshot fileSnapshot, IHasDescription hasDescription) =>
 new DeveroomTag(DeveroomTagTypes.DefinitionLineKeyword,
                 GetTextSpan(fileSnapshot, ((IHasLocation)hasDescription).Location, hasDescription.Keyword, 1));
Пример #7
0
 public void template(string name, Action action)
 {
     current = Template = new Template {Name = name};
     action();
 }
 public static void MapDescription(this IHasDescription element, Document document)
 {
     element.Description = document.GetValue(Labels.Description);
 }
Пример #9
0
 private void FormatHasDescription(IHasDescription hasDescription, StringBuilder result)
 {
     FormatHasLocation(hasDescription as IHasLocation, result);
     result.AppendFormat("{0}: {1}", hasDescription.Keyword, hasDescription.Title);
     result.AppendLine();
     if (hasDescription.Description != null)
         result.AppendLine(hasDescription.Description);
 }
 public static void CopyTo(this IHasDescription from, IHasDescription to, bool allowDefaultValues = true)
 {
     to.Description = from.Description;
 }