Conversation
Register Scala and HCL language configs and extension mappings so .scala, .tf, and .hcl files are indexed via tree-sitter with coverage in parser and language unit tests. Made-with: Cursor
- Revert unrelated test script change (OTEL env var clearing) from package.json - Rename HCL block.name capture to block.type since it captures the block type keyword - Add block.label symbol query to capture HCL block labels (e.g. resource type and name strings) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds Tree-sitter–based language support for Scala (.scala) and HCL (.tf, .hcl) and registers both in the language configuration index, with accompanying unit tests for registration and basic parsing/recognition.
Changes:
- Add new language configurations for Scala and HCL (Tree-sitter parsers + queries).
- Register
scalaandhclinlanguageConfigurations. - Extend unit tests to include the new languages and verify basic parsing/extension recognition.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/languages/scala.ts |
Introduces Scala language config: suffixes, queries, symbol/import/export queries. |
src/languages/hcl.ts |
Introduces HCL language config: suffixes, queries, symbol queries. |
src/languages/index.ts |
Registers scala and hcl in the supported language map. |
tests/unit/parser.test.ts |
Adds Scala/HCL extension recognition parsing tests and includes them in test language list. |
tests/unit/languages.test.ts |
Adds coverage that parseLanguageNames and supported languages include scala and hcl. |
package.json |
Adds dependencies for Tree-sitter Scala and HCL grammars. |
package-lock.json |
Locks new dependency versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| '(return_expression) @return', | ||
| '(function_definition) @function', | ||
| '(class_definition) @class', | ||
| '(object_definition) @object', |
tests/unit/parser.test.ts
Outdated
| expect(result.chunks[0].language).toBe('handlebars'); | ||
| }); | ||
|
|
||
| it('should recognize .scala file extension', () => { |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds Scala and HCL language support. Two tree-sitter parser dependencies were added to package.json. New language configuration modules ( Sequence Diagram(s)sequenceDiagram
participant FS as FileSystem
participant LR as LanguageRegistry
participant P as LanguageParser
participant TS as TreeSitter
participant Out as Result
FS->>P: open file (.scala / .tf / .hcl)
P->>LR: determine language by extension
LR-->>P: return languageConfig (scala / hcl)
P->>TS: load parser from languageConfig (tree-sitter)
TS-->>P: AST + capture matches (queries)
P->>P: extract imports (strip quotes and leading 'import '), symbols, exports
P->>Out: return chunks with language, symbols, imports, exports, metrics
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unit/parser.test.ts (1)
357-382:⚠️ Potential issue | 🟡 MinorRemove duplicate C fixture tests at lines 357-382.
Lines 357-382 are exact duplicates of the same tests at lines 241-266 ("should parse C fixtures correctly" and "should extract symbols from C fixtures correctly"). Remove the duplicate test blocks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a33d080e-dd35-4092-b30b-b1a181c2c755
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
package.jsonsrc/languages/hcl.tssrc/languages/index.tssrc/languages/scala.tstests/unit/languages.test.tstests/unit/parser.test.ts
- Fix Scala importQueries: remove broken query pattern that silently failed due to tree-sitter-scala using flat identifier sequences (no wrapper node like Java's scoped_identifier) - Add trait_definition and enum_definition to Scala queries so exports for traits/enums are properly attached to chunks - Remove duplicate C fixture tests (exact copies of earlier tests) - Add Scala and HCL test fixtures with proper symbol and export extraction assertions - Update snapshots
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Integration Test ResultsDeployed the updated image to the k8s indexing cluster and ran a full index of elastic/cloud to validate Scala and HCL support end-to-end. Results
Total: 24,366 files and 103,244 symbols indexed across the repo. ValidationRan semantic searches against the indexed data via SCS and confirmed:
Semantic search is returning relevant, well-structured results for both languages. Ship it. 🚀 |
kapral18
left a comment
There was a problem hiding this comment.
Approved, but make sure to fix coderabbit and copilot suggestions before merge :)
|
All review feedback has been addressed in commit 6a7777d. Summary of changes made: CodeRabbit (CHANGES_REQUESTED on 9b0324c — now stale):
Copilot:
@coderabbitai resolve |
|
Resolving all open review comments now. ✅ Actions performedComments resolved and changes approved. |
Capture the whole import_declaration node as @import.path and strip the leading 'import ' keyword, rather than trying to capture individual path identifiers. This produces full dotted paths like 'scala.collection.mutable.ListBuffer' correctly. Also adds a test asserting Scala imports are extracted with full paths.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1b29bd9e-e378-43f7-b923-24a5ae3c38a3
⛔ Files ignored due to path filters (1)
tests/unit/__snapshots__/parser.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (5)
src/languages/scala.tssrc/utils/parser.tstests/fixtures/hcl.tftests/fixtures/scala.scalatests/unit/parser.test.ts
- Fix chained .replace() formatting in parser.ts - Fix misleading '// A case class' comment in scala fixture - Fix trailing comma formatting in import assertion test
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 19dabc80-efd9-4647-a3de-182b4c884c0c
⛔ Files ignored due to path filters (1)
tests/unit/__snapshots__/parser.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (3)
src/utils/parser.tstests/fixtures/scala.scalatests/unit/parser.test.ts
There was a problem hiding this comment.
Pull request overview
Adds Tree-sitter-based language support for Scala (.scala) and HCL (.tf, .hcl) to the parser/language-configuration system, along with fixtures, unit tests, and dependency updates.
Changes:
- Add new language configurations for Scala and HCL (Tree-sitter parsers + symbol/import/export queries as applicable).
- Update Tree-sitter import-path extraction to handle Scala
import_declarationcaptures. - Add fixtures + unit tests for extension recognition, parsing, and symbol/import/export extraction; update snapshots accordingly.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/utils/parser.ts |
Normalizes import capture text (strip quotes + leading import) to support Scala import captures. |
src/languages/scala.ts |
Introduces Scala language configuration (suffixes, queries, symbols, exports, imports). |
src/languages/hcl.ts |
Introduces HCL language configuration (suffixes, queries, symbols). |
src/languages/index.ts |
Registers scala and hcl in the central language configuration map. |
tests/unit/parser.test.ts |
Adds parsing/extension/symbol/import/export tests for Scala and HCL. |
tests/unit/languages.test.ts |
Adds parseLanguageNames coverage for scala and hcl. |
tests/fixtures/scala.scala |
Scala fixture for parser/symbol/import/export assertions. |
tests/fixtures/hcl.tf |
HCL fixture for parser/symbol assertions. |
tests/unit/__snapshots__/parser.test.ts.snap |
Snapshot updates reflecting new fixtures and test ordering/output. |
package.json / package-lock.json |
Adds Tree-sitter grammar dependencies for Scala and HCL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/languages/hcl.ts
Outdated
| queries: ['(block) @block', '(attribute) @attribute', '(function_call) @function_call', '(comment) @comment'], | ||
| symbolQueries: [ | ||
| '(block (identifier) @block.type)', | ||
| '(block (string_lit) @block.label)', |
There was a problem hiding this comment.
HCL block label symbols are currently captured as string_lit, which includes the surrounding quotes in capture.node.text (e.g. names like "region"). This makes extracted symbol names inconsistent with other languages and harder to consume downstream. Consider capturing the unquoted string content node instead (if the grammar exposes one) or normalizing block.label symbol text to strip the surrounding quotes.
| '(block (string_lit) @block.label)', | |
| '(block (string_lit (string_content) @block.label))', |
- Handle indented import declarations with ^\s*import\s+ regex - Expand HCL symbol assertions to cover block.label and attribute.name
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
- Fix HCL block.label symbols to capture unquoted names via template_literal instead of string_lit (e.g. 'aws_s3_bucket' instead of '"aws_s3_bucket"') - Refactor repetitive temp-file extension tests into shared helper - Update HCL block.label assertions to expect unquoted values - Update snapshot
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
.scala) language support with tree-sitter parser, including symbol queries for classes, objects, traits, functions, vals/vars, and export queries.tf,.hcl) language support with tree-sitter parser, including symbol queries for block types, block labels, attributes, and function callsTest plan
.tfand.hclextensions)🤖 Generated with Claude Code