Skip to content

90 scala support#91

Merged
colbymchenry merged 2 commits into
colbymchenry:mainfrom
firehooper:feature/90-scala-support
May 8, 2026
Merged

90 scala support#91
colbymchenry merged 2 commits into
colbymchenry:mainfrom
firehooper:feature/90-scala-support

Conversation

@firehooper
Copy link
Copy Markdown
Contributor

#90

@andreinknv
Copy link
Copy Markdown
Contributor

Hi! Sorry to drop in cold — I've been working through the open PR backlog and noticed your PR is waiting on the same architectural conflict as a bunch of other language PRs. I've opened a refactor PR (#116) that turns "adding a language" from a 6-file mutation into a 1-file addition. Once that lands, this PR rebases cleanly. Sharing the rebase template inline so you don't have to read the maintainer guide to do it.

After #116 merges, the rebase is mechanical

Step 1. Discard your changes to the monolithic files (#116 makes them auto-derived from the registry):

git checkout main -- \
  src/types.ts \
  src/extraction/grammars.ts \
  src/extraction/languages/index.ts \
  CLAUDE.md

Step 2. Move your extractor's registration into one file, src/extraction/languages/<your-language>.ts:

import { yourExtractor } from './your-extractor-config';
import type { LanguageDef } from './types';

export const YOUR_DEF: LanguageDef = {
  name: 'yourlang',
  displayName: 'Your Language',
  extensions: ['.ext'],
  includeGlobs: ['**/*.ext'],
  // For a tree-sitter grammar:
  grammar: { wasmFile: 'tree-sitter-yourlang.wasm', vendored: true, extractor: yourExtractor },
  // OR for a custom regex/template extractor (Liquid, HCL pattern):
  // customExtractor: (filePath, source) => new YourExtractor(filePath, source).extract(),
};

Step 3. Add 2 lines to src/extraction/languages/registry.ts:

import { YOUR_DEF } from './yourlang';   // alphabetical
// ...
const ALL_DEFS: readonly LanguageDef[] = [
  // ... alphabetical
  YOUR_DEF,
  // ...
];

Step 4. Add 'yourlang' to the Language union in src/types.ts (1 line).

Step 5. Your test additions in __tests__/extraction.test.ts work as-is — the registry refactor doesn't touch tests.

That's it. If your existing <extractor>.ts file is in the right shape (taking filePath+source for custom extractors, or being a LanguageExtractor for grammar-backed), it requires zero changes — just register it via LanguageDef.

Three of my own language PRs (#92, #94, #95) are already pre-rebased to this pattern as references if you want to see what a finished rebase looks like.

Happy to help with the rebase if you'd like — just let me know.

andreinknv added a commit to andreinknv/codegraph that referenced this pull request Apr 28, 2026
External PR (firehooper). Originally based on the monolithic
grammars.ts; rebased to per-language registry pattern.
- src/extraction/languages/scala.ts (scalaExtractor + SCALA_DEF)
- 'scala' added to Language union
- Vendored tree-sitter-scala.wasm
- Extensions: .scala, .sc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@firehooper
Copy link
Copy Markdown
Contributor Author

@andreinknv sure thing I can help with rebase after the new style has been merged. It will be nice to avoid the conflicts and get many more languages added. Thanks!

@andreinknv
Copy link
Copy Markdown
Contributor

I am like 471 commits more on my wip branch, lol. while waiting for pr merges to happen, I have completely refactored the whole codebase. I really like this project, it is actually helps a lot during AI coding.

Conflict resolution after 2 weeks of main moving:

- src/types.ts: main converted Language to a runtime-iterable
  LANGUAGES `as const` array. Kept that shape and added 'scala' near
  the end (matches Pascal's position).
- __tests__/extraction.test.ts: kept the PR's full Scala Extraction
  describe block AND main's Vue Extraction + Instantiates+Decorates
  describe blocks — they don't overlap. Closed the trailing describe
  on the Scala side (was hanging open due to where the conflict marker
  fell relative to the brace structure).

Verified live on real Scala codebases:
  - typelevel/cats (835 .scala files): 15,771 nodes, 24,462 edges,
    7,158 methods, 1,835 classes, 1,201 traits — search and context
    retrieval both return correct results with proper type signatures.
  - circe/circe (230 .scala files): 5,321 nodes, 5,091 edges, plus
    Scala 3 enums (10 enums / 150 enum_members) extracted correctly.

Full test suite: 503/503 pass (was 481, +22 Scala tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@colbymchenry
Copy link
Copy Markdown
Owner

Reviewed and merging — thanks for the contribution!

Pushed a conflict-resolution commit to your branch (main moved in 2 weeks):

  • src/types.ts was converted to a runtime-iterable LANGUAGES as const array; added 'scala' to it.
  • __tests__/extraction.test.ts had a 3-way text overlap with the Vue and Instantiates+Decorates describe blocks that landed since this PR opened — kept all three.

Verified live on real Scala codebases:

  • typelevel/cats (835 .scala files): 15,771 nodes, 24,462 edges. 7,158 methods, 1,835 classes, 1,201 traits, 256 type aliases. Search for Functor correctly returns the trait at Functor.scala:31, the companion class at :233, and method-level usages with type signatures (: Functor[F]). Context query returns proper Scala source with def, implicit def, and generic bounds ([A: Arbitrary]-style).
  • circe/circe (230 .scala files): 5,321 nodes, 5,091 edges, including Scala 3 enums (10 enums / 150 enum_members) extracted correctly.

Full test suite: 503/503 passing.

Closes #90.

@colbymchenry colbymchenry merged commit 8506936 into colbymchenry:main May 8, 2026
colbymchenry added a commit that referenced this pull request May 8, 2026
…anguages (#146)

- Reorder Get Started so the per-project init code block sits between
  the npx install and the GIF — visually contiguous code blocks read
  better than code → image → code.
- Add Scala (`.scala`, `.sc`) to the Supported Languages table now
  that #91 has landed.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@colbymchenry colbymchenry mentioned this pull request May 8, 2026
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.

3 participants