MCPcopy Index your code
hub / github.com/php/frankenphp / findDirective

Function findDirective

internal/extgen/astutil.go:14–24  ·  view source on GitHub ↗

findDirective searches a comment group for a line matching re and returns the first capture group (typically the directive payload) along with the comment's source line number. Returns "" when no comment matches.

(group *ast.CommentGroup, fset *token.FileSet, re *regexp.Regexp)

Source from the content-addressed store, hash-verified

12// first capture group (typically the directive payload) along with the comment's
13// source line number. Returns "" when no comment matches.
14func findDirective(group *ast.CommentGroup, fset *token.FileSet, re *regexp.Regexp) (string, int) {
15 if group == nil {
16 return "", 0
17 }
18 for _, comment := range group.List {
19 if matches := re.FindStringSubmatch(comment.Text); matches != nil {
20 return strings.TrimSpace(matches[1]), fset.Position(comment.Pos()).Line
21 }
22 }
23 return "", 0
24}
25
26// extractNodeSource returns the verbatim source text covered by node in src.
27func extractNodeSource(src []byte, fset *token.FileSet, node ast.Node) string {

Callers 2

parseMethod · 0.85
parseMethodsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected