Implemented package specific structs
This commit is contained in:
@ -10,11 +10,11 @@ import (
|
||||
)
|
||||
|
||||
// Scan scans the list of files.
|
||||
func Scan(files []string) (<-chan *fs.File, <-chan *core.Function, <-chan types.Type, <-chan error) {
|
||||
func Scan(files []string) (<-chan *fs.File, <-chan *core.Function, <-chan *types.Struct, <-chan error) {
|
||||
scanner := Scanner{
|
||||
files: make(chan *fs.File),
|
||||
functions: make(chan *core.Function),
|
||||
types: make(chan types.Type),
|
||||
structs: make(chan *types.Struct),
|
||||
errors: make(chan error),
|
||||
}
|
||||
|
||||
@ -24,9 +24,9 @@ func Scan(files []string) (<-chan *fs.File, <-chan *core.Function, <-chan types.
|
||||
scanner.group.Wait()
|
||||
close(scanner.files)
|
||||
close(scanner.functions)
|
||||
close(scanner.types)
|
||||
close(scanner.structs)
|
||||
close(scanner.errors)
|
||||
}()
|
||||
|
||||
return scanner.files, scanner.functions, scanner.types, scanner.errors
|
||||
return scanner.files, scanner.functions, scanner.structs, scanner.errors
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
type Scanner struct {
|
||||
files chan *fs.File
|
||||
functions chan *core.Function
|
||||
types chan types.Type
|
||||
structs chan *types.Struct
|
||||
errors chan error
|
||||
queued sync.Map
|
||||
group sync.WaitGroup
|
||||
|
@ -16,7 +16,7 @@ func (s *Scanner) scanStruct(file *fs.File, tokens token.List, i int) (int, erro
|
||||
}
|
||||
|
||||
structName := tokens[i].Text(file.Bytes)
|
||||
structure := types.NewStruct(structName)
|
||||
structure := types.NewStruct(file.Package, structName)
|
||||
|
||||
i++
|
||||
|
||||
@ -54,6 +54,6 @@ func (s *Scanner) scanStruct(file *fs.File, tokens token.List, i int) (int, erro
|
||||
return i, errors.New(errors.MissingBlockEnd, file, tokens[i].Position)
|
||||
}
|
||||
|
||||
s.types <- structure
|
||||
s.structs <- structure
|
||||
return i, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user