Added a check for unused imports
This commit is contained in:
parent
9ea99c97c4
commit
2d905c1ac0
14 changed files with 138 additions and 31 deletions
|
@ -26,11 +26,14 @@ func (s *Scanner) scanFile(path string, pkg string) error {
|
|||
tokens := token.Tokenize(contents)
|
||||
|
||||
file := &fs.File{
|
||||
Path: path,
|
||||
Bytes: contents,
|
||||
Tokens: tokens,
|
||||
Path: path,
|
||||
Bytes: contents,
|
||||
Tokens: tokens,
|
||||
Package: pkg,
|
||||
}
|
||||
|
||||
s.files <- file
|
||||
|
||||
var (
|
||||
i = 0
|
||||
groupLevel = 0
|
||||
|
@ -50,8 +53,20 @@ func (s *Scanner) scanFile(path string, pkg string) error {
|
|||
}
|
||||
|
||||
packageName := tokens[i].Text(contents)
|
||||
s.queueDirectory(filepath.Join(config.Library, packageName), packageName)
|
||||
|
||||
if file.Imports == nil {
|
||||
file.Imports = map[string]*fs.Import{}
|
||||
}
|
||||
|
||||
fullPath := filepath.Join(config.Library, packageName)
|
||||
|
||||
file.Imports[packageName] = &fs.Import{
|
||||
Path: packageName,
|
||||
FullPath: fullPath,
|
||||
Position: tokens[i].Position,
|
||||
}
|
||||
|
||||
s.queueDirectory(fullPath, packageName)
|
||||
i++
|
||||
|
||||
if tokens[i].Kind != token.NewLine && tokens[i].Kind != token.EOF {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue