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

Function annotationToFileAnnotation

private/bufpkg/bufcheck/annotation.go:58–96  ·  view source on GitHub ↗
(
	pathToExternalPath map[string]string,
	annotation *annotation,
)

Source from the content-addressed store, hash-verified

56}
57
58func annotationToFileAnnotation(
59 pathToExternalPath map[string]string,
60 annotation *annotation,
61) bufanalysis.FileAnnotation {
62 fileLocation := annotation.FileLocation()
63 if fileLocation == nil {
64 // We have to do this or we get a weird fileInfo != nil but it is nil thing.
65 return bufanalysis.NewFileAnnotation(
66 nil,
67 0,
68 0,
69 0,
70 0,
71 annotation.RuleID(),
72 annotation.Message(),
73 annotation.PluginName(),
74 annotation.PolicyName(),
75 )
76 }
77 path := fileLocation.FileDescriptor().ProtoreflectFileDescriptor().Path()
78 // While it never should, it is OK if pathToExternalPath returns "" for a given path.
79 // We handle this in fileInfo.
80 fileInfo := newFileInfo(path, pathToExternalPath[path])
81 startLine := fileLocation.StartLine() + 1
82 startColumn := fileLocation.StartColumn() + 1
83 endLine := fileLocation.EndLine() + 1
84 endColumn := fileLocation.EndColumn() + 1
85 return bufanalysis.NewFileAnnotation(
86 fileInfo,
87 startLine,
88 startColumn,
89 endLine,
90 endColumn,
91 annotation.RuleID(),
92 annotation.Message(),
93 annotation.PluginName(),
94 annotation.PolicyName(),
95 )
96}

Callers 1

Calls 11

NewFileAnnotationFunction · 0.92
newFileInfoFunction · 0.70
MessageMethod · 0.65
PluginNameMethod · 0.65
PolicyNameMethod · 0.65
PathMethod · 0.65
FileDescriptorMethod · 0.65
StartLineMethod · 0.65
StartColumnMethod · 0.65
EndLineMethod · 0.65
EndColumnMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…