Skip to content

feat: highlight getter/setter/deleter property accessors#86

Merged
kugesan1105 merged 1 commit into
jaseci-labs:mainfrom
kugesan1105:feat/property-accessor-highlighting
May 21, 2026
Merged

feat: highlight getter/setter/deleter property accessors#86
kugesan1105 merged 1 commit into
jaseci-labs:mainfrom
kugesan1105:feat/property-accessor-highlighting

Conversation

@kugesan1105

Copy link
Copy Markdown
Contributor

Summary

Adds syntax highlighting for Jac's property accessors — getter, setter, and deleter keywords inside has <name>: <type> { ... } blocks.

A new #accessor rule mirrors the existing #ability rule (which handles def/can/impl):

  • Wraps each accessor declaration in meta.function.accessor.jac.
  • Includes #parameters, so setter(value: float) highlights value as variable.parameter.function.language.jac, : as punctuation.separator.annotation.jac, and float as support.type.jac — same as parameters on any def.
  • Uses (?<!\.) to avoid matching setter after a dot in dotted-impl forms like impl Foo.bar.setter, where it should stay an identifier (attribute), not a keyword.

Changes

  • syntaxes/jac.tmLanguage.json — new #accessor repository entry, wired into #elements before #has / #ability.
  • examples/property_accessors.jac — fixture exercising the four shapes (typed getter+setter with bodies, bare getter, signature-only getter;/setter(...);/deleter;, full inline bodies).
  • src/__tests__/inspectTokenScopes.test.ts — 3 tests asserting: getter keyword scope, setter parameter scope (the key reason for the meta.function.accessor.jac wrapper), and signature-only deleter;.

Test plan

  • npm run test:unit — 190/190 tests pass, including the new property_accessors block.
  • Visual check: open examples/property_accessors.jac and confirm getter/setter/deleter are colored as keywords, parameter names are colored like def params, and types/-> are colored correctly.
  • Regression: confirm existing has, def, impl Foo.bar highlighting is unchanged.

Adds a new `#accessor` rule to the TextMate grammar that scopes
`getter|setter|deleter` keywords with the same `meta.function.*` shape
used for `def`/`can`/`impl`. The rule wraps in `meta.function.accessor.jac`
and includes `#parameters`, so a setter's parameter list (e.g.
`setter(value: float)`) is highlighted identically to a `def`'s
parameter list — parameter name as `variable.parameter.function.language.jac`,
`:` as `punctuation.separator.annotation.jac`, type as `support.type.jac`.

`(?<!\.)` in the begin pattern prevents the rule from firing on dotted-impl
references like `impl Foo.bar.setter`, where `setter` should remain an
identifier (attribute), not a keyword.

Adds an `examples/property_accessors.jac` fixture and three focused tests
covering: getter inside an accessor block, setter parameter scoping, and
the signature-only `deleter;` form.
@kugesan1105
kugesan1105 merged commit b30f2e9 into jaseci-labs:main May 21, 2026
2 checks passed
@kugesan1105
kugesan1105 deleted the feat/property-accessor-highlighting branch May 21, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant