MCPcopy Create free account
hub / github.com/bufbuild/buf / getAssociatedSourcePaths

Function getAssociatedSourcePaths

private/pkg/protosourcepath/protosourcepath.go:56–82  ·  view source on GitHub ↗
(
	sourcePath protoreflect.SourcePath,
	excludeChildAssociatedPaths bool,
)

Source from the content-addressed store, hash-verified

54}
55
56func getAssociatedSourcePaths(
57 sourcePath protoreflect.SourcePath,
58 excludeChildAssociatedPaths bool,
59) ([]protoreflect.SourcePath, error) {
60 var result []protoreflect.SourcePath
61 currentState := start
62 var associatedSourcePaths []protoreflect.SourcePath
63 var err error
64 for i, token := range sourcePath {
65 if currentState == nil {
66 // We have not parsed the entire source path, but received a terminal state, this is
67 // considered an invalid source path, return an error.
68 return nil, newInvalidSourcePathError(sourcePath, "unexpected termination, invalid source path")
69 }
70 // Check the currentState and then set the next state.
71 currentState, associatedSourcePaths, err = currentState(token, sourcePath, i, excludeChildAssociatedPaths)
72 if err != nil {
73 return nil, err
74 }
75 // Add all associated paths found to the result.
76 if associatedSourcePaths != nil {
77 result = append(result, associatedSourcePaths...)
78 }
79 }
80
81 return result, nil
82}
83
84// *** PRIVATE ***
85

Callers 2

GetAssociatedSourcePathsFunction · 0.85

Calls 1

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…