-
Notifications
You must be signed in to change notification settings - Fork 2.5k
TML-3230: declare block-level attributes on the attribute-spec kit (block-attributes-on-kit) #30162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ca870cc
5ba5fbc
45cd83c
b7b17f9
5a70545
768eaf5
c6ac2cc
7121335
9c7b807
b991bd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ export type { | |
| PslExtensionBlockParamRef, | ||
| PslExtensionBlockParamScalarValue, | ||
| PslExtensionBlockParamValue, | ||
| PslExtensionBlockParsedAttribute, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Keep the type export in an
As per coding guidelines: “Do not re-export from one file in another, except in 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| PslPosition, | ||
| PslSpan, | ||
| } from '../shared/psl-extension-block'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import type { PslDiagnostic } from '@internal/framework-components/psl-ast'; | ||
| import type { AstNode } from '../syntax/ast-helpers'; | ||
| import type { | ||
| AttributeOut, | ||
| AttributeSpec, | ||
| BlockInterpretCtx, | ||
| Param, | ||
| PositionalParam, | ||
| } from './types'; | ||
|
|
||
| interface BlockAttributeConfig< | ||
| Pos extends readonly PositionalParam<unknown, BlockInterpretCtx>[], | ||
| Named extends Record<string, Param<unknown, BlockInterpretCtx>>, | ||
| > { | ||
| readonly positional?: Pos; | ||
| readonly named?: Named; | ||
| readonly refine?: ( | ||
| parsed: AttributeOut<Pos, Named>, | ||
| ctx: BlockInterpretCtx, | ||
| attributeNode: AstNode, | ||
| ) => readonly PslDiagnostic[]; | ||
| } | ||
|
|
||
| export function blockAttribute< | ||
| const Pos extends readonly PositionalParam<unknown, BlockInterpretCtx>[] = readonly [], | ||
| const Named extends Record<string, Param<unknown, BlockInterpretCtx>> = Record<never, never>, | ||
| >( | ||
| name: string, | ||
| config: BlockAttributeConfig<Pos, Named>, | ||
| ): AttributeSpec<AttributeOut<Pos, Named>, BlockInterpretCtx> { | ||
| return { | ||
| level: 'block', | ||
| name, | ||
| positional: config.positional ?? [], | ||
| named: config.named ?? {}, | ||
| ...(config.refine !== undefined ? { refine: config.refine } : {}), | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Clarify the “No extension code runs” claim.
AuthoringPslBlockDescriptor.attributesnow uses nullary factories. The framework invokes those factories to obtain the specifications used for block-attribute interpretation. The sentence is inaccurate as written. Limit the claim to extension-specific parse and print code.As per coding guidelines, keep documentation current; update this sentence to match the new function-valued attribute contract.
Proposed wording
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines