GitNexus/gitnexus/test/fixtures/lang-resolution/java-method-reference/services/MethodRefService.java
Chirag Nighut e2de9271fc
feat(java): method references, worker overload disambiguation, interface dispatch (#540)
* feat(java): method references + worker overload disambiguation (TypeEnv + argTypes)

Fix two Java gaps: (1) method references (obj::method) via
  tree-sitter @call + parseJavaMethodReference wired through extractLanguageCallSiteSeed for parse-worker and call-processor; (2) overloaded calls with typed
  non-literal args by extending OverloadHints with TypeEnv for identifiers and adding ExtractedCall.argTypes from extractCallArgTypes on the worker path with
  matchCandidatesByArgTypes (inferJvmLiteralType remains for literals).

* test(csharp): expect interface-dispatch edge for IRepository.Save in heritage fixture

* refactor(ingestion): move parseJavaMethodReference to call-sites/java.ts

* refactor(ingestion): defer worker call resolution until implementor map is complete

* style: prettier + remove unused import for CI quality checks

Made-with: Cursor

* fix(ingestion): implementor map for C# base_list + sequential pipeline path

- buildImplementorMap: treat extends rows as implements when resolveExtendsType
  says IMPLEMENTS (worker heritage mirrors parse-worker, all base_list as extends)
- Worker path: pass ctx into buildImplementorMap(deferredWorkerHeritage, ctx)
- Sequential path: extract heritage before processCalls and pass implementor map
  so small repos get interface-dispatch CALLS (fixes csharp-proj integration test)

Made-with: Cursor

* perf(pipeline): accumulate sequential implementor map without O(E) per chunk

- Merge buildImplementorMap(chunk heritage) into one map each sequential chunk so
  work is O(heritage) per chunk and interface dispatch sees prior chunks (worker parity)
- Drop unused globalImplementorMap + redundant merge after worker pass

Made-with: Cursor
2026-03-28 16:59:28 +00:00

60 lines
1.6 KiB
Java

package services;
import java.util.List;
import java.util.stream.Collectors;
import models.ResponseBuilder;
import models.User;
import util.FormatUtil;
public class MethodRefService {
private ResponseBuilder responseBuilder;
/**
* Instance-bound reference (Synapse-style: mapVar::method).
*/
public List<String> mapViaInstanceBuilder(List<String> inputs) {
return inputs.stream()
.map(responseBuilder::buildResponse)
.collect(Collectors.toList());
}
/**
* Static method on a project class (not JDK) — {@code Util::staticMethod}.
*/
public List<String> mapViaStaticUtil(List<Object> values) {
return values.stream()
.map(FormatUtil::format)
.collect(Collectors.toList());
}
/**
* Unbound instance method reference — {@code Type::instanceMethod}.
*/
public List<String> mapUserNames(List<User> users) {
return users.stream()
.map(User::getName)
.collect(Collectors.toList());
}
/**
* Constructor reference — {@code Type::new}.
*/
public List<User> mapNewUsers(List<String> names) {
return names.stream()
.map(User::new)
.collect(Collectors.toList());
}
/**
* {@code this::instanceMethod} on enclosing class.
*/
public List<Boolean> mapSaves(List<User> users) {
return users.stream()
.map(this::saveOne)
.collect(Collectors.toList());
}
private boolean saveOne(User user) {
return user.save();
}
}