lang

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(source []byte) []byte

Format normalizes whitespace for top-level .gwdk annotations and blocks.

func Lex

func Lex(source string) ([]Token, Diagnostics)

Lex tokenizes .gwdk source for editor and CLI tooling.

Types

type Completion

type Completion struct {
	Label  string
	Detail string
}

Completion describes one language completion shared by editor integrations.

func Completions

func Completions() []Completion

Completions returns the core .gwdk language keywords known to editor tools.

type Diagnostic

type Diagnostic struct {
	File       string   `json:"file"`
	Code       string   `json:"code,omitempty"`
	Pos        Position `json:"pos"`
	Range      *Range   `json:"range,omitempty"`
	Severity   string   `json:"severity"`
	Message    string   `json:"message"`
	Suggestion string   `json:"suggestion,omitempty"`
}

Diagnostic describes a language-tool finding.

func (Diagnostic) String

func (diagnostic Diagnostic) String() string

type DiagnosticReport

type DiagnosticReport struct {
	Diagnostics Diagnostics `json:"diagnostics"`
}

DiagnosticReport is the JSON shape consumed by editor integrations.

type Diagnostics

type Diagnostics []Diagnostic

Diagnostics is a collection that implements error.

func CheckFiles

func CheckFiles(config gowdk.Config, paths []string) (manifest.Manifest, Diagnostics)

CheckFiles parses and validates .gwdk files.

func CheckJSON

func CheckJSON(config gowdk.Config, paths []string) ([]byte, Diagnostics)

CheckJSON returns editor-friendly JSON diagnostics for parsed files.

func CheckSource

func CheckSource(config gowdk.Config, path string, source []byte) (manifest.Page, Diagnostics)

CheckSource parses and validates one in-memory .gwdk source buffer.

func ManifestJSON

func ManifestJSON(config gowdk.Config, paths []string) ([]byte, Diagnostics)

ManifestJSON returns the manifest JSON for parsed and validated files.

func ParseBuildFiles

func ParseBuildFiles(paths []string) (manifest.Manifest, Diagnostics)

ParseBuildFiles parses explicit page and component files for build commands.

func ParseComponentSource

func ParseComponentSource(path string, source []byte) (manifest.Component, Diagnostics)

ParseComponentSource parses one in-memory .cmp.gwdk source buffer.

func ParseFile

func ParseFile(path string) (manifest.Page, Diagnostics)

ParseFile reads and parses one .gwdk file.

func ParseFiles

func ParseFiles(paths []string) (manifest.Manifest, Diagnostics)

ParseFiles parses multiple .gwdk files into a manifest.

func ParseLayoutSource

func ParseLayoutSource(path string, source []byte) (manifest.Layout, Diagnostics)

ParseLayoutSource parses one in-memory .layout.gwdk source buffer.

func ParseSource

func ParseSource(path string, source []byte) (manifest.Page, Diagnostics)

ParseSource parses one .gwdk source buffer.

func SiteMapJSON

func SiteMapJSON(config gowdk.Config, paths []string) ([]byte, Diagnostics)

SiteMapJSON returns the JSON site map for parsed and validated files.

func (Diagnostics) Error

func (diagnostics Diagnostics) Error() string

func (Diagnostics) HasErrors

func (diagnostics Diagnostics) HasErrors() bool

HasErrors reports whether any diagnostic is an error.

type FileKind

type FileKind string

FileKind identifies the current source file category.

const (
	FileKindPage      FileKind = "page"
	FileKindComponent FileKind = "component"
	FileKindLayout    FileKind = "layout"
	FileKindAsset     FileKind = "asset"
	FileKindPlugin    FileKind = "plugin"
)

func ClassifySource

func ClassifySource(path string, source []byte) FileKind

ClassifySource classifies a .gwdk source file using current file-kind rules.

type Position

type Position struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

Position is a 1-based source location.

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

Range is a 1-based source range. End is exclusive.

type SiteMap

type SiteMap struct {
	Pages     []SiteMapPage     `json:"pages"`
	Routes    []SiteMapRoute    `json:"routes,omitempty"`
	Endpoints []SiteMapEndpoint `json:"endpoints,omitempty"`
}

SiteMap is an editor-facing route and file map.

func BuildSiteMap

func BuildSiteMap(config gowdk.Config, app manifest.Manifest) SiteMap

BuildSiteMap converts a manifest into the editor-facing site map.

type SiteMapBlocks

type SiteMapBlocks struct {
	Paths   bool     `json:"paths"`
	Build   bool     `json:"build"`
	Load    bool     `json:"load"`
	View    bool     `json:"view"`
	Actions []string `json:"actions,omitempty"`
	APIs    []string `json:"apis,omitempty"`
}

SiteMapBlocks records which top-level source blocks are present.

type SiteMapEndpoint added in v0.1.5

type SiteMapEndpoint struct {
	Kind          compiler.EndpointKind         `json:"kind"`
	Method        string                        `json:"method"`
	Route         string                        `json:"route"`
	PageID        string                        `json:"pageId"`
	Symbol        string                        `json:"symbol,omitempty"`
	Package       string                        `json:"package,omitempty"`
	BindingStatus manifest.BackendBindingStatus `json:"bindingStatus,omitempty"`
	Signature     manifest.BackendSignatureKind `json:"signature,omitempty"`
	InputType     string                        `json:"inputType,omitempty"`
}

SiteMapEndpoint describes one generated action/API endpoint graph entry.

type SiteMapPage

type SiteMapPage struct {
	ID            string           `json:"id"`
	Route         string           `json:"route"`
	Source        string           `json:"source"`
	Render        gowdk.RenderMode `json:"render"`
	Layouts       []string         `json:"layouts,omitempty"`
	Guard         []string         `json:"guard,omitempty"`
	DynamicParams []string         `json:"dynamicParams,omitempty"`
	Blocks        SiteMapBlocks    `json:"blocks"`
}

SiteMapPage describes one movable page file and its route identity.

type SiteMapRoute added in v0.1.5

type SiteMapRoute struct {
	Kind    compiler.RouteKind `json:"kind"`
	Method  string             `json:"method"`
	Route   string             `json:"route"`
	PageID  string             `json:"pageId"`
	Handler string             `json:"handler,omitempty"`
}

SiteMapRoute describes one generated route graph entry.

type Token

type Token struct {
	Kind   TokenKind
	Lexeme string
	Pos    Position
}

Token is a lexical token with source location.

type TokenKind

type TokenKind string

TokenKind identifies one lexical token.

const (
	TokenIllegal    TokenKind = "illegal"
	TokenEOF        TokenKind = "eof"
	TokenNewline    TokenKind = "newline"
	TokenAnnotation TokenKind = "annotation"
	TokenIdentifier TokenKind = "identifier"
	TokenString     TokenKind = "string"
	TokenLBrace     TokenKind = "lbrace"
	TokenRBrace     TokenKind = "rbrace"
	TokenComma      TokenKind = "comma"
	TokenColon      TokenKind = "colon"
	TokenQuestion   TokenKind = "question"
	TokenArrow      TokenKind = "arrow"
	TokenText       TokenKind = "text"
)

Jump to

Keyboard shortcuts

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