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

Function fileAnnotationCompareTo

private/bufpkg/bufanalysis/file_annotation_set.go:102–165  ·  view source on GitHub ↗

fileAnnotationCompareTo returns a value less than 0 if a < b, a value greater than 0 if a > b, and 0 if a == b.

(a FileAnnotation, b FileAnnotation)

Source from the content-addressed store, hash-verified

100// fileAnnotationCompareTo returns a value less than 0 if a < b, a value
101// greater than 0 if a > b, and 0 if a == b.
102func fileAnnotationCompareTo(a FileAnnotation, b FileAnnotation) int {
103 if a == nil && b == nil {
104 return 0
105 }
106 if a == nil && b != nil {
107 return -1
108 }
109 if a != nil && b == nil {
110 return 1
111 }
112 aFileInfo := a.FileInfo()
113 bFileInfo := b.FileInfo()
114 if aFileInfo == nil && bFileInfo != nil {
115 return -1
116 }
117 if aFileInfo != nil && bFileInfo == nil {
118 return 1
119 }
120 if aFileInfo != nil && bFileInfo != nil {
121 if aFileInfo.ExternalPath() < bFileInfo.ExternalPath() {
122 return -1
123 }
124 if aFileInfo.ExternalPath() > bFileInfo.ExternalPath() {
125 return 1
126 }
127 }
128 if a.StartLine() < b.StartLine() {
129 return -1
130 }
131 if a.StartLine() > b.StartLine() {
132 return 1
133 }
134 if a.StartColumn() < b.StartColumn() {
135 return -1
136 }
137 if a.StartColumn() > b.StartColumn() {
138 return 1
139 }
140 if a.Type() < b.Type() {
141 return -1
142 }
143 if a.Type() > b.Type() {
144 return 1
145 }
146 if a.Message() < b.Message() {
147 return -1
148 }
149 if a.Message() > b.Message() {
150 return 1
151 }
152 if a.EndLine() < b.EndLine() {
153 return -1
154 }
155 if a.EndLine() > b.EndLine() {
156 return 1
157 }
158 if a.EndColumn() < b.EndColumn() {
159 return -1

Callers 1

LessMethod · 0.85

Calls 8

FileInfoMethod · 0.65
ExternalPathMethod · 0.65
StartLineMethod · 0.65
StartColumnMethod · 0.65
TypeMethod · 0.65
MessageMethod · 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…