Skip to content
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

Navigation not working #347

Closed
mauromol opened this issue Sep 28, 2017 · 7 comments
Closed

Navigation not working #347

mauromol opened this issue Sep 28, 2017 · 7 comments
Assignees

Comments

@mauromol
Copy link

This use case is taken from the old GRECLIPSE-1755, but the symptom is different.

Create a Groovy project which depends on org.hibernate:hibernate-core:3.5.6-Final and write the following class:

package f

import org.hibernate.SQLQuery
import org.hibernate.SessionFactory
import org.hibernate.impl.SessionFactoryImpl

class F { 
	static main(args) { 
		SessionFactory sf = new SessionFactoryImpl(null, null, null, null, null) 
		SQLQuery query = sf.currentSession.createSQLQuery('SELECT BLA BLA') 
	} 
}

When I opened GRECLIPSE-1755, Greclipse was confusing org.hibernate.Session.createSQLQuery(String) with org.hibernate.classic.Session.createSQLQuery(String, String, Class), which is deprecated, and hence it was showing my method call with the deprecation highlighting.
This does not happen any more, but what I see now is that I can't navigate to org.hibernate.impl.SessionFactoryImpl.getCurrentSession() (by hitting F3 on currentSession) or to org.hibernate.Session.createSQLQuery(String) (by hitting F3 on createSQLQuery). Eclipse does nothing, apart from writing "Current text selection cannot be opened in an editor" in the status bar.

By the way, I noticed a lot of such problems in one of our main projects, but it's hard to extract a small and sharable use case from there. While trying to reproduce GRECLIPSE-1755 I could finally reproduce this behaviour, I hope you'll be able to reproduce as well.

@eric-milles
Copy link
Member

eric-milles commented Sep 28, 2017 via email

@mauromol
Copy link
Author

This is what Greclipse writes to the Groovy Event Console when I click on currentSession:

Code select : 17:13:06 F.groovy at [272,0]
   Code select : 17:13:06 F.groovy at [272,0]
   Code select : 17:13:06 Event complete: 0ms: Code select: F.groovy
   Code select : 17:13:06 Event complete: 0ms: Code select: F.groovy

@eric-milles
Copy link
Member

eric-milles commented Sep 29, 2017 via email

@eric-milles
Copy link
Member

Interesting. Ctrl clicking on currentSession goes to org.hibernate.SessionFactory.getCurrentSession() as expected. Only the F3 (Open Declaration) key binding fails.

@mauromol
Copy link
Author

Yes, it's interesting. I didn't realize that, I never use Ctrl+Click...

@eric-milles
Copy link
Member

Ctrl-click is entering CodeSelectHelper.select with a offset and length that cover the entire name. F3 enters the same with the offset of the cursor and a length of 0. Because of this difference, the string literal check (below) is improperly returning true.

    protected static boolean isStringLiteral(ASTNode node, char[] contents, int start, int length) {
        if (node instanceof ConstantExpression && ClassHelper.STRING_TYPE.equals(((ConstantExpression) node).getType())) {
            return (start > node.getStart() && length < node.getLength());
        }
        return false;
    }

@mauromol
Copy link
Author

mauromol commented Oct 2, 2017

Hi Eric,
I tested this with 2.9.2.xx-201710020138-e46 and this use case works well now, thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants