Skip to content

Commit 69a9e89

Browse files
committed
fix: resolve merge conflicts with fix/native-prototype-extraction-1327
2 parents 3b11a8a + 7b4f369 commit 69a9e89

59 files changed

Lines changed: 2644 additions & 117 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/codegraph-core/src/edge_builder.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,3 +1406,52 @@ mod call_edge_tests {
14061406
assert_eq!(receiver_edge.unwrap().target_id, 2);
14071407
}
14081408
}
1409+
1410+
#[cfg(test)]
1411+
mod inline_new_type_tests {
1412+
use super::extract_inline_new_type;
1413+
1414+
#[test]
1415+
fn parens_new_uppercase() {
1416+
assert_eq!(extract_inline_new_type("(new Foo)"), Some("Foo".to_string()));
1417+
}
1418+
1419+
#[test]
1420+
fn parens_new_with_args() {
1421+
// (new Foo('arg')) — parens and constructor args
1422+
assert_eq!(extract_inline_new_type("(new Foo('arg'))"), Some("Foo".to_string()));
1423+
}
1424+
1425+
#[test]
1426+
fn no_parens_new_uppercase() {
1427+
assert_eq!(extract_inline_new_type("new Bar"), Some("Bar".to_string()));
1428+
}
1429+
1430+
#[test]
1431+
fn underscore_prefix_accepted() {
1432+
assert_eq!(extract_inline_new_type("new _Factory"), Some("_Factory".to_string()));
1433+
}
1434+
1435+
#[test]
1436+
fn dollar_prefix_accepted() {
1437+
assert_eq!(extract_inline_new_type("new $Service"), Some("$Service".to_string()));
1438+
}
1439+
1440+
#[test]
1441+
fn lowercase_constructor_rejected() {
1442+
// `new foo()` — lowercase, should return None to avoid false positives
1443+
assert_eq!(extract_inline_new_type("new foo"), None);
1444+
}
1445+
1446+
#[test]
1447+
fn not_a_new_expression() {
1448+
// plain receiver name — no `new` keyword
1449+
assert_eq!(extract_inline_new_type("myVar"), None);
1450+
}
1451+
1452+
#[test]
1453+
fn new_without_whitespace_is_not_new_keyword() {
1454+
// `newFoo` — not a `new` keyword, just an identifier
1455+
assert_eq!(extract_inline_new_type("newFoo"), None);
1456+
}
1457+
}

crates/codegraph-core/src/extractors/javascript.rs

Lines changed: 241 additions & 10 deletions
Large diffs are not rendered by default.

docs/benchmarks/RESOLUTION-COMPARISON.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,35 @@ Established Java static call graph tools all require compiled bytecode:
177177
| [Soot](https://github.com/soot-oss/soot) | CHA / RTA / VTA / Spark | Needs compiled `.class` files |
178178
| [javacg-static](https://github.com/gousiosg/java-callgraph) | CHA | Lightweight, reads JARs |
179179

180-
The fixture contains raw `.java` source with no build system. Running these
181-
tools requires a `javac` compilation step (tracked in #1307).
180+
The fixture now includes a `Makefile` that compiles all `.java` sources into
181+
`fixture.jar`:
182182

183-
**Current codegraph Java metrics** (`scripts/resolution-benchmark.ts`):
183+
```bash
184+
cd tests/benchmarks/resolution/fixtures/java && make
185+
```
186+
187+
`scripts/compare-javacg.mjs` then runs
188+
[javacg-static](https://github.com/gousiosg/java-callgraph) on the compiled JAR.
189+
javacg-static uses CHA to enumerate all possible call targets at virtual,
190+
interface, and static call sites.
191+
192+
```bash
193+
node scripts/compare-javacg.mjs --jar /path/to/javacg-0.1-SNAPSHOT.jar
194+
# or: JAVACG_JAR=... node scripts/compare-javacg.mjs
195+
```
196+
197+
Download javacg-static from
198+
[github.com/gousiosg/java-callgraph/releases](https://github.com/gousiosg/java-callgraph/releases)
199+
or build with `mvn package -DskipTests`.
200+
201+
**Name mapping:** javacg-static uses `pkg.ClassName:method(JVM-descriptors)` form.
202+
`compare-javacg.mjs` maps this to `ClassName.method` and matches
203+
`ClassName.ClassName` (source constructor) / `ClassName` (target constructor)
204+
against the expected-edges.json convention. Only edges where both class names
205+
appear in the fixture source files are counted; JDK calls (`String`, `HashMap`,
206+
`System.out`, …) are filtered out.
207+
208+
**Codegraph Java metrics** (`scripts/resolution-benchmark.ts`):
184209

185210
| Mode | Codegraph |
186211
|------|:---------:|
@@ -192,6 +217,19 @@ tools requires a `javac` compilation step (tracked in #1307).
192217
| `class-inheritance` (3 edges) | 0/3 (0%) |
193218
| **Total** | **9/17 (53%)** · precision=100% |
194219

220+
**javacg-static comparison** — run `node scripts/compare-javacg.mjs` to populate:
221+
222+
| Tool | Precision | Recall | TP | FP | FN |
223+
|------|:---------:|:------:|---:|---:|---:|
224+
| Codegraph | 100% | 53% | 9 | 0 | 8 |
225+
| javacg-static (CHA) ||||||
226+
227+
javacg-static uses CHA and reads compiled bytecode, so it should resolve
228+
`class-inheritance` (inherited `log()` calls) and `interface-dispatched`
229+
(virtual dispatch via `UserRepository` interface) edges that codegraph
230+
currently misses at the source-level. `static` and `same-file` calls
231+
(`invokestatic` in bytecode) should also be fully captured.
232+
195233
---
196234

197235
## Conclusions
@@ -231,8 +269,9 @@ tools requires a `javac` compilation step (tracked in #1307).
231269
2 `class-inheritance` edges (+7 recall on TS fixture).
232270
2. **Property-assignment type tracking** (#1306) — Track `this.prop = new Foo()`
233271
writes. Recovers 3 JS `receiver-typed` FN.
234-
3. **Java comparison with javacg-static** (#1307) — Add `javac` compilation to
235-
the Java fixture so a bytecode-level tool can validate Java recall claims.
272+
3. **Java recall gaps**`same-file` (0/2) and `static` (0/2) are `invokestatic`
273+
patterns that javacg-static will expose; `class-inheritance` (0/3) requires
274+
tracking inherited method calls from superclass to subclass invocation site.
236275

237276
---
238277

@@ -300,6 +339,10 @@ npx tsx scripts/resolution-benchmark.ts | jq '{javascript, typescript, java}'
300339
npm install @cs-au-dk/jelly @persper/js-callgraph
301340
node scripts/compare-tools.mjs --all
302341

342+
# javacg-static comparison (Java)
343+
cd tests/benchmarks/resolution/fixtures/java && make && cd -
344+
node scripts/compare-javacg.mjs --jar /path/to/javacg-0.1-SNAPSHOT.jar
345+
303346
# Full resolution test suite
304347
npx vitest run tests/benchmarks/resolution/resolution-benchmark.test.ts
305348
```

0 commit comments

Comments
 (0)