Getting call hierarchy is easy in IntelliJ. Simply use the built in tool. But is there a way to do it using code? Eclipse internal JDT has two classes called CallHierarchy and MethodWrapper that help to do so: link
If there is no equivalent in IntelliJ, is there another pre-built way I can find all callers of a specific method (and base methods)? (Can we programmatically invoke Find Usages?)
In short, for a specific method, I'd like to get all other methods and classes that use the base method in a Collection<> of some sort.
Thanks in advance for any responses or ideas.
Yes, it's possible. After research and a bunch of asking around, the IntelliJ developers pointed me at the IntelliJ Platform SDK... Didn't know this existed. This link in particular points out how to use Find Usages in the SDK. Hope this helps someone in the future.
Related
I'd like to try using WebTest, preferably from Clojure, but I can only find its functionality exposed as Ant tasks. There seems to be some sort of Groovy interface, which implies that it's possible to use from any JVM language outside of Ant, but I can't figure it out.
I'm hoping to use WebTest as a "scriptable browser" to load up someone else's page and see if it does various unpleasant things, rather than test my own page with every build, so Ant doesn't really seem like an appropriate solution if I can avoid it.
It is often the case that useful Java functionality is hidden behind Ant tasks. I hit the issue when writing the book (pre-leiningen et al), and wrote lancet to let you call Ant tasks as clojure functions.
Lancet would probably need to be extended to handle arbitrary Ant tasks, but since it is now being maintained (as a dependency of leiningen) you might find other people willing to help out.
I am late into the game.
What about directly using the underlying httpunit java library straight from clojure ?
Is there a method of knowing the depending library in the java library?
If possible, I want to know the method to know by the tool or the command.
My method usually consists of googling the class and method and downloading the appropriate jar. :) Sometimes it takes some research.
Check classycle and JDepend, they both do dependency checks and can be used to automate process using ant.
JBoss TattleTale may help you, it's very easy to use.
"Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on."
I'd suggest letting Maven handle your dependencies (NetBeans has good inbuilt support, for example). Once you're using it, it's easy to view the dependency tree.
I have done some Java programs on my own but now I found an interesting Java project to work. I chose one item from todo list and now I would like to implement it and find a suitable place in the original code for it. What are some good strategies to find the correct place? I'm using Eclipse Helios and its debugger.
This is where coding convention and technical documentation would help you. If the java programs you are talking about is written correctly with the correct conventions and everything, you should be able to figure out where your code should reside.
Best way would be to run through the part where the TODO is needed. If the todo is specific to current class, it would be ideal to just put it in the same file. Of course, TODO usually (but not all the time) means that it might be an enhancement to the current code. If that's the case, then creating a new method for it would be good.
if on the other hand, you think your code would be useful for the entire project, a utility method would be the perfect place to store your code.
If it's something you can make a local copy of, try getting it all to work IE do a couple of test runs, and then try deleting some files that look unimportant. It may sound silly but it'll show you straight away whether or not something is a core part of the code.
Once you get down to class level, read the whole thing. Eventually you'll get to know a few core classes really well and gain a basic understanding of what all the others do.
If you are completely new to a project, but that project has other developers I suggest you ask someone more familiar with the code base. If you are on your own you would have to see if there are any functions that are similar to what you want to do. You could then try and put your own code in the same place (package/class/whatever is appropriate) and job done!
Good luck!
Start working on a private branch (you do use some version control software, right?) and make sure you understand how to validate the project (you do use automated tests, right?). After that, just start experimenting!
If this is an open source project then it most likely have some means of contacting the developers for the project. A mailing list is usually available, where you can ask these questions to those who know the code well.
Remember to choose an active project...
There are few open source projects/APIs/libraries that we use in our project (Spring, Struts, iBatis etc.) and I want to understand their design and how they work internally.
What is the best way to understand these projects? Note that I am already using these libraries in my project. And I know the input-output interaction/configurations for these libraries. What I don't understand is how these APIs/libraries work internally.
The problems I face is:
Finding the entry class of the library. Is there any way I can know the entry class for the library - something which is kicking the whole API?
Tools/Plugins to use in Eclipse to get an overview of the design of the library. Going through each and every class of the library, can be a very daunting task. Is there any tool you would like to recommend which can generate the class diagrams of the API in Eclipse.
Thanks in advance!!
UPDATE: I need some inputs on eclipse plugins which can help me in getting an overview/class diagram of the library
I always use the same strategy for this: I never try to "understand" the code base as a whole, and I usually try to follow the request flow. I read enough of the documentation to determine what is necessary to use the application, and I read that code (Keep all source code loaded in your IDE).
For example, in struts you'll be installing a servlet filter in web.xml. Start reading the filter and follow the path a single request takes through your stack.
Likewise for spring, there are two main entry points, the filter and "getBean", both of which are mentioned real early in the documentation. Read those two.
For both of these cases you'll find one or two classes that represent the "core" of the framework real quickly. Read those really well and let actual use cases & needs drive your further exploration.
Approaching "understanding" of an open source library (or any other code base for that matter) by trying to find all the pieces is usually not a very good way of approaching these things, it will usually just lead nowhere because a lot of these things contain too much code. When following the request flow I find making diagrams can also be quite distracting, it tends to draw attention/focus away from understanding (and since my understanding increases rapidly most of them are out-of-date even before they reach the printer).
Nice question!!!, what I've done, specially in the case of Spring, apart from consulting the Documentation and their API's is to attach the sources of the project to my project on Eclipse, that way I'm able to navigate through the source code, not just the API. Its been quite helpful specially in the case of the Spring-Security project, there were some concepts that I just couldn't understand until I inspected the source code.
That's one of the advantages of using Open Source libraries.
Regards.
Tools like Structure101 (http://www.headwaysoftware.com/products/structure101/index.php), and Lattix (http://www.lattix.com/) let you analyze code and produce architecture diagrams / dependency matrices.
This is not exactly class diagram - the main focus is on layering. So the entry point is usually the topmost layer.
But then again, as I specified above, you will notice that some libs are just a mess, and these tools will not be helpful enough.
See the S101 online demo: http://www.structure101.com/java/
This for example is the Sonar project architecture: http://www.structure101.com/java/tracker/sonar/1.11.1/arch.html
Your best bet for those three would be to consult the official documentation (make sure you are looking at the version you are using) or to get a book on the technology.
Most APIs don't have a class with a main method; they're running in the webserver called by the server itself. Unless they're running as their own server, they won't have a main method.
It is possible to access bits of MATLAB's internal java code to programmatically change MATLAB itself. For example, you can programmatically open a document in the editor using
editorServices = com.mathworks.mlservices.MLEditorServices;
editorServices.newDocument() %older versions of MATLAB seem to use new()
You can see the method signatures (but not what they do) using methodsview.
methodsview(com.mathworks.mlservices.MLEditorServices)
I have a few related questions about using these Java methods.
Firstly, is there any documentation on these things (either from the Mathworks or otherwise)?
Secondly, how do you find out what methods are available? The ones I've come across appear to be contained in JAR files in matlabroot\java\jar, but I'm not sure what the best way to inspect a JAR file is.
Thirdly, are there functions for inspecting the classes, other than methodsview?
Finally, are there any really useful methods that anyone has found?
There is no official documentation nor support for these classes. Moreover, these classes and internal methods represent internal implementation that may change without notice in any future Matlab release. This said, you can use my uiinspect and checkClass utilities to investigate the internal methods, properties and static fields. These utilities use Java reflection to do their job, something which is also done by the built-in methodsview function (I believe my utilities are far more powerful, though). In this respect, I believe we are not crossing the line of reverse-engineering which may violate Matlab's license.
If you are looking for documentation, then my UndocumentedMatlab.com website has plenty of relevant resources, and more is added on a regular basis so keep tuned.
I am also working on a book that will present a very detailed overview of all these internal classes, among other undocumented stuff - I hope to have publication news later this year.
I am an eclipse fan. If you use that as your IDE, the jar can be imported into one of your projects and you can inspect the methods in there.
To find out more about java objects, I use uiinspect.
The only place I know that is documenting the Matlab hidden Java stuff is Undocumented Matlab by Yair Altman. His site lists plenty of very useful tricks. Being able to use Java to format text in list boxes has come in very handy for me, for example.
EDIT
The man has spoken. Listen to him, since I don't think there's anyone outside MathWorks who knows more about Matlab's internal java code.
Undocumented Matlab is a great place to start looking.