parser

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAppMissingTypeApp        = errors.New(`missing required type "App"`)
	ErrAppMissingPageIndex      = errors.New(`missing required page type "PageIndex"`)
	ErrSignatureMissingReq      = errors.New(`missing the *http.Request parameter`)
	ErrSignatureMultiErrRet     = errors.New(`multiple error return values`)
	ErrSignatureUnknownInput    = errors.New(`handler has unknown input parameter type`)
	ErrSignatureSecondArgNotSSE = errors.New(
		"event handler second argument must be *datastar.ServerSentEventGenerator",
	)
	ErrSignatureEvHandReturnMustBeError = errors.New(
		"event handler must return only error",
	)
	ErrSignatureEvHandFirstArgNotEvent = errors.New(
		`event handler first argument must be named "event"`,
	)
	ErrSignatureEvHandFirstArgTypeNotEvent = errors.New(
		"event handler first argument type must be an event type",
	)
	ErrSignatureGETMissingBody = errors.New(
		"GET handler must return body templ.Component",
	)
	ErrSignatureGETBodyWrongName = errors.New(
		"GET handler first templ.Component return must be named \"body\"",
	)
	ErrSignatureGETHeadWrongName = errors.New(
		"GET handler second templ.Component return must be named \"head\"",
	)

	ErrPageMissingFieldApp     = errors.New(`page is missing the "App *App" field`)
	ErrPageHasExtraFields      = errors.New(`page struct has unsupported fields`)
	ErrPageMissingGET          = errors.New(`page is missing the GET handler`)
	ErrPageConflictingGETEmbed = errors.New("conflicting GET handlers in embedded")
	ErrPageNameInvalid         = errors.New("page has invalid name")
	ErrPageMissingPathComm     = errors.New("page is missing path comment")
	ErrPageInvalidPathComm     = errors.New("page has invalid path comment")

	ErrActionNameMissing      = errors.New("action handler must have a name")
	ErrActionNameInvalid      = errors.New("action has invalid name")
	ErrActionMissingPathComm  = errors.New("action handler is missing path comment")
	ErrActionInvalidPathComm  = errors.New("action handler has invalid path comment")
	ErrActionPathNotUnderPage = errors.New("action handler path is not under page path")

	ErrEventCommMissing     = errors.New("event type is missing subject comment")
	ErrEventCommInvalid     = errors.New("event type has invalid subject comment")
	ErrEventSubjectInvalid  = errors.New("event subject is invalid")
	ErrEvHandDuplicate      = errors.New("duplicate event handler for event")
	ErrEvHandDuplicateEmbed = errors.New("duplicate event handler for event in embedded")

	ErrEventFieldUnexported = errors.New("event field must be exported")
	ErrEventFieldMissingTag = errors.New("event field must have json tag")
	ErrEventFieldEmptyTag   = errors.New(
		"event field json tag must have a non-empty name",
	)
	ErrEventFieldDuplicateTag = errors.New("event field has duplicate json tag value")

	ErrPathParamNotStruct    = paramvalidation.ErrPathParamNotStruct
	ErrPathFieldUnexported   = paramvalidation.ErrPathFieldUnexported
	ErrPathFieldMissingTag   = paramvalidation.ErrPathFieldMissingTag
	ErrPathFieldNotString    = paramvalidation.ErrPathFieldNotString
	ErrPathFieldNotInRoute   = paramvalidation.ErrPathFieldNotInRoute
	ErrPathMissingRouteVar   = paramvalidation.ErrPathMissingRouteVar
	ErrPathFieldDuplicateTag = paramvalidation.ErrPathFieldDuplicateTag
	ErrPathFieldEmptyTag     = paramvalidation.ErrPathFieldEmptyTag

	ErrQueryParamNotStruct    = paramvalidation.ErrQueryParamNotStruct
	ErrQueryFieldUnexported   = paramvalidation.ErrQueryFieldUnexported
	ErrQueryFieldMissingTag   = paramvalidation.ErrQueryFieldMissingTag
	ErrQueryFieldDuplicateTag = paramvalidation.ErrQueryFieldDuplicateTag
	ErrQueryFieldEmptyTag     = paramvalidation.ErrQueryFieldEmptyTag

	ErrQueryReflectSignalNotInSignals = structtag.ErrQueryReflectSignalNotInSignals

	ErrSignalsParamNotStruct    = paramvalidation.ErrSignalsParamNotStruct
	ErrSignalsFieldUnexported   = paramvalidation.ErrSignalsFieldUnexported
	ErrSignalsFieldMissingTag   = paramvalidation.ErrSignalsFieldMissingTag
	ErrSignalsFieldDuplicateTag = paramvalidation.ErrSignalsFieldDuplicateTag
	ErrSignalsFieldEmptyTag     = paramvalidation.ErrSignalsFieldEmptyTag

	ErrDispatchParamNotFunc    = paramvalidation.ErrDispatchParamNotFunc
	ErrDispatchReturnCount     = paramvalidation.ErrDispatchReturnCount
	ErrDispatchMustReturnError = paramvalidation.ErrDispatchMustReturnError
	ErrDispatchNoParams        = paramvalidation.ErrDispatchNoParams
	ErrDispatchParamNotEvent   = paramvalidation.ErrDispatchParamNotEvent

	ErrSessionNotStruct     = errors.New("session type must be a struct")
	ErrSessionMissingUserID = errors.New(
		"session type must have a UserID string field",
	)
	ErrSessionMissingIssuedAt = errors.New(
		"session type must have an IssuedAt time.Time field",
	)
	ErrSessionParamNotSessionType = errors.New("session parameter type must be Session")
	ErrSessionTokenParamNotString = errors.New(
		"sessionToken parameter must be of type string",
	)

	ErrRedirectNotString             = errors.New("redirect must be a string")
	ErrRedirectStatusNotInt          = errors.New("redirectStatus must be an int")
	ErrRedirectStatusWithoutRedirect = errors.New("redirectStatus requires redirect")

	ErrNewSessionNotSessionType = errors.New("newSession must be of type Session")
	ErrCloseSessionNotBool      = errors.New("closeSession must be of type bool")
	ErrNewSessionWithSSE        = errors.New(
		"newSession cannot be used together with sse parameter",
	)
	ErrCloseSessionWithSSE = errors.New(
		"closeSession cannot be used together with sse parameter",
	)

	ErrEnableBgStreamNotBool = errors.New(
		"enableBackgroundStreaming must be of type bool",
	)
	ErrEnableBgStreamNotGET = errors.New(
		"enableBackgroundStreaming can only be used in GET handlers",
	)
	ErrDisableRefreshNotBool = errors.New(
		"disableRefreshAfterHidden must be of type bool",
	)
	ErrDisableRefreshNotGET = errors.New(
		"disableRefreshAfterHidden can only be used in GET handlers",
	)
)

Functions

This section is empty.

Types

type ErrorActionInvalidPathComm added in v0.2.0

type ErrorActionInvalidPathComm struct {
	Recv       string // e.g. "PageProfile" or "App"
	MethodName string // e.g. "POSTFoo"
}

ErrorActionInvalidPathComm is ErrActionInvalidPathComm with suggestion context.

func (*ErrorActionInvalidPathComm) Error added in v0.2.0

func (*ErrorActionInvalidPathComm) Unwrap added in v0.2.0

func (e *ErrorActionInvalidPathComm) Unwrap() error

type ErrorActionMissingPathComm added in v0.2.0

type ErrorActionMissingPathComm struct {
	PagePath   string // e.g. "/profile/" (empty for App-level actions)
	Recv       string // e.g. "PageProfile" or "App"
	MethodName string // e.g. "POSTFoo"
}

ErrorActionMissingPathComm is ErrActionMissingPathComm with suggestion context.

func (*ErrorActionMissingPathComm) Error added in v0.2.0

func (*ErrorActionMissingPathComm) Unwrap added in v0.2.0

func (e *ErrorActionMissingPathComm) Unwrap() error

type ErrorActionPathNotUnderPage added in v0.2.0

type ErrorActionPathNotUnderPage struct {
	PagePath   string // e.g. "/profile/"
	Recv       string // e.g. "PageProfile"
	MethodName string // e.g. "POSTFoo"
}

ErrorActionPathNotUnderPage is ErrActionPathNotUnderPage with suggestion context.

func (*ErrorActionPathNotUnderPage) Error added in v0.2.0

func (*ErrorActionPathNotUnderPage) Unwrap added in v0.2.0

func (e *ErrorActionPathNotUnderPage) Unwrap() error

type ErrorEventCommInvalid added in v0.2.0

type ErrorEventCommInvalid struct {
	TypeName string // e.g. "EventFoo"
}

ErrorEventCommInvalid is ErrEventCommInvalid with suggestion context.

func (*ErrorEventCommInvalid) Error added in v0.2.0

func (e *ErrorEventCommInvalid) Error() string

func (*ErrorEventCommInvalid) Unwrap added in v0.2.0

func (e *ErrorEventCommInvalid) Unwrap() error

type ErrorEventCommMissing added in v0.2.0

type ErrorEventCommMissing struct {
	TypeName string // e.g. "EventFoo"
}

ErrorEventCommMissing is ErrEventCommMissing with suggestion context.

func (*ErrorEventCommMissing) Error added in v0.2.0

func (e *ErrorEventCommMissing) Error() string

func (*ErrorEventCommMissing) Unwrap added in v0.2.0

func (e *ErrorEventCommMissing) Unwrap() error

type ErrorEventFieldDuplicateTag added in v0.2.3

type ErrorEventFieldDuplicateTag struct {
	FieldName string // e.g. "UserID"
	TagValue  string // e.g. "user_id"
	TypeName  string // e.g. "EventFoo"
}

ErrorEventFieldDuplicateTag is ErrEventFieldDuplicateTag with suggestion context.

func (*ErrorEventFieldDuplicateTag) Error added in v0.2.3

func (*ErrorEventFieldDuplicateTag) Unwrap added in v0.2.3

func (e *ErrorEventFieldDuplicateTag) Unwrap() error

type ErrorEventFieldEmptyTag added in v0.2.3

type ErrorEventFieldEmptyTag struct {
	FieldName string // e.g. "UserID"
	TypeName  string // e.g. "EventFoo"
}

ErrorEventFieldEmptyTag is ErrEventFieldEmptyTag with suggestion context.

func (*ErrorEventFieldEmptyTag) Error added in v0.2.3

func (e *ErrorEventFieldEmptyTag) Error() string

func (*ErrorEventFieldEmptyTag) Unwrap added in v0.2.3

func (e *ErrorEventFieldEmptyTag) Unwrap() error

type ErrorEventFieldMissingTag added in v0.2.0

type ErrorEventFieldMissingTag struct {
	FieldName string // e.g. "UserID"
	TypeName  string // e.g. "EventFoo"
}

ErrorEventFieldMissingTag is ErrEventFieldMissingTag with suggestion context.

func (*ErrorEventFieldMissingTag) Error added in v0.2.0

func (e *ErrorEventFieldMissingTag) Error() string

func (*ErrorEventFieldMissingTag) Unwrap added in v0.2.0

func (e *ErrorEventFieldMissingTag) Unwrap() error

type ErrorPageInvalidPathComm added in v0.2.0

type ErrorPageInvalidPathComm struct {
	TypeName string // e.g. "PageProfile"
}

ErrorPageInvalidPathComm is ErrPageInvalidPathComm with suggestion context.

func (*ErrorPageInvalidPathComm) Error added in v0.2.0

func (e *ErrorPageInvalidPathComm) Error() string

func (*ErrorPageInvalidPathComm) Unwrap added in v0.2.0

func (e *ErrorPageInvalidPathComm) Unwrap() error

type ErrorPageMissingFieldApp added in v0.2.0

type ErrorPageMissingFieldApp struct {
	TypeName string // e.g. "PageProfile"
}

ErrorPageMissingFieldApp is ErrPageMissingFieldApp with suggestion context.

func (*ErrorPageMissingFieldApp) Error added in v0.2.0

func (e *ErrorPageMissingFieldApp) Error() string

func (*ErrorPageMissingFieldApp) Unwrap added in v0.2.0

func (e *ErrorPageMissingFieldApp) Unwrap() error

type ErrorPageMissingGET added in v0.2.0

type ErrorPageMissingGET struct {
	TypeName string // e.g. "PageProfile"
}

ErrorPageMissingGET is ErrPageMissingGET with suggestion context.

func (*ErrorPageMissingGET) Error added in v0.2.0

func (e *ErrorPageMissingGET) Error() string

func (*ErrorPageMissingGET) Unwrap added in v0.2.0

func (e *ErrorPageMissingGET) Unwrap() error

type ErrorPageMissingPathComm added in v0.2.0

type ErrorPageMissingPathComm struct {
	TypeName string // e.g. "PageProfile"
}

ErrorPageMissingPathComm is ErrPageMissingPathComm with suggestion context.

func (*ErrorPageMissingPathComm) Error added in v0.2.0

func (e *ErrorPageMissingPathComm) Error() string

func (*ErrorPageMissingPathComm) Unwrap added in v0.2.0

func (e *ErrorPageMissingPathComm) Unwrap() error

type Errors

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

func Parse

func Parse(appPackagePath string) (app *model.App, errs Errors)

func (*Errors) All

func (e *Errors) All() iter.Seq2[int, error]

func (*Errors) Entry

func (e *Errors) Entry(i int) (token.Position, error)

func (*Errors) Err

func (e *Errors) Err(err error)

func (*Errors) ErrAt

func (e *Errors) ErrAt(pos token.Position, err error)

func (*Errors) Error

func (e *Errors) Error() string

func (*Errors) Len

func (e *Errors) Len() int

Directories

Path Synopsis
Package errsuggest provides fix suggestions for parser errors.
Package errsuggest provides fix suggestions for parser errors.
internal
methodkind
Package methodkind classifies handler method names into HTTP method kinds (GET, POST, PUT, DELETE) or event handlers.
Package methodkind classifies handler method names into HTTP method kinds (GET, POST, PUT, DELETE) or event handlers.
paramvalidation
Package paramvalidation validates handler parameter structs (path, query, signals) and route-to-path consistency.
Package paramvalidation validates handler parameter structs (path, query, signals) and route-to-path consistency.
structinspect
Package structinspect provides AST helpers for inspecting Go struct types and method receivers.
Package structinspect provides AST helpers for inspecting Go struct types and method receivers.
structtag
Package structtag provides struct tag value extraction and cross-validation for Datapages handler parameters.
Package structtag provides struct tag value extraction and cross-validation for Datapages handler parameters.
typecheck
Package typecheck provides type-checking predicates for common Go types used in Datapages handler signatures.
Package typecheck provides type-checking predicates for common Go types used in Datapages handler signatures.

Jump to

Keyboard shortcuts

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