parser

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CallTypeBuiltin  = "builtin"
	CallTypeStd      = "std"
	CallTypeInternal = "internal"
	CallTypeExternal = "external"
	CallTypePackage  = "package"
)

Variables

View Source
var Builtins = map[string]byte{
	"len":     0,
	"append":  0,
	"delete":  0,
	"make":    0,
	"string":  0,
	"int":     0,
	"uint":    0,
	"uintptr": 0,
	"int8":    0,
	"uint8":   0,
	"int16":   0,
	"uint16":  0,
	"int32":   0,
	"uint32":  0,
	"int64":   0,
	"uint64":  0,
	"float32": 0,
	"float64": 0,
	"new":     0,
	"panic":   0,
	"defer":   0,
	"copy":    0,
	"byte":    0,
	"close":   0,
	"rune":    0,
}
View Source
var Libs = map[string]byte{
	"archive":       0,
	"arena":         0,
	"bufio":         0,
	"builtin":       0,
	"bytes":         0,
	"cmd":           0,
	"cmp":           0,
	"compress":      0,
	"container":     0,
	"context":       0,
	"crypto":        0,
	"database":      0,
	"database/sql":  0,
	"debug":         0,
	"embed":         0,
	"encoding":      0,
	"encoding/hex":  0,
	"errors":        0,
	"expvars":       0,
	"flag":          0,
	"fmt":           0,
	"go":            0,
	"hash":          0,
	"html":          0,
	"image":         0,
	"index":         0,
	"io":            0,
	"log":           0,
	"maps":          0,
	"math":          0,
	"mime":          0,
	"net":           0,
	"net/netip":     0,
	"os":            0,
	"path":          0,
	"path/filepath": 0,
	"plugin":        0,
	"reflect":       0,
	"regexp":        0,
	"runtime":       0,
	"slices":        0,
	"sort":          0,
	"strconv":       0,
	"strings":       0,
	"sync":          0,
	"sync/atomic":   0,
	"syscall":       0,
	"testing":       0,
	"text":          0,
	"time":          0,
	"unicode":       0,
	"unsafe":        0,
	"net/http":      0,
}

common std lib cd /usr/local/go/src/ && ls -d */ | cut -f1 -d'/'

Functions

This section is empty.

Types

type Abstract

type Abstract struct {
	ID      string   `json:"id"`
	Pos     string   `json:"pos"`
	Name    string   `json:"name"`
	File    string   `json:"file"`
	Pkg     string   `json:"pkg"`
	Comment string   `json:"comment"`
	Fields  []string `json:"fields"`
	// contains filtered or unexported fields
}

func NewAbstract

func NewAbstract(ident *ast.Ident, strtTyp *ast.StructType, file *File) *Abstract

func (*Abstract) Complete

func (a *Abstract) Complete()

func (*Abstract) LookupName added in v0.1.0

func (a *Abstract) LookupName() string

func (*Abstract) SetupID added in v0.1.0

func (a *Abstract) SetupID()

type Call

type Call struct {
	ID        string `json:"id"`
	Pos       string `json:"pos"`
	Caller    string `json:"caller"`
	Callee    string `json:"callee"`
	File      string `json:"file"`
	Typ       string `json:"typ"`
	Signature string `json:"signature"`
	Dep       string `json:"dep"`
	// contains filtered or unexported fields
}

func NewCall

func NewCall(pos token.Pos, scope string, selector string, typ *parsedtypes.Type, file *File) *Call

func (*Call) Complete

func (c *Call) Complete()

func (*Call) LookupName added in v0.1.0

func (c *Call) LookupName() string

func (*Call) SetupID added in v0.1.0

func (c *Call) SetupID()

type Callable

type Callable struct {
	ID         string   `json:"id"`
	Pos        string   `json:"pos"`
	Name       string   `json:"name"`
	Abstract   string   `json:"abstract"`
	File       string   `json:"file"`
	Pkg        string   `json:"pkg"`
	Comment    string   `json:"comment"`
	Parameters []string `json:"parameters"`
	Results    []string `json:"results"`
	Method     bool     `json:"method"`
	Private    bool     `json:"private"`
	Orphan     bool     `json:"orphan"`
	// contains filtered or unexported fields
}

func NewCallable

func NewCallable(decl *ast.FuncDecl, file *File) *Callable

func (*Callable) Complete

func (c *Callable) Complete()

func (*Callable) LookupName added in v0.1.0

func (c *Callable) LookupName() string

func (*Callable) SetupID added in v0.1.0

func (c *Callable) SetupID()

type Dep added in v0.1.0

type Dep struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Typ  string `json:"type"`
	// contains filtered or unexported fields
}

func NewDep added in v0.1.0

func NewDep(name string, imp *ast.ImportSpec) *Dep

func NewPkgDep added in v0.1.0

func NewPkgDep(name string, pkg *Pkg) *Dep

func (*Dep) SetupID added in v0.1.0

func (d *Dep) SetupID()

type File

type File struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
	Pkg  string `json:"pkg"`
	// contains filtered or unexported fields
}

func NewSourceFile

func NewSourceFile(path string, name string, sm *SourceMap, sf *SourceFile, pkg *Pkg) *File

func (*File) BuildDeps

func (f *File) BuildDeps()

func (*File) EnumerateDecls

func (f *File) EnumerateDecls()

func (*File) LookupAbstract added in v0.1.0

func (f *File) LookupAbstract(name string) *Abstract

func (*File) LookupCallable added in v0.1.0

func (f *File) LookupCallable(name string) *Callable

func (*File) LookupDepByScope added in v0.1.0

func (f *File) LookupDepByScope(scope string) *Dep

func (*File) LookupName added in v0.1.0

func (f *File) LookupName() string

func (*File) SearchCalls

func (f *File) SearchCalls()

func (*File) SetupID added in v0.1.0

func (f *File) SetupID()

type Pkg

type Pkg struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
	// contains filtered or unexported fields
}

func NewSourcePkg

func NewSourcePkg(path string, name string, sm *SourceMap, sd *SourceDir, p *Project) *Pkg

func (*Pkg) Abstracts

func (p *Pkg) Abstracts() []*Abstract

func (*Pkg) Callables

func (p *Pkg) Callables() []*Callable

func (*Pkg) Calls

func (p *Pkg) Calls() []*Call

func (*Pkg) LookupAbstract added in v0.1.0

func (p *Pkg) LookupAbstract(name string) *Abstract

func (*Pkg) LookupCallable added in v0.1.0

func (p *Pkg) LookupCallable(name string) *Callable

func (*Pkg) LookupName added in v0.1.0

func (p *Pkg) LookupName() string

func (*Pkg) SetupID added in v0.1.0

func (p *Pkg) SetupID()

type Project

type Project struct {
	Name      string      `json:"name"`
	Directory string      `json:"directory"`
	Pkgs      []*Pkg      `json:"pkgs"`
	Files     []*File     `json:"files"`
	Abstracts []*Abstract `json:"abstracts"`
	Callables []*Callable `json:"callables"`
	Calls     []*Call     `json:"calls"`
	Deps      []*Dep      `json:"deps"`
	// contains filtered or unexported fields
}

func NewProject

func NewProject(project, directory string) *Project

func (*Project) Initialize

func (p *Project) Initialize()

scan the whole project to get the directories and files

func (*Project) Parse

func (p *Project) Parse()

parse all the files to find out the nodes we are interested at

type SourceDir

type SourceDir struct {
	Path  string
	Files int
	Pkg   bool
}

type SourceFile

type SourceFile struct {
	Path     string
	Name     string
	Dir      *SourceDir
	AST      *ast.File
	GoSource bool
	Test     bool
	Error    string
}

func (*SourceFile) Parse2AST

func (sf *SourceFile) Parse2AST(fset *token.FileSet)

type SourceMap

type SourceMap struct {
	// contains filtered or unexported fields
}

read-only source map of the project

func NewSourceMap

func NewSourceMap(project string, directory string) *SourceMap

func (*SourceMap) Dirs

func (sm *SourceMap) Dirs() []*SourceDir

func (*SourceMap) FileSet

func (sm *SourceMap) FileSet() *token.FileSet

func (*SourceMap) Files

func (sm *SourceMap) Files() []*SourceFile

func (*SourceMap) Module

func (sm *SourceMap) Module() string

func (*SourceMap) Path

func (sm *SourceMap) Path() string

func (*SourceMap) Scan

func (sm *SourceMap) Scan()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL