Exemple #1
0
func addSourceUnitFiles(u *unit.SourceUnit, file string) {
	for _, f := range u.Files {
		if f == file {
			return
		}
	}
	u.Files = append(u.Files, file)
}
Exemple #2
0
func addSourceUnitFilesFromData(u *unit.SourceUnit, data *graph.Output) {
	files := map[string]struct{}{}
	for _, def := range data.Defs {
		files[def.File] = struct{}{}
	}
	for _, ref := range data.Refs {
		files[ref.File] = struct{}{}
	}
	for f := range files {
		u.Files = append(u.Files, f)
	}
	sort.Strings(u.Files)
}
Exemple #3
0
func (f byUnitsFilter) SelectUnit(unit *unit.SourceUnit) bool {
	return (unit.Type == "" && unit.Name == "") || f.contains(unit.ID2())
}
Exemple #4
0
// checkSourceUnitFiles warns if any files appear in graph data but
// are not in u.Files.
func (s *indexedTreeStore) checkSourceUnitFiles(u *unit.SourceUnit, data graph.Output) {
	if u == nil {
		return
	}

	graphFiles := make(map[string]struct{}, len(u.Files))
	for _, def := range data.Defs {
		graphFiles[def.File] = struct{}{}
	}
	for _, ref := range data.Refs {
		graphFiles[ref.File] = struct{}{}
	}
	for _, doc := range data.Docs {
		graphFiles[doc.File] = struct{}{}
	}
	for _, ann := range data.Anns {
		graphFiles[ann.File] = struct{}{}
	}
	delete(graphFiles, "")

	unitFiles := make(map[string]struct{}, len(u.Files))
	for _, f := range u.Files {
		unitFiles[f] = struct{}{}
	}
	if u.Dir != "" {
		unitFiles[u.Dir] = struct{}{}
	}

	var missingFiles []string
	for f := range graphFiles {
		if _, present := unitFiles[f]; !present {
			missingFiles = append(missingFiles, f)
		}
	}
	if len(missingFiles) > 0 {
		sort.Strings(missingFiles)
		log.Printf("Warning: The graph output (defs/refs/docs/anns) for source unit %+v contain %d references to files that are not present in the source unit's Files list. Indexed lookups by any of these missing files will return no results. To fix this, ensure that the source unit's Files list includes all files that appear in the graph output. The missing files are: %s.", u.ID2(), len(missingFiles), strings.Join(missingFiles, " "))
	}
}