File: comment.go

package info (click to toggle)
golang-github-vektah-gqlparser 2.5.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: javascript: 164; sh: 46; makefile: 10
file content (31 lines) | stat: -rw-r--r-- 484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package ast

import (
	"strconv"
	"strings"
)

type Comment struct {
	Value    string
	Position *Position
}

func (c *Comment) Text() string {
	return strings.TrimPrefix(c.Value, "#")
}

type CommentGroup struct {
	List []*Comment
}

func (c *CommentGroup) Dump() string {
	if len(c.List) == 0 {
		return ""
	}
	var builder strings.Builder
	for _, comment := range c.List {
		builder.WriteString(comment.Value)
		builder.WriteString("\n")
	}
	return strconv.Quote(builder.String())
}