Skip to content

Add ABAP highlighting - #37

Open
DreierF wants to merge 2 commits into
TanStack:mainfrom
DreierF:add-abap
Open

DreierF wants to merge 2 commits into
TanStack:mainfrom
DreierF:add-abap

Conversation

@DreierF

@DreierF DreierF commented Oct 21, 2026

Copy link
Copy Markdown

Changes

ABAP fences currently fall back to plaintext. This adds an isolated abap definition (no aliases), registers it in the default entry, and exposes it as a selective import (@tanstack/highlight/languages/abap). It uses the existing collectPatternRanges helpers with a small linear scanner for comments and literals: no new token classes, no new dependencies, no cross-language imports, and no changes to core or to existing language modules.

Context-aware behaviour:

  • * comments in the first column versus multiplication, and " line comments
  • '…' and `…` literals with doubled delimiters
  • string templates |…{ expr }…|, where the { } holes are tokenized as code
  • case-insensitive and hyphenated keywords (CLASS-METHODS, START-OF-SELECTION)
  • field symbols <fs>, pragmas ##NEEDED, and class names before =>
  • component selectors (-, ->, =>, ~), which keep keyword-like names plain, for example ls_entry-type
  • ABAP requires spaces inside expression parentheses and around operators, so a word touching a parenthesis is a call or a declared name (update( … ), DATA(message)), and - or / inside names never become operators

The template scanner is iterative, so deeply nested templates cannot overflow the stack. A regression test tokenizes 50,000 nested holes in well under a second.

The branch is one commit for the module and tests, then one registration commit (default entry, barrel, size and bench profiles, fixture, docs tables, changeset).

Proposal: #35

Deliberate limits

  • A variable named like a keyword (value, length, key) is highlighted as a keyword outside the positions above. highlight.js behaves the same way.
  • Templates end at a line break, as in ABAP.

Validation

pnpm run verify passes, including the new test/abap.test.ts and a representative fixture in test/fixtures.ts. I also checked the output against a few hundred lines of real ABAP from static-analysis rule descriptions.

Core + ABAP, local Node 24: 7.93 KB minified / 3.64 KB gzip / 3.27 KB Brotli, with a 3.8 KB gzip budget. Most of it is the keyword list, which ABAP needs because it has no small reserved-word core. Core and every existing selective profile are unchanged. The all-language convenience entry grows from 52.74 KB minified / 17.68 KB gzip to 56.13 KB / 18.94 KB gzip, and its budget rises from 18.0 KB to 19.2 KB gzip.

#36 (C) touches the same registration lines and size budget. Whichever merges second needs a small rebase.

🤖 Generated with Claude Code

DreierF and others added 2 commits October 19, 2026 17:18
ABAP fences currently fall back to plaintext. This adds an isolated `abap` definition on the existing pattern helpers with a small linear scanner for comments and literals. It has no aliases, no new token classes, and no cross-language imports.

Context-aware behaviour: first-column `*` comments versus multiplication, `"` line comments, doubled-delimiter `'…'` and `` `…` `` literals, string templates whose `{ }` holes are tokenized as code, case-insensitive and hyphenated keywords (`CLASS-METHODS`, `START-OF-SELECTION`), field symbols, pragmas, and component selectors (`-`, `->`, `=>`, `~`) that keep keyword-like names plain. ABAP requires spaces inside expression parentheses and around operators, so a word touching a parenthesis is a call or declared name, and `-` or `/` inside names never become operators.

Deliberate limits: a variable named like a keyword (`value`, `length`, `key`) is highlighted as a keyword outside those positions, and templates end at a line break as in ABAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds ABAP to the default entry and language barrel, with a size and benchmark profile, a representative fixture, docs tables, and a minor changeset. The all-language convenience entry grows from 17.68 KB to 18.94 KB gzip and its budget rises to 19.2 KB; core and existing selective profiles are unchanged. Most of the growth is the keyword list, which ABAP needs because it has no small reserved-word core.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DreierF DreierF mentioned this pull request Oct 21, 2026
@changeset-bot

changeset-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 86c7755

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/highlight Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dfcde623-5c3d-4a91-9b32-da8611fe979b
📥 Commits

Reviewing files that changed from the base of the PR and between 0541f2f and 86c7755.

📒 Files selected for processing: 18
  • .changeset/abap.md
  • README.md
  • docs/guides/performance.md
  • docs/installation.md
  • docs/language-support.md
  • docs/reference/default-entry.md
  • docs/reference/languages.md
  • docs/test-strategy.md
  • scripts/bench.mjs
  • scripts/language-utils.mjs
  • scripts/measure-size.mjs
  • skills/configure-selective-highlighting/references/languages.md
  • src/index.ts
  • src/languages/abap.ts
  • src/languages/index.ts
  • test/abap.test.ts
  • test/fixtures.ts
  • test/real-doc-fixtures.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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