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:
+1
-1
@@ -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:
|
||||
|
||||
Vendored
+1
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user