MCPcopy Create free account
hub / github.com/php/frankenphp / checkOrphanDirectives

Function checkOrphanDirectives

internal/extgen/astutil.go:38–51  ·  view source on GitHub ↗

checkOrphanDirectives returns an error for the first comment that matches re but whose source line was not consumed by a declaration.

(file *ast.File, fset *token.FileSet, re *regexp.Regexp, consumed map[int]bool, directiveLabel string)

Source from the content-addressed store, hash-verified

36// checkOrphanDirectives returns an error for the first comment that matches re
37// but whose source line was not consumed by a declaration.
38func checkOrphanDirectives(file *ast.File, fset *token.FileSet, re *regexp.Regexp, consumed map[int]bool, directiveLabel string) error {
39 for _, group := range file.Comments {
40 for _, comment := range group.List {
41 if !re.MatchString(comment.Text) {
42 continue
43 }
44 line := fset.Position(comment.Pos()).Line
45 if !consumed[line] {
46 return fmt.Errorf("%s directive at line %d is not followed by a function declaration", directiveLabel, line)
47 }
48 }
49 }
50 return nil
51}

Callers 2

parseMethod · 0.85
parseMethodsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected