parsers

package
v0.0.0-...-4fcc4bf Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllSelectors

func GetAllSelectors(doc *goquery.Document) ([]string, error)

GetAllSelectors retrieves all selectors from the given HTML document.

func GetMinifiedDoc

func GetMinifiedDoc(
	url string,
	disallowedTags []string,
) (doc *goquery.Document, err error)

GetMinifiedDoc gets a minified goquery doc from a given url and returns goquery doc and error if there is an error while getting the doc.

func GetSelectors

func GetSelectors(
	ctx context.Context,
	db *data.Database[master.Queries],
	url string,
	ignores []string,
	mustOccur int,
) (selectors []master.Selector, err error)

GetSelectors gets all the selectors from the given URL and appends them to the selectors slice.

func IsValidFileName

func IsValidFileName(fileName string) error

func IsValidPackageName

func IsValidPackageName(packageName string) error

func IsValidURL

func IsValidURL(uri string) error

IsValidURL checks if the given URL is valid.

Types

type Dimensions

type Dimensions struct {
	RowStart    int
	RowEnd      int
	ColumnStart int
	ColumnEnd   int
}

type GoField

type GoField struct {
	Struct *GoStruct
	Name   string
	Type   string
	Tag    *GoTag
}

GoField is a struct for a field within a struct

https://golang.org/pkg/go/ast/#Field

type GoFile

type GoFile struct {
	Package         string
	Path            string
	GlobalConstants []*GoType
	GlobalVariables []*GoType
	Structs         []*GoStruct
	Interfaces      []*GoInterface
	Imports         []*GoImport
	StructMethods   []*GoStructMethod
}

GoFile is a struct for a go file

https://golang.org/pkg/go/ast/#File

func ParseDir

func ParseDir(
	path string,
	withComments bool,
	filterFiles func(fs.FileInfo) bool,
) ([]*GoFile, error)

ParseFiles parses files at the same time

func ParseSingleFile

func ParseSingleFile(path string, withComments bool) (*GoFile, error)

ParseSingleFile parses a single file at the same time

func ParseSource

func ParseSource(source string, filepath string, withComments bool) (*GoFile, error)

ParseSource parses the source of a given golang file.

func (*GoFile) ImportPath

func (g *GoFile) ImportPath() (
	importPath string,
	isExternalPackage bool,
	err error,
)

ImportPath returns the import path for the go file

type GoImport

type GoImport struct {
	File *GoFile
	Name string
	Path string
}

GoImport is a struct for an import within a file

https://golang.org/pkg/go/ast/#ImportSpec

func (*GoImport) Prefix

func (g *GoImport) Prefix() string

For an import - guess what prefix will be used in type declarations. For examples:

"strings" -> "strings"
"net/http/httptest" -> "httptest"

Libraries where the package name does not match will be mis-identified.

type GoInterface

type GoInterface struct {
	File     *GoFile
	Name     string
	Comments string
	Methods  []*GoMethod
}

GoInterface is a struct for an interface within a file

https://golang.org/pkg/go/ast/#TypeSpec

type GoMethod

type GoMethod struct {
	Name     string
	Params   []*GoType
	Comments string
	Results  []*GoType
}

GoMethod is a struct for a method within a file https://golang.org/pkg/go/ast/#FuncDecl

type GoStruct

type GoStruct struct {
	File     *GoFile
	StartRow int
	EndRow   int
	Name     string
	Comments string
	Fields   []*GoField

	SeltablURL        string
	SeltablOccurances int
	SeltablIgnores    []string
}

GoStruct is a struct for a struct within a file.

https://golang.org/pkg/go/ast/#TypeSpec

type GoStructMethod

type GoStructMethod struct {
	GoMethod
	Receivers []string
}

GoStructMethod is a struct for a struct method within a file.

https://golang.org/pkg/go/ast/#FuncDecl

type GoTag

type GoTag struct {
	Field *GoField
	Value string
}

GoTag is a struct for a tag within a field

https://golang.org/pkg/go/ast/#Field

func (*GoTag) Get

func (g *GoTag) Get(key string) string

Get returns the value of the tag for the given key

type GoType

type GoType struct {
	Name       string
	Type       string
	Underlying string
	Inner      []*GoType
}

GoType is a struct for a type within a file.

https://golang.org/pkg/go/ast/#Expr

type PackImporter

type PackImporter struct {
	Fset *token.FileSet
}

PackImporter is a struct for a package importer

https://golang.org/pkg/go/types/#Importer

func (*PackImporter) Import

func (this *PackImporter) Import(path string) (*types.Package, error)

Import imports a package

https://golang.org/pkg/go/types/#Importer

type State

type State int

State represents the state of a position within a struct.

const (
	// StateInTag is the state for when the position is within a struct tag.
	StateInTag State = iota
	// StateInTagValue is the state for when the position is within a struct tag value.
	StateInTagValue
	// StateAfterColon is the state for when the position is after a colon.
	StateAfterColon
	// StateOnURL is the state for when the position is on a url.
	StateOnURL
	// StateInvalid is the state for when the position is invalid or not within a struct.
	StateInvalid
)

func ParsePosState

func ParsePosState(pos protocol.Position, text *string) (State, error)

ParsePosState parses the state of a position within a struct.

func (State) String

func (s State) String() string

String returns the string representation of the State.

Jump to

Keyboard shortcuts

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