Documentation
¶
Index ¶
- Constants
- Variables
- func CheckFiles(config gowdk.Config, paths []string) (CheckResult, Diagnostics)
- func CheckFilesWithOptions(config gowdk.Config, paths []string, options CheckOptions) (CheckResult, Diagnostics)
- func Format(source []byte) []byte
- func FormatChecked(source []byte) (formatted []byte, ok bool)
- func IsMetadataKeyword(value string) bool
- func Lex(source string) ([]Token, Diagnostics)
- func RedactMessage(message string) string
- type CheckOptions
- type CheckResult
- type Completion
- type ConstructKind
- type ConstructStability
- type Diagnostic
- type DiagnosticReport
- type Diagnostics
- func CheckJSON(config gowdk.Config, paths []string) ([]byte, Diagnostics)
- func CheckJSONWithOptions(config gowdk.Config, paths []string, options CheckOptions) ([]byte, Diagnostics)
- func CheckSource(config gowdk.Config, path string, source []byte) (gwdkir.Page, Diagnostics)
- func CheckSourceWithOptions(config gowdk.Config, path string, source []byte, options CheckOptions) (gwdkir.Page, Diagnostics)
- func ManifestJSON(config gowdk.Config, paths []string) ([]byte, Diagnostics)
- func ManifestJSONWithOptions(config gowdk.Config, paths []string, options CheckOptions) ([]byte, Diagnostics)
- func ParseAuditSource(path string, source []byte) (gwdkir.AuditSpec, Diagnostics)
- func ParseBuildFiles(paths []string) (gwdkanalysis.Sources, Diagnostics)
- func ParseComponentSource(path string, source []byte) (gwdkir.Component, Diagnostics)
- func ParseFile(path string) (gwdkir.Page, Diagnostics)
- func ParseFiles(paths []string) (gwdkanalysis.Sources, Diagnostics)
- func ParseLayoutSource(path string, source []byte) (gwdkir.Layout, Diagnostics)
- func ParseSource(path string, source []byte) (gwdkir.Page, Diagnostics)
- func SiteMapJSON(config gowdk.Config, paths []string) ([]byte, Diagnostics)
- func SiteMapJSONWithOptions(config gowdk.Config, paths []string, options CheckOptions) ([]byte, Diagnostics)
- type FileKind
- type OutlineKind
- type OutlineSymbol
- type Position
- type Range
- type RelatedLocation
- type SiteMap
- type SiteMapBlocks
- type SiteMapEndpoint
- type SiteMapPage
- type SiteMapRoute
- type StabilityTier
- type Token
- type TokenKind
- type TopLevel
Constants ¶
const ( TokenIllegal = syntax.TokenIllegal TokenEOF = syntax.TokenEOF TokenNewline = syntax.TokenNewline TokenMetadata = syntax.TokenMetadata TokenIdentifier = syntax.TokenIdentifier TokenString = syntax.TokenString TokenLBrace = syntax.TokenLBrace TokenRBrace = syntax.TokenRBrace TokenComma = syntax.TokenComma TokenColon = syntax.TokenColon TokenAssign = syntax.TokenAssign TokenQuestion = syntax.TokenQuestion TokenArrow = syntax.TokenArrow TokenText = syntax.TokenText )
const ManifestSchemaVersion = 1
ManifestSchemaVersion is the current gowdk manifest JSON schema version.
Variables ¶
var MetadataKeywords = syntax.MetadataKeywords
MetadataKeywords and IsMetadataKeyword re-export the single source of truth the lexer and formatter share.
Functions ¶
func CheckFiles ¶
func CheckFiles(config gowdk.Config, paths []string) (CheckResult, Diagnostics)
CheckFiles parses and validates .gwdk files.
func CheckFilesWithOptions ¶ added in v0.3.0
func CheckFilesWithOptions(config gowdk.Config, paths []string, options CheckOptions) (CheckResult, Diagnostics)
CheckFilesWithOptions parses and validates .gwdk files with explicit project context for checks that need to inspect sibling Go code.
func Format ¶
Format normalizes whitespace for .gwdk source. When the file parses, it formats from the parsed structure: block kinds and boundaries come from the parser and view markup indentation comes from the parsed view node tree, so nested markup, multi-line attributes, and interpolations are indented from structure rather than line-by-line tag heuristics. When the file does not parse, it falls back to the conservative line-oriented formatter so malformed source is preserved instead of being rewritten destructively.
func FormatChecked ¶ added in v0.8.0
FormatChecked formats source and reports whether the file was formatted from its parsed structure. ok is false when the syntax does not parse; in that case the returned bytes come from the conservative line-oriented fallback, which only normalizes whitespace and never drops user source. Callers that must not rewrite malformed files (for example `gowdk fmt --write`) gate on ok.
func IsMetadataKeyword ¶ added in v0.3.0
IsMetadataKeyword reports whether value is a top-level metadata keyword.
func Lex ¶
func Lex(source string) ([]Token, Diagnostics)
Lex tokenizes .gwdk source for tooling, mapping each leaf-level LexError into a rich lang.Diagnostic (the error severity, redaction, and JSON marshaling stay in lang).
func RedactMessage ¶ added in v0.2.7
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 CheckOptions ¶ added in v0.3.0
type CheckOptions struct {
ProjectRoot string
}
CheckOptions controls validation behavior that depends on project context.
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 ¶
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 ConstructKind ¶ added in v0.3.0
type ConstructKind string
ConstructKind groups language constructs by surface.
const ( ConstructBlock ConstructKind = "block" ConstructKeyword ConstructKind = "metadata-keyword" ConstructDirective ConstructKind = "g-directive" ConstructMarkup ConstructKind = "markup" ConstructEndpoint ConstructKind = "endpoint" )
type ConstructStability ¶ added in v0.3.0
type ConstructStability struct {
Name string
Kind ConstructKind
Tier StabilityTier
DiagnosticCode string
}
ConstructStability is the stability record for one language construct. For planned and deprecated constructs DiagnosticCode names the diagnostic emitted when the construct is used.
func ConstructStabilities ¶ added in v0.3.0
func ConstructStabilities() []ConstructStability
ConstructStabilities returns the code-level source of truth for per-construct stability tiers. The published table in docs/language/stability.md is verified against it by TestStabilityTableMatchesRegistry. Metadata keywords are derived from MetadataKeywords so the two cannot drift.
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"`
Fix *diagnostics.Fix `json:"fix,omitempty"`
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
Related []RelatedLocation `json:"related,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 {
Version int `json:"version"`
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 CheckJSONWithOptions ¶ added in v0.3.0
func CheckJSONWithOptions(config gowdk.Config, paths []string, options CheckOptions) ([]byte, Diagnostics)
CheckJSONWithOptions returns editor-friendly JSON diagnostics for parsed files with explicit project context.
func CheckSource ¶
CheckSource parses and validates one in-memory .gwdk source buffer.
func CheckSourceWithOptions ¶ added in v0.5.0
func CheckSourceWithOptions(config gowdk.Config, path string, source []byte, options CheckOptions) (gwdkir.Page, Diagnostics)
CheckSourceWithOptions parses and validates one in-memory .gwdk source buffer with project context for checks that need sibling Go metadata.
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 ManifestJSONWithOptions ¶ added in v0.3.0
func ManifestJSONWithOptions(config gowdk.Config, paths []string, options CheckOptions) ([]byte, Diagnostics)
ManifestJSONWithOptions returns the manifest JSON report with explicit project context.
func ParseAuditSource ¶ added in v0.5.0
func ParseAuditSource(path string, source []byte) (gwdkir.AuditSpec, Diagnostics)
ParseAuditSource parses one in-memory *.audit.gwdk source buffer.
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 SiteMapJSONWithOptions ¶ added in v0.3.0
func SiteMapJSONWithOptions(config gowdk.Config, paths []string, options CheckOptions) ([]byte, Diagnostics)
SiteMapJSONWithOptions returns the JSON site map with explicit project context.
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.
func ClassifySource ¶
ClassifySource classifies a .gwdk source file using current file-kind rules.
type OutlineKind ¶ added in v0.3.0
type OutlineKind string
OutlineKind classifies a top-level .gwdk declaration for a document outline.
const ( OutlineKindPackage OutlineKind = "package" OutlineKindMetadata OutlineKind = "metadata" OutlineKindImport OutlineKind = "import" OutlineKindUse OutlineKind = "use" OutlineKindBlock OutlineKind = "block" OutlineKindEndpoint OutlineKind = "endpoint" OutlineKindComponent OutlineKind = "component" OutlineKindPage OutlineKind = "page" )
type OutlineSymbol ¶ added in v0.3.0
type OutlineSymbol struct {
Kind OutlineKind
Name string
Detail string
Span source.SourceSpan
}
OutlineSymbol is one entry in a document outline.
func Outline ¶ added in v0.3.0
func Outline(src string) []OutlineSymbol
Outline parses the top-level declaration structure of .gwdk source into a flat document outline. It is a recursive-descent pass over the shared tokenizer — the first consumer of the ADR 0010 parser direction — and recovers from unrecognized lines by skipping to the next line, so a malformed line never hides the rest of the outline. Block ranges span to the matching close brace, counted over tokens (string literals are single tokens, so braces inside strings never miscount).
type Position ¶
Token and position types are aliases, so lang.Token and syntax.Token are the same type and values cross the boundary without conversion.
type Range ¶
Token and position types are aliases, so lang.Token and syntax.Token are the same type and values cross the boundary without conversion.
type RelatedLocation ¶ added in v0.3.0
type RelatedLocation struct {
File string `json:"file,omitempty"`
Pos Position `json:"pos"`
Range *Range `json:"range,omitempty"`
Message string `json:"message,omitempty"`
}
RelatedLocation is a secondary source location attached to a diagnostic, such as the first declaration that a conflict diagnostic also points at.
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.
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"`
Fragments []string `json:"fragments,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"`
EndpointSource string `json:"endpointSource,omitempty"`
Source string `json:"source,omitempty"`
SourceSpan *sourceSpanJSON `json:"sourceSpan,omitempty"`
Method string `json:"method"`
Route string `json:"route"`
PageID string `json:"pageId"`
Symbol string `json:"symbol,omitempty"`
Package string `json:"package,omitempty"`
PackagePath string `json:"packagePath,omitempty"`
PackageName string `json:"packageName,omitempty"`
Cache string `json:"cache,omitempty"`
DynamicParams []string `json:"dynamicParams,omitempty"`
RouteParams []routeParamJSON `json:"routeParams,omitempty"`
Guards []string `json:"guards,omitempty"`
CSRF bool `json:"csrf,omitempty"`
Handler string `json:"handler,omitempty"`
BindingStatus source.BackendBindingStatus `json:"bindingStatus,omitempty"`
BindingMessage string `json:"bindingMessage,omitempty"`
Signature source.BackendSignatureKind `json:"signature,omitempty"`
InputType string `json:"inputType,omitempty"`
Contract *siteMapContractJSON `json:"contract,omitempty"`
}
SiteMapEndpoint describes one generated 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"`
Package string `json:"package,omitempty"`
Render gowdk.RenderMode `json:"render,omitempty"`
Cache string `json:"cache,omitempty"`
Locale string `json:"locale,omitempty"`
DynamicParams []string `json:"dynamicParams,omitempty"`
RouteParams []routeParamJSON `json:"routeParams,omitempty"`
Layouts []string `json:"layouts,omitempty"`
Guards []string `json:"guards,omitempty"`
Source string `json:"source,omitempty"`
SourceSpan *sourceSpanJSON `json:"sourceSpan,omitempty"`
Handler string `json:"handler,omitempty"`
}
SiteMapRoute describes one generated route graph entry.
type StabilityTier ¶ added in v0.3.0
type StabilityTier string
StabilityTier is the per-construct stability classification, mirroring the Stability field the diagnostics registry records for diagnostic codes.
const ( // TierStable: accepted today and not expected to change shape within 0.x // without a deprecation step. TierStable StabilityTier = "stable" // TierPartial: accepted for a narrower slice than the final contract. TierPartial StabilityTier = "partial" // TierPlanned: not accepted yet; using it is rejected with DiagnosticCode. TierPlanned StabilityTier = "planned" // TierDeprecated: previously accepted spelling, now rejected with // DiagnosticCode. TierDeprecated StabilityTier = "deprecated" )
type Token ¶
Token and position types are aliases, so lang.Token and syntax.Token are the same type and values cross the boundary without conversion.
type TokenKind ¶
Token and position types are aliases, so lang.Token and syntax.Token are the same type and values cross the boundary without conversion.
type TopLevel ¶ added in v0.3.0
Token and position types are aliases, so lang.Token and syntax.Token are the same type and values cross the boundary without conversion.
func ParseTopLevel ¶ added in v0.3.0
ParseTopLevel runs the recursive-descent declaration parser.