-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.go
45 lines (38 loc) · 923 Bytes
/
file.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package references
import (
"go/parser"
"go/token"
)
var fset *token.FileSet = token.NewFileSet()
type VariableReferences struct {
File string
Refs []VariableReference
}
type VariableReference struct {
Name string
Row int
// col int
}
func New() *VariableReferences {
return &VariableReferences{}
}
func (v *VariableReferences) ParseFile(filePath string) error {
v.File = filePath
file, err := parser.ParseFile(fset, filePath, nil, 0)
if err != nil {
return err
}
// Doc has no variable refernces
// Package has no variable refernces
// Name has no variable refernces
// Decls has variable refernces
for _, d := range file.Decls {
v.parseDecl(d)
}
// Scope has no variable refernces
// Imports has no variable refernces
// Unresolved has no variable refernces
// TODO: is it necessary??
// Comments has no variable refernces
return nil
}