// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package doc

import 

type Filter func(string) bool

func matchFields( *ast.FieldList,  Filter) bool {
	if  != nil {
		for ,  := range .List {
			for ,  := range .Names {
				if (.Name) {
					return true
				}
			}
		}
	}
	return false
}

func matchDecl( *ast.GenDecl,  Filter) bool {
	for ,  := range .Specs {
		switch v := .(type) {
		case *ast.ValueSpec:
			for ,  := range .Names {
				if (.Name) {
					return true
				}
			}
		case *ast.TypeSpec:
			if (.Name.Name) {
				return true
			}
			switch t := .Type.(type) {
			case *ast.StructType:
				if matchFields(.Fields, ) {
					return true
				}
			case *ast.InterfaceType:
				if matchFields(.Methods, ) {
					return true
				}
			}
		}
	}
	return false
}

func filterValues( []*Value,  Filter) []*Value {
	 := 0
	for ,  := range  {
		if matchDecl(.Decl, ) {
			[] = 
			++
		}
	}
	return [0:]
}

func filterFuncs( []*Func,  Filter) []*Func {
	 := 0
	for ,  := range  {
		if (.Name) {
			[] = 
			++
		}
	}
	return [0:]
}

func filterTypes( []*Type,  Filter) []*Type {
	 := 0
	for ,  := range  {
		 := 0 // number of matches
		if matchDecl(.Decl, ) {
			 = 1
		} else {
			// type name doesn't match, but we may have matching consts, vars, factories or methods
			.Consts = filterValues(.Consts, )
			.Vars = filterValues(.Vars, )
			.Funcs = filterFuncs(.Funcs, )
			.Methods = filterFuncs(.Methods, )
			 += len(.Consts) + len(.Vars) + len(.Funcs) + len(.Methods)
		}
		if  > 0 {
			[] = 
			++
		}
	}
	return [0:]
}

// Filter eliminates documentation for names that don't pass through the filter f.
// TODO(gri): Recognize "Type.Method" as a name.
//
func ( *Package) ( Filter) {
	.Consts = filterValues(.Consts, )
	.Vars = filterValues(.Vars, )
	.Types = filterTypes(.Types, )
	.Funcs = filterFuncs(.Funcs, )
	.Doc = "" // don't show top-level package doc
}