36 lines
658 B
Go
36 lines
658 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"ollie/tools/codeintel/internal/codeintel"
|
|
)
|
|
|
|
type arguments struct {
|
|
Path string `json:"path"`
|
|
Language string `json:"language"`
|
|
}
|
|
|
|
func main() {
|
|
var a arguments
|
|
if err := json.NewDecoder(os.Stdin).Decode(&a); err != nil {
|
|
fail(err)
|
|
}
|
|
p, err := filepath.Abs(a.Path)
|
|
if err != nil {
|
|
fail(err)
|
|
}
|
|
d, err := codeintel.Parse(p, a.Language)
|
|
if err != nil {
|
|
fail(err)
|
|
}
|
|
defer d.Close()
|
|
for _, s := range codeintel.Symbols(d) {
|
|
fmt.Printf("%s:%d: %s [%s]\n", s.Path, s.Line, s.Name, s.Kind)
|
|
}
|
|
}
|
|
func fail(e error) { fmt.Fprintln(os.Stderr, "error:", e); os.Exit(1) }
|