// if there's a comment on the line `lines` before pos, return its text, otherwise "".
558468
func (b *Builder) priorCommentLines(pos token.Pos, lines int) *ast.CommentGroup {
	position := b.fset.Position(pos)
	key := fileLine{position.Filename, position.Line - lines}
	return b.endLineToCommentGroup[key]
}
233112
func (r *RefErrUnsupportedDetail) Lines() []string {
	lines := []string{
		r.Ref.String(),
		strings.Repeat("^", len(r.Ref[:r.Pos+1].String())),
		fmt.Sprintf("have: %v", r.Have),
	}
	return lines
}
1219470
func Line(prompt string) (string, error) {
	ins := getInstance()
	ins.SetPrompt(prompt)
	return ins.Readline()
}
620052
func (s *Scanner) pos() ast.Position {
	return ast.Position{Line: s.line + 1, Column: s.offset - s.lineHead + 1}
}
717863
func (f *File) Line(p Pos) int {
	// TODO(gri) this can be implemented much more efficiently
	return f.Position(p).Line
}
1007071
func (l *logger) linePrefix(skipFrames int) string {
	runtime.Callers(skipFrames, l.pc)
	funcForPc := runtime.FuncForPC(l.pc[0])
	file, line := funcForPc.FileLine(l.pc[0] - 1)
	return fmt.Sprintf("%s%s:%d ", l.prefix, filepath.Base(file), line)
}
1286629
func Lines(l int) Option {
	return func(s *Scroller) error {
		if l < 0 {
			return errors.New(ErrNegativeLines, errorMessages, l)
		}
		s.lines = l
		return nil
	}
}
560508
func (w *mlWriter) Comment(comment string) error {
	w.writeIndent(true)
	if err := w.activePlugin().Comment(comment); err != nil {
		return err
	}
	w.writeNewline()
	return nil
}
335965
func (f *file) containsComments(start, end token.Pos) bool {
	for _, cgroup := range f.f.Comments {
		comments := cgroup.List
		if comments[0].Slash >= end {
			// All comments starting with this group are after end pos.
			return false
		}
		if comments[len(comments)-1].Slash < start {
			// Comments group ends before start pos.
			continue
		}
		for _, c := range comments {
			if start <= c.Slash && c.Slash < end && !strings.HasPrefix(c.Text, "// MATCH ") {
				return true
			}
		}
	}
	return false
}
1104341
func (line *Line) Text() string {
	if len(line.Args) > 0 {
		return line.Args[len(line.Args)-1]
	}
	return ""
}
266031
func (v *printVisitor) VisitComment(node *CommentStatement) interface{} {
	v.line("{{! '" + node.Value + "' }}")

	return nil
}
66077
func (g *Group) Line() *Statement {
	s := Line()
	g.items = append(g.items, s)
	return s
}
659007
func (lx *lexer) assignComments() {
	// Generate preorder and postorder lists.
	lx.order(lx.prog)

	// Split into whole-line comments and suffix comments.
	var line, suffix []Comment
	for _, com := range lx.comments {
		if com.Suffix {
			suffix = append(suffix, com)
		} else {
			line = append(line, com)
		}
	}

	// Assign line comments to syntax immediately following.
	for _, x := range lx.pre {
		start := x.GetSpan().Start
		xcom := x.GetComments()
		for len(line) > 0 && start.Byte >= line[0].Start.Byte {
			xcom.Before = append(xcom.Before, line[0])
			line = line[1:]
		}
	}

	// Remaining line comments go at end of file.
	lx.prog.Comments.After = append(lx.prog.Comments.After, line...)

	// Assign suffix comments to syntax immediately before.
	for i := len(lx.post) - 1; i >= 0; i-- {
		x := lx.post[i]

		// Do not assign suffix comments to call, list, end-of-list, or whole file.
		// Instead assign them to the last argument, element, or rule.
		/*
			switch x.(type) {
			case *CallExpr, *ListExpr, *End, *File:
				continue
			}
		*/

		// Do not assign suffix comments to something that starts
		// on an earlier line, so that in
		//
		//	tags = [ "a",
		//		"b" ], # comment
		//
		// we assign the comment to "b" and not to tags = [ ... ].
		span := x.GetSpan()
		start, end := span.Start, span.End
		if start.Line != end.Line {
			continue
		}
		xcom := x.GetComments()
		for len(suffix) > 0 && end.Byte <= suffix[len(suffix)-1].Start.Byte {
			xcom.Suffix = append(xcom.Suffix, suffix[len(suffix)-1])
			suffix = suffix[:len(suffix)-1]
		}
	}

	// We assigned suffix comments in reverse.
	// If multiple suffix comments were appended to the same
	// expression node, they are now in reverse. Fix that.
	for _, x := range lx.post {
		reverseComments(x.GetComments().Suffix)
	}

	// Remaining suffix comments go at beginning of file.
	lx.prog.Comments.Before = append(lx.prog.Comments.Before, suffix...)
}
93090
func (post *ProjectPost) Comments(options CommentlistOptions) *[]ExistingComment {
	var comments []ProjectPostComment

	query := Db().Where(&ProjectPostComment{Hpid: post.ID()})
	query = commentlistQueryBuilder(query, options)
	query.Scan(&comments)

	comments = utils.ReverseSlice(comments).([]ProjectPostComment)

	var ret []ExistingComment
	for _, c := range comments {
		comment := c
		ret = append(ret, ExistingComment(&comment))
	}
	return &ret
}
386444
func (s *Statement) Comment(str string) *Statement {
	c := comment{
		comment: str,
	}
	*s = append(*s, c)
	return s
}
879721
func StripLeadingComments(sql string) string {
	sql = strings.TrimFunc(sql, unicode.IsSpace)

	for hasCommentPrefix(sql) {
		switch sql[0] {
		case '/':
			// Multi line comment
			index := strings.Index(sql, "*/")
			if index <= 1 {
				return sql
			}
			// don't strip /*! ... */ or /*!50700 ... */
			if len(sql) > 2 && sql[2] == '!' {
				return sql
			}
			sql = sql[index+2:]
		case '-':
			// Single line comment
			index := strings.Index(sql, "\n")
			if index == -1 {
				return ""
			}
			sql = sql[index+1:]
		}

		sql = strings.TrimFunc(sql, unicode.IsSpace)
	}

	return sql
}
588573
func multiComment(text string) string {
	lines := strings.Split(text, "\n")
	nl := make([]string, len(lines))
	for i, l := range lines {
		nl[i] = "// " + strings.TrimSpace(l)
	}
	return strings.Join(nl, "\n")
}