Skip to content

Add Scala support to repository analysis - #108

Merged
anhnh2002 merged 3 commits into
FSoft-AI4Code:mainfrom
mageshwaranr:scala-support-v1
Sep 16, 2026
Merged

anhnh2002 merged 3 commits into
FSoft-AI4Code:mainfrom
mageshwaranr:scala-support-v1

Conversation

@mageshwaranr

@mageshwaranr mageshwaranr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What

Adds Scala support, addresses #105.

How

New analyzers/scala.py following the same tree-sitter pattern as the Kotlin/Ruby
analyzers:

  • Components: classes, case classes, traits, objects, package objects, Scala 3
    enums, methods, and top-level functions. Uses a two-level component_type /
    node_type split — component_type is the coarse type the pipeline gates leaf
    selection on (traits → interface, objects → class, so both stay leaf-eligible and
    count toward the issue-C/C++ repository collapses to 5 leaf nodes during dependency analysis. Silent fallback to whole-repository mode #75 OOP heuristic), while node_type/display_name preserve
    the faithful Scala construct (trait, object, enum). This avoids widening the
    shared OOP_TYPES set, which would change documentation output for PHP/Kotlin/C++ as
    a side effect — a decision left for its own change.
  • Companion objects: get a $-suffixed component id (buffer.scala::Buffer vs.
    buffer.scala::Buffer$), mirroring Scala's own JVM encoding of module classes, so a
    class and its same-named companion never displace each other.
  • Relationships: inheritance, trait mixins, constructor-parameter and field types
    (including Scala 3 parameterized traits), instantiation, and method calls — resolving
    intra-file targets against a same-file symbol table and leaving external targets as
    unresolved logical names. A curated primitive/stdlib-call exclusion set (mirroring the
    Kotlin/PHP precedent) keeps Int, List, .map, .size, etc. out of the graph.
  • sbt build files: build.sbt and project/*.sbt classify as build
    manifest/artifact files (alongside the existing Maven/Gradle handling) rather than
    being parsed as application source; .sbt is deliberately never added to
    CODE_EXTENSIONS.

Registration follows the Ruby/Kotlin precedent end-to-end: both language whitelists in
analysis_service.py, the dispatcher branch + lang-scala cytoscape class in
call_graph_analyzer.py, .sc mapping and Scala function patterns in patterns.py,
module-path stripping in ast_parser.py, the source-extension set in artifact.py, the
code-fence language map in prompt_template.py, CLI repo validation and language
detection, and MCP incremental-change detection.

Dependency note: pins tree-sitter-scala==0.23.4, not the newer 0.26.2. Verified
empirically that 0.24.0+ compiles against grammar ABI 15, which raises
Incompatible Language version 15 under this repo's tree-sitter==0.23.2 core pin —
declared package metadata (tree-sitter~=0.22) doesn't reflect the actual compiled ABI.
0.23.4 is the last ABI-14 release and is node-for-node identical to 0.26.2 for every
construct the analyzer reads (verified by diffing field-annotated parse trees), so no
tree-sitter core bump is needed for this change.

Tests

tests/test_scala_analyzer.py (11 tests): component extraction (classes, traits,
objects, companion $ suffix, docstrings, parameters including curried parameter
groups), relationship extraction (resolved/unresolved inheritance and mixins,
constructor-parameter edges including Scala 3 parameterized traits, intra-file calls,
unresolved external calls across all three fallback paths, stdlib-noise exclusion),
Scala 3 enum/significant-indentation syntax, sbt artifact classification, .sc
extension end-to-end, empty-file handling, and a DependencyParser end-to-end test
proving the whitelist/dispatcher wiring and cross-file inheritance resolution.

Full existing suite (110 tests) passes with no regressions in the Python, Kotlin, PHP,
Ruby, or artifact analyzer tests. ruff check / ruff format --check clean on every
touched file.

🤖 Generated with Claude Code

@anhnh2002
anhnh2002 merged commit 7fe4745 into FSoft-AI4Code:main Sep 16, 2026
2 checks passed
@anhnh2002

Copy link
Copy Markdown
Collaborator

Thank you very much @mageshwaranr. Merged!

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.

2 participants