bool表示是否有错
(localFD *model.FileDescriptor, rawFieldType string)
| 249 | |
| 250 | // bool表示是否有错 |
| 251 | func findlocalFieldType(localFD *model.FileDescriptor, rawFieldType string) (model.FieldType, bool, *model.Descriptor, bool) { |
| 252 | |
| 253 | var isrepeated bool |
| 254 | var puretype string |
| 255 | |
| 256 | if strings.HasPrefix(rawFieldType, model.RepeatedKeyword) { |
| 257 | |
| 258 | puretype = rawFieldType[model.RepeatedKeywordLen+1:] |
| 259 | |
| 260 | isrepeated = true |
| 261 | } else { |
| 262 | puretype = rawFieldType |
| 263 | } |
| 264 | |
| 265 | // 解析普通类型 |
| 266 | if ft, ok := model.ParseFieldType(puretype); ok { |
| 267 | |
| 268 | return ft, isrepeated, nil, true |
| 269 | |
| 270 | } |
| 271 | |
| 272 | // 解析内建类型 |
| 273 | if desc, ok := localFD.DescriptorByName[rawFieldType]; ok { |
| 274 | |
| 275 | // 只有枚举( 结构体不允许再次嵌套, 增加理解复杂度 ) |
| 276 | if desc.Kind != model.DescriptorKind_Enum { |
| 277 | log.Errorf("%s, '%s'", i18n.String(i18n.TypeSheet_StructFieldCanNotBeStruct), rawFieldType) |
| 278 | |
| 279 | return model.FieldType_None, isrepeated, nil, false |
| 280 | } |
| 281 | |
| 282 | return model.FieldType_Enum, isrepeated, desc, true |
| 283 | |
| 284 | } |
| 285 | |
| 286 | // 没找到类型, 待二次pass |
| 287 | return model.FieldType_None, isrepeated, nil, true |
| 288 | |
| 289 | } |
| 290 | |
| 291 | func parseFieldValue(rawFieldValue string) (model.DescriptorKind, int32, bool) { |
| 292 |
no test coverage detected