Skip to content

Commit

Permalink
Merge pull request #1767 from dedis/work-be1-stuart-refactor-file-names
Browse files Browse the repository at this point in the history
Refactor files name
  • Loading branch information
sgueissa authored Mar 2, 2024
2 parents d03d684 + d430655 commit 7a29930
Show file tree
Hide file tree
Showing 41 changed files with 391 additions and 390 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type config struct {
type bag map[string]struct{}

func main() {

app := &cli.App{
Name: "depgraph",
Usage: "generate a dot graph",
Expand Down Expand Up @@ -219,8 +218,6 @@ func getWriter(config config) (io.Writer, error) {
// folder
func walkFn(config config, links map[string]bag) filepath.WalkFunc {
return func(path string, f os.FileInfo, err error) error {
fset := token.NewFileSet()

if err != nil {
return xerrors.Errorf("got an error while walking: %v", err)
}
Expand All @@ -237,47 +234,52 @@ func walkFn(config config, links map[string]bag) filepath.WalkFunc {
return nil
}

astFile, err := parser.ParseFile(fset, path, nil, parser.ImportsOnly)
if err != nil {
return xerrors.Errorf("failed to parse file: %v", err)
}
return walkTroughImports(config, links, path)
}
}

path = filepath.Dir(path)
// This is the full package path. From "mino" we want
// "go.dedis.ch/dela/mino"
packagePath := config.Modname + path
func walkTroughImports(config config, links map[string]bag, path string) error {
fset := token.NewFileSet()
astFile, err := parser.ParseFile(fset, path, nil, parser.ImportsOnly)
if err != nil {
return xerrors.Errorf("failed to parse file: %v", err)
}

if !isIncluded(packagePath, config.Includes) ||
isExcluded(packagePath, config.Excludes) {
return nil
}
path = filepath.Dir(path)
// This is the full package path. From "mino" we want
// "go.dedis.ch/dela/mino"
packagePath := config.Modname + path

for _, s := range astFile.Imports {
// because an import path is always surrounded with "" we remove
// them
importPath := s.Path.Value[1 : len(s.Path.Value)-1]
if !isIncluded(packagePath, config.Includes) ||
isExcluded(packagePath, config.Excludes) {
return nil
}

if !isIncluded(importPath, config.Includes) ||
isExcluded(importPath, config.Excludes) {
for _, s := range astFile.Imports {
// because an import path is always surrounded with "" we remove
// them
importPath := s.Path.Value[1 : len(s.Path.Value)-1]

continue
}
if !isIncluded(importPath, config.Includes) ||
isExcluded(importPath, config.Excludes) {

// in the case the package imports a package from the same module,
// we want to keep only the "relative" name. From
// "go.dedis.ch/dela/mino/minogrpc" we want only "mino/minogrpc".
importPath = strings.TrimPrefix(importPath, config.Modname)
continue
}

if links[packagePath[len(config.Modname):]] == nil {
links[packagePath[len(config.Modname):]] = make(bag)
}
// in the case the package imports a package from the same module,
// we want to keep only the "relative" name. From
// "go.dedis.ch/dela/mino/minogrpc" we want only "mino/minogrpc".
importPath = strings.TrimPrefix(importPath, config.Modname)

// add the dependency to the bag
links[packagePath[len(config.Modname):]][importPath] = struct{}{}
if links[packagePath[len(config.Modname):]] == nil {
links[packagePath[len(config.Modname):]] = make(bag)
}

return nil
// add the dependency to the bag
links[packagePath[len(config.Modname):]][importPath] = struct{}{}
}

return nil
}

func displayGraph(out io.Writer, links map[string]bag, interfaces bag) {
Expand Down
File renamed without changes.
File renamed without changes.
70 changes: 0 additions & 70 deletions be1-go/network/socket/mod.go

This file was deleted.

Loading

0 comments on commit 7a29930

Please sign in to comment.