// GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0
354653
func (ctxt *parseContext) matchAt3(line *Line) (newState int, err error) {
	if ok, token, err := ctxt.matchEOF(line); ok {
		ctxt.endRule(RuleTypeFeatureHeader)
		ctxt.endRule(RuleTypeFeature)
		ctxt.build(token)
		return 41, err
	}
	if ok, token, err := ctxt.matchEmpty(line); ok {
		ctxt.build(token)
		return 3, err
	}
	if ok, token, err := ctxt.matchComment(line); ok {
		ctxt.build(token)
		return 5, err
	}
	if ok, token, err := ctxt.matchBackgroundLine(line); ok {
		ctxt.endRule(RuleTypeFeatureHeader)
		ctxt.startRule(RuleTypeBackground)
		ctxt.build(token)
		return 6, err
	}
	if ok, token, err := ctxt.matchTagLine(line); ok {
		ctxt.endRule(RuleTypeFeatureHeader)
		ctxt.startRule(RuleTypeScenarioDefinition)
		ctxt.startRule(RuleTypeTags)
		ctxt.build(token)
		return 11, err
	}
	if ok, token, err := ctxt.matchScenarioLine(line); ok {
		ctxt.endRule(RuleTypeFeatureHeader)
		ctxt.startRule(RuleTypeScenarioDefinition)
		ctxt.startRule(RuleTypeScenario)
		ctxt.build(token)
		return 12, err
	}
	if ok, token, err := ctxt.matchRuleLine(line); ok {
		ctxt.endRule(RuleTypeFeatureHeader)
		ctxt.startRule(RuleTypeRule)
		ctxt.startRule(RuleTypeRuleHeader)
		ctxt.build(token)
		return 22, err
	}
	if ok, token, err := ctxt.matchOther(line); ok {
		ctxt.startRule(RuleTypeDescription)
		ctxt.build(token)
		return 4, err
	}

	// var stateComment = "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0"
	var expectedTokens = []string{"#EOF", "#Empty", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#RuleLine", "#Other"}
	if line.IsEof() {
		err = &parseError{
			msg: fmt.Sprintf("unexpected end of file, expected: %s", strings.Join(expectedTokens, ", ")),
			loc: &Location{Line: line.LineNumber, Column: 0},
		}
	} else {
		err = &parseError{
			msg: fmt.Sprintf("expected: %s, got '%s'", strings.Join(expectedTokens, ", "), line.LineText),
			loc: &Location{Line: line.LineNumber, Column: line.Indent() + 1},
		}
	}
	// if (ctxt.p.stopAtFirstError) throw error;
	//ctxt.addError(err)
	return 3, err
}
266305
func (s *Scheme) unstructuredToTyped(in Unstructured) (Object, error) {
	// the type must be something we recognize
	gvks, _, err := s.ObjectKinds(in)
	if err != nil {
		return nil, err
	}
	typed, err := s.New(gvks[0])
	if err != nil {
		return nil, err
	}
	if err := DefaultUnstructuredConverter.FromUnstructured(in.UnstructuredContent(), typed); err != nil {
		return nil, fmt.Errorf("unable to convert unstructured object to %v: %v", gvks[0], err)
	}
	return typed, nil
}
1138507
func (doc *Document) updateDocument(oldBody []byte, newBody []byte) ([]byte, error) {

	var oldBodyMap map[string]interface{}
	var newBodyMap map[string]interface{}
	err := json.Unmarshal(oldBody, &oldBodyMap)
	if err != nil {
		return nil, errors.New("Unmarshalling error " + err.Error())
	}

	err = json.Unmarshal(newBody, &newBodyMap)
	if err != nil {
		return nil, errors.New("Unmarshalling error " + err.Error())
	}

	// Update old data with new contents.
	for newKey, newValue := range newBodyMap {
		oldBodyMap[newKey] = newValue
	}

	oldBodyMap["_rev"] = doc.Rev
	// do the update operation.
	newData, err := json.Marshal(oldBodyMap)
	if err != nil {
		return nil, errors.New("Marshalling error of new value in couch " + err.Error())
	}
	return newData, nil
}
162656
func (gvs GroupVersioners) KindForGroupVersionKinds(kinds []schema.GroupVersionKind) (schema.GroupVersionKind, bool) {
	for _, gv := range gvs {
		target, ok := gv.KindForGroupVersionKinds(kinds)
		if !ok {
			continue
		}
		return target, true
	}
	return schema.GroupVersionKind{}, false
}
740668
func (e shortcutExpander) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error) {
	return e.RESTMapper.KindFor(e.expandResourceShortcut(resource))
}
633833
func (v *kindSchemaVisitor) VisitKind(result *proto.Kind) {
	v.Result = result
	v.Kind = "kind"
}
818248
func GetFieldKind(obj interface{}, name string) (reflect.Kind, error) {
	if !hasValidType(obj, []reflect.Kind{reflect.Struct, reflect.Ptr}) {
		return reflect.Invalid, errors.New("Cannot use GetField on a non-struct interface")
	}

	objValue := reflectValue(obj)
	field := objValue.FieldByName(name)

	if !field.IsValid() {
		return reflect.Invalid, fmt.Errorf("No such field: %s in obj", name)
	}

	return field.Type().Kind(), nil
}
85489
func (c *customMetricsClient) qualResourceForKind(groupKind schema.GroupKind) (string, error) {
	mapping, err := c.mapper.RESTMapping(groupKind)
	if err != nil {
		return "", fmt.Errorf("unable to map kind %s to resource: %v", groupKind.String(), err)
	}

	gr := mapping.Resource.GroupResource()
	return gr.String(), nil
}
603890
func NewEmptyResult(resultType reflect.Type) *GenResult {
	return &GenResult{
		ResultType: resultType,
		Shrinker:   NoShrinker,
	}
}
543861
func (obj *GCSObject) IsRequiredKind(requires []string) bool {
	kindName := obj.ExtractKindName()
	for _, k := range requires {
		if k == kindName {
			return true
		}
	}
	return false
}
848692
func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error) {
	gvks, err := s.ObjectKinds(obj)
	if err != nil {
		return unversioned.GroupVersionKind{}, err
	}
	return gvks[0], nil
}
1263519
func NewShowcaseDocumentLogInfo(ShowcaseId string, ShowcaseTitle string) *ShowcaseDocumentLogInfo {
	s := new(ShowcaseDocumentLogInfo)
	s.ShowcaseId = ShowcaseId
	s.ShowcaseTitle = ShowcaseTitle
	return s
}
575048
func parseDocument(parser *Parser) (*ast.Document, error) {
	var (
		nodes []ast.Node
		node  ast.Node
		item  parseDefinitionFn
		err   error
	)
	start := parser.Token.Start
	for {
		if skp, err := skip(parser, lexer.EOF); err != nil {
			return nil, err
		} else if skp {
			break
		}
		switch kind := parser.Token.Kind; kind {
		case lexer.BRACE_L, lexer.NAME, lexer.STRING, lexer.BLOCK_STRING:
			item = tokenDefinitionFn[kind.String()]
		default:
			return nil, unexpected(parser, lexer.Token{})
		}
		if node, err = item(parser); err != nil {
			return nil, err
		}
		nodes = append(nodes, node)
	}
	return ast.NewDocument(&ast.Document{
		Loc:         loc(parser, start),
		Definitions: nodes,
	}), nil
}
1088041
func SplitYAMLDocuments(yamlBytes []byte) (map[schema.GroupVersionKind][]byte, error) {
	gvkmap := map[schema.GroupVersionKind][]byte{}
	knownKinds := map[string]bool{}
	errs := []error{}
	buf := bytes.NewBuffer(yamlBytes)
	reader := utilyaml.NewYAMLReader(bufio.NewReader(buf))
	for {
		typeMetaInfo := runtime.TypeMeta{}
		// Read one YAML document at a time, until io.EOF is returned
		b, err := reader.Read()
		if err == io.EOF {
			break
		} else if err != nil {
			return nil, err
		}
		if len(b) == 0 {
			break
		}
		// Deserialize the TypeMeta information of this byte slice
		if err := yaml.Unmarshal(b, &typeMetaInfo); err != nil {
			return nil, err
		}
		// Require TypeMeta information to be present
		if len(typeMetaInfo.APIVersion) == 0 || len(typeMetaInfo.Kind) == 0 {
			errs = append(errs, errors.New("invalid configuration: kind and apiVersion is mandatory information that needs to be specified in all YAML documents"))
			continue
		}
		// Check whether the kind has been registered before. If it has, throw an error
		if known := knownKinds[typeMetaInfo.Kind]; known {
			errs = append(errs, errors.Errorf("invalid configuration: kind %q is specified twice in YAML file", typeMetaInfo.Kind))
			continue
		}
		knownKinds[typeMetaInfo.Kind] = true

		// Build a GroupVersionKind object from the deserialized TypeMeta object
		gv, err := schema.ParseGroupVersion(typeMetaInfo.APIVersion)
		if err != nil {
			errs = append(errs, errors.Wrap(err, "unable to parse apiVersion"))
			continue
		}
		gvk := gv.WithKind(typeMetaInfo.Kind)

		// Save the mapping between the gvk and the bytes that object consists of
		gvkmap[gvk] = b
	}
	if err := errorsutil.NewAggregate(errs); err != nil {
		return nil, err
	}
	return gvkmap, nil
}
1255816
func (s *Store) ConfigEntriesByKind(ws memdb.WatchSet, kind string) (uint64, []structs.ConfigEntry, error) {
	tx := s.db.Txn(false)
	defer tx.Abort()

	// Get the index
	idx := maxIndexTxn(tx, configTableName)

	// Lookup by kind, or all if kind is empty
	var iter memdb.ResultIterator
	var err error
	if kind != "" {
		iter, err = tx.Get(configTableName, "kind", kind)
	} else {
		iter, err = tx.Get(configTableName, "id")
	}
	if err != nil {
		return 0, nil, fmt.Errorf("failed config entry lookup: %s", err)
	}
	ws.Add(iter.WatchCh())

	var results []structs.ConfigEntry
	for v := iter.Next(); v != nil; v = iter.Next() {
		results = append(results, v.(structs.ConfigEntry))
	}
	return idx, results, nil
}
955054
func (parser *StandardResultParser) ParseHighlighting(response *SolrResponse, sr *SolrResult) {
	if highlighting, ok := response.Response["highlighting"].(map[string]interface{}); ok {
		sr.Highlighting = highlighting
	}
}
602126
func IsInvalidArgument(err error) bool {
	_, ok := Cause(err).(InvalidArgumentError)
	return ok
}