MCPcopy
hub / github.com/go-yaml/yaml / yaml_emitter_check_simple_key

Function yaml_emitter_check_simple_key

emitterc.go:970–1001  ·  view source on GitHub ↗

Check if the next node can be expressed as a simple key.

(emitter *yaml_emitter_t)

Source from the content-addressed store, hash-verified

968
969// Check if the next node can be expressed as a simple key.
970func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool {
971 length := 0
972 switch emitter.events[emitter.events_head].typ {
973 case yaml_ALIAS_EVENT:
974 length += len(emitter.anchor_data.anchor)
975 case yaml_SCALAR_EVENT:
976 if emitter.scalar_data.multiline {
977 return false
978 }
979 length += len(emitter.anchor_data.anchor) +
980 len(emitter.tag_data.handle) +
981 len(emitter.tag_data.suffix) +
982 len(emitter.scalar_data.value)
983 case yaml_SEQUENCE_START_EVENT:
984 if !yaml_emitter_check_empty_sequence(emitter) {
985 return false
986 }
987 length += len(emitter.anchor_data.anchor) +
988 len(emitter.tag_data.handle) +
989 len(emitter.tag_data.suffix)
990 case yaml_MAPPING_START_EVENT:
991 if !yaml_emitter_check_empty_mapping(emitter) {
992 return false
993 }
994 length += len(emitter.anchor_data.anchor) +
995 len(emitter.tag_data.handle) +
996 len(emitter.tag_data.suffix)
997 default:
998 return false
999 }
1000 return length <= 128
1001}
1002
1003// Determine an acceptable scalar style.
1004func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool {

Tested by

no test coverage detected