Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- In Kotlin, a call on a library type you import, like Jetpack Compose's `Modifier.pad()`, now links to the extension your project declares on that type, `fun Modifier.pad()`, when the calling file can see it: in the same package, or imported by name or with `.*`. The library type's own methods, like `Modifier.fillMaxSize()`, still never link to a project method that shares the name. Re-index Kotlin projects after upgrading. Thanks @danusha2345.
- In Kotlin, when two packages each declare a class with the same name, a call on a value of that type now links to the class the file imports, even when that class lives in a file named for something else, like `FooConverter` in `Converters.kt`. Before, it went to whichever of the two came first. Java calls on such a class, like okhttp's Java tests calling the `mockwebserver3.MockWebServer` they import, now link through the type their variable is declared with (#1942). Re-index Kotlin projects after upgrading. Thanks @arttttt.
- In Kotlin and Java, a call through an import of a class written in the other language now links to that class: Kotlin's `JUtil.make()`, `JUtil.Nested.deep()` or `Outer.Inner()` on an imported Java class, and Java's `KUtil.INSTANCE.kmake()` on a Kotlin object, `Factory.Companion.create()` on a companion object or `UtilsKt.helper()` on a Kotlin file's top-level function, whose import now links that file. Before, the import was only matched against files in the calling file's own language, so the call went to a same-named class in another package, or to nothing. A Kotlin extension declared in another package, like `fun Modes.hidden()`, is now reached only from a file that imports it or its package. Re-index Kotlin and Java projects after upgrading. Thanks @mixxer.
- In Java, Kotlin and C#, a supertype written through its enclosing type, like `class Named extends Outer.Inner`, `implements Api.Listener`, `new Api.Listener() { … }`, Kotlin's `class K : Outer.Inner()` or C#'s `class N : Outer.IListener`, now links to that nested type when the file can name the outer type, and a method a class inherits through a nested type, like a builder's `build()` from its `AbstractBuilder`, is that type's rather than a namesake's. Before, Java and C# left it unlinked, a Java anonymous class kept only the last name, and Kotlin linked the outer type instead. A Kotlin object expression, like `object : Listener { … }` passed as a callback or held in a property, is now indexed as an anonymous class, as Java's `new Listener() { … }` is: its overrides are its own methods, so a call through the interface reaches them and `codegraph_explore` follows a callback into its body. Re-index Java, Kotlin and C# projects after upgrading. Thanks @mixxer.
- In JavaScript and TypeScript, a `super.run()` call now links to the method of the class's parent, or of the nearest ancestor that has it, like three.js's `super.copy(source)` reaching `Object3D.copy`, so `codegraph_explore`'s call path and impact follow an override into the method it builds on. Before, such a call inside a method of the same name was dropped, and elsewhere it went to whatever method had the name, often the class's own or a sibling class's in the same file. A call from a static method reaches the parent's static method, and a call to a parent from outside your project, like `HTMLElement`, `Set` or `Promise`, links nothing. Re-index JavaScript and TypeScript projects after upgrading. Thanks @Puma7 for the report and the pull request. (#2497)
- In JavaScript and TypeScript, a named class expression, like `register(class Widget extends Base {…})`, `customElements.define('x-card', class XCard extends HTMLElement {…})` or `const Panel = class PanelImpl extends Base {…}`, is now indexed as a class with its own methods and the class it extends, so calls between its methods and its `super` calls link as a class declaration's do. Before, its methods were free functions or weren't indexed at all, and it extended nothing. Its name stays bound inside the expression alone, as JavaScript has it: `new Widget()` elsewhere links nothing, a constant, class or interface of the same name around it keeps its links, and code outside never reaches its methods by a guess. A class a CommonJS module exports, like webpack's `module.exports = class MultiCompiler {…}` or `exports.Store = class Store {…}`, is reached through `require` as a class declaration is, along with its static methods and the methods called on its instances. Re-index JavaScript and TypeScript projects after upgrading. Thanks @Puma7 for the report and the pull request. (#2499)
- In Go, a call through a struct field that holds a function, like prometheus's `d.refreshf(ctx)`, now reaches the functions put in that field, so `codegraph_explore` follows service discovery from `Discovery.Run` into each provider's `refresh` and names the line where each provider wires its method in, like `RefreshF: d.refresh`. The field can be set in a struct literal or by an assignment, copied from another struct's field (`refreshf: opts.RefreshF`), or given a method of an interface value, and two unrelated structs with a field of the same name, like `fn` or `handler`, stay apart. Before, such a flow stopped at the field. Re-index Go projects after upgrading.
Expand Down
9 changes: 9 additions & 0 deletions __tests__/fixtures/kernel-parity/Torture.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,12 @@ interface Shape extends Comparable<Shape>, Cloneable {
@interface Marker {
String value() default "";
}

class DottedAnon {
Api.Listener listener = new Api.Listener<String>() {
public void on() {}
};
Object plain = new java.util.concurrent.Callable<Integer>() {
public Integer call() { return 1; }
};
}
38 changes: 38 additions & 0 deletions __tests__/fixtures/kernel-parity/torture.kt
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,41 @@ class ReceiverChainK(private val engine: EngineK) {
super.toString().length.toString()
}
}

// Object expressions as anonymous classes: dotted and generic supertypes, a
// constructor and a `by` delegate in the header, nested and supertype-less ones.
// (Multi-line bodies: a one-line class body sets the grammar's phantom error.)
class ObjectExpressions {
val held = object : Outer.Listener, Runnable {
override fun on() {
helper()
}
override fun run() {
}
}
fun make(): Base = object : Base(compute()) {
override fun run() {
val inner = object : Runnable {
override fun run() {
helper()
}
}
}
}
fun delegated() = object : api.IFoo by makeDelegate(), Marker {
val x = 1
}
fun generic() = object : pkg.Outer<IFoo.Stub>.Inner<List<String>>() {
val y = 2
}
fun bare() = object {
fun x() {
helper()
}
}
fun helper() {
}
fun compute(): Int = 1
}

class DottedSuper : Outer.Inner(), com.example.Api.Listener
Loading