I use JQuery to detect undesirable dependencies between Java classes. Is it correct that there is no possibility to access the import declaration statements in Java files? I've found an imports(?cu,?el) predicate in the core predicate file but it seems that the corresponding facts are not generated - at least the visit(ImportDeclaration node) method of the ca.ubc.jquery.engine.tyruba.java.FactsGenerator class doesn't seem to create any facts at all.
If it isn't supported, is it planned to "implement" the imports predicate?
If not, is there an easy way to retrieve all elements that a compilation unit (or class, interface, package,...) depends on?
Best regards,
Sebastian.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe we did have an implementation for the visit(ImportDeclaration node) method but stopped using it because we weren't querying that information. We do not have any plans to add it back in at the moment so you are welcome to add it back.
As for retrieving all elements that a compilation unit depends on: this too may be a little tricky at the moment. You can write a query to gather information about a compilation unit by finding out the method return types or any instanceof tests, etc. This would get close to an accurate picture. The problem is again, the JQuery factbase does not store information about local variable declarations so if you use a particular type only as a local variable in a method, you would not be able to detect this dependency.
You are welcome to change the AST visitor to generate the facts that you need. We have built this factbase based on our needs and unfortunately it does not represent a Java program in entirety. Another solution would be to install the JTransformer plugin as a backend for JQuery because it has a complete representation of the Java program.
Hope this helps.
Lloyd
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would also like to say that as a result of your comments (and others as well) the next version of JQuery (hopefully available next week) will include an extension point for extending the JQuery Java AST visitor. This will allow you to easily insert your own import facts if you so desire. We will also include a small tutorial on the wiki to demonstrate how this can be done.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The tutorial would be an example of how to extend the Java visitor. I see a simple extension as adding facts for local variables or adding facts for import declarations. This should give a good feel for how the factbase is built and how it can be extended.
I suppose we'll also have to cover some basics about Extension points.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there,
I use JQuery to detect undesirable dependencies between Java classes. Is it correct that there is no possibility to access the import declaration statements in Java files? I've found an imports(?cu,?el) predicate in the core predicate file but it seems that the corresponding facts are not generated - at least the visit(ImportDeclaration node) method of the ca.ubc.jquery.engine.tyruba.java.FactsGenerator class doesn't seem to create any facts at all.
If it isn't supported, is it planned to "implement" the imports predicate?
If not, is there an easy way to retrieve all elements that a compilation unit (or class, interface, package,...) depends on?
Best regards,
Sebastian.
I believe we did have an implementation for the visit(ImportDeclaration node) method but stopped using it because we weren't querying that information. We do not have any plans to add it back in at the moment so you are welcome to add it back.
As for retrieving all elements that a compilation unit depends on: this too may be a little tricky at the moment. You can write a query to gather information about a compilation unit by finding out the method return types or any instanceof tests, etc. This would get close to an accurate picture. The problem is again, the JQuery factbase does not store information about local variable declarations so if you use a particular type only as a local variable in a method, you would not be able to detect this dependency.
You are welcome to change the AST visitor to generate the facts that you need. We have built this factbase based on our needs and unfortunately it does not represent a Java program in entirety. Another solution would be to install the JTransformer plugin as a backend for JQuery because it has a complete representation of the Java program.
Hope this helps.
Lloyd
Thanks for your reply. I've changed the AST visitor and it seems to work fine.
fine. i like the tool very much. it does cut down some of my daily work from hours to quarters of hours. i look forward to the next version.
I would also like to say that as a result of your comments (and others as well) the next version of JQuery (hopefully available next week) will include an extension point for extending the JQuery Java AST visitor. This will allow you to easily insert your own import facts if you so desire. We will also include a small tutorial on the wiki to demonstrate how this can be done.
This sounds great. A tutorial would be great, since I don't know HOW quick and dirty my solution is ;-)
what kind of tutorial do you have in mind ?
The tutorial would be an example of how to extend the Java visitor. I see a simple extension as adding facts for local variables or adding facts for import declarations. This should give a good feel for how the factbase is built and how it can be extended.
I suppose we'll also have to cover some basics about Extension points.