Add self-contained gometalinter build tooling.
This commit is contained in:
22
tools/vendor/github.com/mibk/dupl/job/buildtree.go
generated
vendored
Normal file
22
tools/vendor/github.com/mibk/dupl/job/buildtree.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"github.com/mibk/dupl/suffixtree"
|
||||
"github.com/mibk/dupl/syntax"
|
||||
)
|
||||
|
||||
func BuildTree(schan chan []*syntax.Node) (t *suffixtree.STree, d *[]*syntax.Node, done chan bool) {
|
||||
t = suffixtree.New()
|
||||
data := make([]*syntax.Node, 0, 100)
|
||||
done = make(chan bool)
|
||||
go func() {
|
||||
for seq := range schan {
|
||||
data = append(data, seq...)
|
||||
for _, node := range seq {
|
||||
t.Update(node)
|
||||
}
|
||||
}
|
||||
done <- true
|
||||
}()
|
||||
return t, &data, done
|
||||
}
|
||||
36
tools/vendor/github.com/mibk/dupl/job/parse.go
generated
vendored
Normal file
36
tools/vendor/github.com/mibk/dupl/job/parse.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/mibk/dupl/syntax"
|
||||
"github.com/mibk/dupl/syntax/golang"
|
||||
)
|
||||
|
||||
func Parse(fchan chan string) chan []*syntax.Node {
|
||||
|
||||
// parse AST
|
||||
achan := make(chan *syntax.Node)
|
||||
go func() {
|
||||
for file := range fchan {
|
||||
ast, err := golang.Parse(file)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
achan <- ast
|
||||
}
|
||||
close(achan)
|
||||
}()
|
||||
|
||||
// serialize
|
||||
schan := make(chan []*syntax.Node)
|
||||
go func() {
|
||||
for ast := range achan {
|
||||
seq := syntax.Serialize(ast)
|
||||
schan <- seq
|
||||
}
|
||||
close(schan)
|
||||
}()
|
||||
return schan
|
||||
}
|
||||
Reference in New Issue
Block a user