lang

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ManifestSchemaVersion = 1

ManifestSchemaVersion is the current gowdk manifest JSON schema version.

Variables

This section is empty.

Functions

func CheckFiles

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

CheckFiles parses and validates .gwdk files.

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.

func RedactMessage added in v0.2.7

func RedactMessage(message string) string

RedactMessage masks values that commonly carry credentials so a diagnostic quoting .gwdk source content (attribute values, expressions, route or store literals) does not echo a hardcoded secret into terminal output, check --json payloads, or LSP diagnostics.

It is deliberately conservative and mirrors the runtime panic-log policy: it favours over-masking a suspicious token over letting a real secret through.

Types

type CheckResult added in v0.2.8

type CheckResult struct {
	IR       gwdkir.Program
	Bindings []source.BackendBinding
}

CheckResult is the validated program produced by CheckFiles: the IR with discovered standalone Go endpoints and backend handler bindings attached, plus the flat binding record list for the manifest JSON report.

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) MarshalJSON added in v0.2.7

func (diagnostic Diagnostic) MarshalJSON() ([]byte, error)

MarshalJSON redacts secret-bearing source content from the message and suggestion before serialization so check --json and other JSON sinks never emit a hardcoded secret quoted from .gwdk source.

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 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) (gwdkir.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 report for parsed and validated files. The report shape is derived from the compiler IR.

func ParseBuildFiles

func ParseBuildFiles(paths []string) (gwdkanalysis.Sources, Diagnostics)

ParseBuildFiles parses explicit page and component files for build commands.

func ParseComponentSource

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

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

func ParseFile

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

ParseFile reads and parses one .gwdk file.

func ParseFiles

func ParseFiles(paths []string) (gwdkanalysis.Sources, Diagnostics)

ParseFiles parses multiple .gwdk files into IR source records.

func ParseLayoutSource

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

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

func ParseSource

func ParseSource(path string, source []byte) (gwdkir.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 BuildSiteMapFromIR added in v0.2.6

func BuildSiteMapFromIR(config gowdk.Config, ir gwdkir.Program) SiteMap

BuildSiteMapFromIR converts stable compiler IR 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 source.BackendBindingStatus `json:"bindingStatus,omitempty"`
	Signature     source.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