feat: highlight getter/setter/deleter property accessors#86
Merged
kugesan1105 merged 1 commit intoMay 21, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds syntax highlighting for Jac's property accessors —
getter,setter, anddeleterkeywords insidehas <name>: <type> { ... }blocks.A new
#accessorrule mirrors the existing#abilityrule (which handlesdef/can/impl):meta.function.accessor.jac.#parameters, sosetter(value: float)highlightsvalueasvariable.parameter.function.language.jac,:aspunctuation.separator.annotation.jac, andfloatassupport.type.jac— same as parameters on anydef.(?<!\.)to avoid matchingsetterafter a dot in dotted-impl forms likeimpl Foo.bar.setter, where it should stay an identifier (attribute), not a keyword.Changes
syntaxes/jac.tmLanguage.json— new#accessorrepository entry, wired into#elementsbefore#has/#ability.examples/property_accessors.jac— fixture exercising the four shapes (typed getter+setter with bodies, bare getter, signature-onlygetter;/setter(...);/deleter;, full inline bodies).src/__tests__/inspectTokenScopes.test.ts— 3 tests asserting: getter keyword scope, setter parameter scope (the key reason for themeta.function.accessor.jacwrapper), and signature-onlydeleter;.Test plan
npm run test:unit— 190/190 tests pass, including the new property_accessors block.examples/property_accessors.jacand confirmgetter/setter/deleterare colored as keywords, parameter names are colored likedefparams, and types/->are colored correctly.has,def,impl Foo.barhighlighting is unchanged.