I'm trying to implement a plug-in for Eclipse (using Java) for C programmers, in which the user could right click on any variable in his/her C code and I would give him all sorts of information on that variable (like usages or which function is it passed to ... etc.).
Do you know how can I achieve this? If so - can I get the C syntax tree ?
Are there any open source project I could use as a reference ?
Not a direct answer to your question, but have you heard of the program Doxygen (also has an eclipse plugin? Take a look and see if it meets your needs. Sometimes it is easier to use pre-existing plugins rather than creating your own.
Related
I am trying to build a project in Eclipse (Neon.2 Release (4.6.2)) and am trying to use Java and C. I'm not asking how to code in either language, but I'm not sure how to call a C main function passing it a param from a Java class or function. I know projects are made from multiple languages but I'm not sure how it's done and I haven't found a very solid answer from Google.
Thanks in advance.
Eclipse allows to get all references to a function. I'd like to go further and know if anyone knows of a tool or script that would do this recursively ie from a function it would produce the list of different possible function stacks to access to it.
I am looking for this to make sure all the impacts of a change are captured in the spaghetti old legacy code I am looking at the moment. Thanks.
Try eclipse's Call Hierarchy.
It's CTRL-ALT-H on Windows, CTRL-OPTION-H on OS X.
(Hotkeys for eclipse 3.x, I have yet to use eclipse 4)
Its called the Call Hierarchy and you can open it with Ctrl+Alt+H
http://www.javaprogrammingforums.com/java-jdk-ide-tutorials/19-list-shortcuts-key-eclipse.html
Is it possible to edit the content assistance of Eclipse? Sort of add rules or functions for it? I'm aware that Eclipse is open-sourced, but I was there an "easier way" or an interface?
For example, I'm working in Java 1.4.2, so I don't believe I have the magical "autoboxing"(am I correct in thinking that autoboxing would solve this issue?) . So when I'm working with getting parameters from a request, they all return strings when I may need a Long or an Int. I'm always interested in making things more automated (as any computer scientist usually would), so I was wondering if it was possible to have content assist suggest to use the common java parse functions (Integer.parseInt, Long.parseLong, etc) for the passed in parameters.
If you want to actually augment Content Assist in a highly detailed, customized way, you'd have to write a plugin. Eclipse is very well architected such that there are endless extension points via which plugins can extend base functionality, including Content Assist. But, writing one is not a trivial matter (though a skill that could serve you well, if you have the time to learn it).
Another option is to write your own Java editor template, which can emit any pre-defined snippet of code you want (including inserting parameter values), and will be included in Content Assist. Open Eclipse's Preferences and navigate to Java > Editor > Templates. You can use the ? help button on that Preferences page to learn more about them.
Are there any open source tools that automate the functionality of finding the number of usages of a Java API? I can figure out this information for one class at a time in my IDE. I want to use this information to create a rudimentary report on the speed of adoption of a particular library. I would create a daily report on the number of usages of dozens of classes, and I would report on several code bases.
I'd go with one of those tools for analyzing dependencies in Java code. Let it work on your source tree, a package or a single class and see if you can export the results to XML or something like that. I've used Dependency Finder in a project about two years ago and I think it should do what you want. Not sure about the export to XML, though.
In Eclipse you can right click on a method name or class and go to the References menu and from there you can choose the scope of where you want to search for classes that reference that item.
Is that what you need?
I'm going to try Macker. Its style is to report references to configured classes as errors, but that's fine. It can be run from an automated build. Thanks Robert.
I am working on an incremental builder for Java code in Eclipse. Eclipse provides a ResourceDelta that tells me which resources have changed since the last build. However, I would like to have more detailed information, e.g. what methods or what field definitions changed. There seems to be functionality similar to what I want in the "compare with -> each other" view. However, this code is quite disconnected from the build engine and seems incompatible with ResourceDeltas. What would be a good way to figure out what I want? The best solution I can see is to compare two ASTs, but I also could not find any built-in support for that.
JavaCore does supply this information via the IElementChangedListener and IJavaElementDelta interfaces. Here's a quick code sample to get you started:
JavaCore.addElementChangedListener(new MyJavaElementChangeReporter(), ElementChangedEvent.POST_RECONCILE);
More details available in Manipulating Java code from the JDT Plug-in Developer Guide.