// TypesThatEmbed returns all types that (directly or indirectly) embed the // target type, which must be a fully qualified type name, // e.g. "github.com/robfig/revel.Controller" func (s *SourceInfo) TypesThatEmbed(targetType string) (filtered []*TypeInfo) { // Do a search in the "embedded type graph", starting with the target type. var ( nodeQueue = []string{targetType} processed []string ) for len(nodeQueue) > 0 { controllerSimpleName := nodeQueue[0] nodeQueue = nodeQueue[1:] processed = append(processed, controllerSimpleName) // Look through all known structs. for _, spec := range s.StructSpecs { // If this one has been processed or is already in nodeQueue, then skip it. if revel.ContainsString(processed, spec.String()) || revel.ContainsString(nodeQueue, spec.String()) { continue } // Look through the embedded types to see if the current type is among them. for _, embeddedType := range spec.embeddedTypes { // If so, add this type's simple name to the nodeQueue, and its spec to // the filtered list. if controllerSimpleName == embeddedType.String() { nodeQueue = append(nodeQueue, spec.String()) filtered = append(filtered, spec) break } } } } return }
// TypesThatEmbed returns all types that (directly or indirectly) embed the // target type, which must be a fully qualified type name, // e.g. "github.com/robfig/revel.Controller" func (s *SourceInfo) TypesThatEmbed(targetType string) (filtered []*TypeInfo) { // Do a search in the "embedded type graph", starting with the target type. nodeQueue := []string{targetType} for len(nodeQueue) > 0 { controllerSimpleName := nodeQueue[0] nodeQueue = nodeQueue[1:] for _, spec := range s.StructSpecs { if revel.ContainsString(nodeQueue, spec.String()) { continue // Already added } // Look through the embedded types to see if the current type is among them. for _, embeddedType := range spec.embeddedTypes { // If so, add this type's simple name to the nodeQueue, and its spec to // the filtered list. if controllerSimpleName == embeddedType.String() { nodeQueue = append(nodeQueue, spec.String()) filtered = append(filtered, spec) break } } } } return }
func (h *Harness) WatchDir(info os.FileInfo) bool { return !revel.ContainsString(doNotWatch, info.Name()) }