Own eclipse plugin - sharing data between plugins - java

I would like to write small eclipse plugin for code estimation. At start I would like to use results shown in "problems" tab (warnings and errors) instead of writing next, own tool for code analysis. The question is:
Is it possible to use data from one plugin in another?
I would be greatful for any examples or links to tutorials.
Thank you in advance :)

The objects in the Problems view are called 'markers' and are represented by the org.eclipse.core.resources.IMarker interface.
You get the markers defined on a file, folder or project by calling the findMarkers method on the IResource. You can ask for all types of marker or just specific types.

Related

Eclipse IDE - source code for 'Outline' feature

i`m actually working for a tool, which counts the methods in a class and the number of the if statements. the purpose is to estimate the quantity of test cases to write.
I've noticed that the Eclipse outline box has some interesting information and it would be really nice to get the code which produces the outline information.
I`ve already browsed through the Eclipse Git site, but I am a beginner and there are so many packages, can anybody tell me where I can find the source code for the Outline view, or point me in a good direction?
Best regards.
Download Eclipse Classic which contains the source code for Eclipse. It also allows you to sniff which packages are being used by Eclipse using the plugin-spy. You can then import the specific package and set debug points within it to view the source being executed when a specific event occurs.
The following article provides a good tutorial on the steps mentioned above:
Eclipse Source Code Tutorial
See this article about how to access the Java model from your plugin. IJavaProject is the relevant API.

Eclipse-based Custom Content Assistance? (Java)

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.

Is there a better way to view un-attached source class decleration in Eclipse?

When looking at a class declaration that has no attached, why is it not in plain text allowing it to at least be searchable. Is there a way to view this output in a search format?
Please let me know of a plugin. Thx
If I understand what you are asking here, if you are referring to a class file, then no. You would need to import the source code as a plugin. As an example, take a look at this tutorial
The "Outline" View will display the structure of the class, even if no source is attached, so you can at least see all the class' members, including parameters and return types. The View also has some sorting and filtering abilities, so it might help to find the info you're looking for.
Another option would be to plugin a decompiler, which should open up class files as source files "on the fly". I don't use any personally, but just Google "eclipse decompiler" and see which one you like.

Automated way to find number of usages?

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.

Structural comparison of two ASTs in Eclipse

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.

Categories