fix(scala): emit field type references for var declarations

The Scala field handler matched only `val_definition`, so a mutable field
(`var b: Repo`), which parses as `var_definition`, had its type reference
silently dropped from the graph. val and var nodes are structurally identical
(both expose a `type` field), so the existing type-collection logic works
unchanged. Widen the guard to accept var_definition.

Adds a var field to the Scala fixture and a regression test.
This commit is contained in:
Synvoya
2026-07-01 16:36:47 +01:00
committed by safishamsi
parent 784e9c833e
commit 67b4525f32
3 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -3868,7 +3868,7 @@ def _extract_generic(
return
if (config.ts_module == "tree_sitter_scala"
and t == "val_definition"
and t in ("val_definition", "var_definition")
and parent_class_nid):
type_node = node.child_by_field_name("type")
if type_node is not None:
+1
View File
@@ -7,6 +7,7 @@ abstract class BaseClient
class HttpClient(config: Config) extends BaseClient with Loggable {
val source: Config = config
var fallback: BaseClient = null
def get(path: String): String = {
buildRequest("GET", path)
+5
View File
@@ -655,6 +655,11 @@ def test_scala_val_definition_field_context():
assert ("HttpClient", "Config") in _edge_labels(r, "references", "field")
def test_scala_var_definition_field_context():
r = extract_scala(FIXTURES / "sample.scala")
assert ("HttpClient", "BaseClient") in _edge_labels(r, "references", "field")
def test_scala_method_return_type_context():
r = extract_scala(FIXTURES / "sample.scala")
assert ("create", "HttpClient") in _edge_labels(r, "references", "return_type")