-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong result in "Search for references" and "Call Hierarchy" with constructor overloading #1090
Comments
ready to test |
There's an improvement here (I had to rebuild the index), but I still see some inconsistencies. In the above project, change classes in this way: package test61;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Function;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
public class MyBean<T> {
public MyBean(final SessionFactory sessionFactory,
final DetachedCriteria baseCriteria,
final List<Order> defaultOrders,
final BiConsumer<Session, ? super T> postProcessor) {
this(sessionFactory, baseCriteria, defaultOrders, null, postProcessor);
}
public MyBean(final SessionFactory sessionFactory,
final DetachedCriteria baseCriteria,
final List<Order> defaultOrders,
final Map<String, ? extends Iterable<String>> customSortFields) {
}
public MyBean(final SessionFactory sessionFactory,
final DetachedCriteria baseCriteria,
final List<Order> defaultOrders,
final Map<String, ? extends Iterable<String>> customSortFields,
final BiConsumer<Session, ? super T> postProcessor) {
}
public MyBean(final SessionFactory sessionFactory,
final DetachedCriteria baseCriteria, final Order... defaultOrders) {
}
} (please note the addition of the And: package test61
import org.hibernate.SessionFactory
import org.hibernate.criterion.DetachedCriteria
import org.hibernate.criterion.Order
class Test61 {
SessionFactory shopSessionFactory
void foo() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'))
}
void bar() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'), Order.asc('foo'), Order.asc('bar'))
}
DetachedCriteria bar(String a, String, b, String c) {
}
} Now, invoke Call Hierarchy for Now, invoke "Search for references" for
Two interesting observations:
|
I suspect this change may have broken Call Hierarchy for pure-Java code as well, because it's now failing to find references to a simple |
The original case and the case demonstrated in your bar() method both have to do with the varargs parameter. One note that might help you in the future: when an exact match is not found, the first constructor is used. So if you want to have a "catch all" like the variadic orders, you can put that one first. I know it is just a workaround, but it may help you out while waiting for a fix. |
ready to test |
Unfortunately, I don't see improvements here in 3.8.0.v202004240308-e1912, even after I rebuilt the Java index. With this: package test61
import org.hibernate.SessionFactory
import org.hibernate.criterion.DetachedCriteria
import org.hibernate.criterion.Order
class Test61 {
SessionFactory shopSessionFactory
void foo() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'))
}
void bar() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'), Order.asc('foo'), Order.asc('bar'))
}
DetachedCriteria bar(String a, String, b, String c) {
}
}
With this: package test61
import org.hibernate.SessionFactory
import org.hibernate.criterion.DetachedCriteria
import org.hibernate.criterion.Order
class Test61 {
SessionFactory shopSessionFactory
void foo() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'))
}
void bar() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'), Order.asc('foo'))
}
DetachedCriteria bar(String a, String, b, String c) {
}
}
With this: package test61
import org.hibernate.SessionFactory
import org.hibernate.criterion.DetachedCriteria
import org.hibernate.criterion.Order
class Test61 {
SessionFactory shopSessionFactory
void foo() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'))
}
void bar2() {
def b = new MyBean(shopSessionFactory, bar('a', 'b', 'c'), Order.asc('foo'), Order.asc('bar'))
}
DetachedCriteria bar(String a, String, b, String c) {
}
} no match is found (!?!? Just changed Also, call hierarchy seems to be broken (see my comments above), and I'm pretty sure it was not before these changes. |
There must be some extra thing going on here. I imported your project and tested your foo and bar scenarios. I have test cases for 0, 1 and 2 arguments to the variadic parameter. When you change some unrelated element and the search results change, that tends to suggest something is missing in the indexing visitor. It must tag a source unit as having the potential for matches before the match locator will build AST and look deeply for search hits. The "broken" call hierarchy seems unrelated. I did not change anything that would touch the Java results, unless there is an exception being thrown along the way. But this would show up in your Error Log view. |
Note: You have "DetachedCriteria bar(String a, String, b, String c)" with an extra comma between "String" and "b". This may be having strange effects. Groovy is fine with this, seeing your declaration as "bar(String a, Object String, Object b, String c)". |
Yes, it seems like the broken With regards to the broken Call Hierarchy: I just checked with the exact same projects, same IDE version, but Greclipse 3.8.0.v202004230438-e1912 and call hierarchy for the aforementioned setXXX method works well, while it does not work on the system where I'm testing 3.8.0.v202004242058-e1912.
What I see in the system where it is broken is that wrong Call Hierarchy results are computed very quickly (while in the other system it takes a while to show the correct results), but no exception is produced in the error log. I can try to upgrade the workspace where things are working well to see if they get broken there too. |
Actually, I just upgraded Greclipse on the other workspace and Call Hierarchy still works there... Maybe I have some corruption in the workspace where it's broken. Rebuilding the index does not help, neither cleaning all projects... I may try to recreate the workspace from scratch... (actually, I was wondering whether that button "Rebuild Index" in Eclipse preferences does anything, I get no feedback at all when I press it...). |
For the records, I fixed my broken Call Hierarchy by creating a new workspace from scratch and then re-importing my projects... |
Consider the attached Eclipse/Gradle project:
Test61.zip
Go to:
test61.MyBean.MyBean(SessionFactory, DetachedCriteria, List<Order>, BiConsumer<Session, ? super T>)
Try to hit Ctrl+Alt+H or Ctrl+Shift+G: a reference is found in Test61.foo(), but the constructor actually called from there is rather
test61.MyBean.MyBean(SessionFactory, DetachedCriteria, Order...)
.I was not able to reproduce this problem with a smaller test case using simple types like
String
,Integer
, etc.. Maybe the difference is that the involved types are binary references to an external JAR (Hibernate, in this case).The text was updated successfully, but these errors were encountered: