Eclipse Plugin Development: Code Review - eclipse

I'm trying to write a plugin for Eclipse which should analyse all java files in the open project.
Is it possible to add my code to the code parser of Eclipse itself?
Currently, I'm able to load the workspace and iterating over all java files but any changes after the first iteration are missed.

You can use the org.eclipse.jdt.core.compilationParticipant extension point to define a class extending org.eclipse.jdt.core.compiler.CompilationParticipant which will be called at various points during the compilation of a project.
You can also use an IResourceChangeListener to listen for changes to individual resources:
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);

Related

is there any demo for eclipse cdt api use?

I want to use the eclipse cdt api to resolve c++ code AST tree for code analysis.
base on the blow question answer, I try to create a default Workspace and project by java code. The Workspace init method require many IDE source support, when i fix one resouce issue, another comes. is there any demo for this?
Using CDT without Eclipse
If you want to parser a single source file, it is enough to use cdt.core only. If you want to use the higher level(semantic) you need to replace a lot dependences about those IDE packages. I did a project using Eclipse-JDT and use JavaCore and Workspace to generate IJavaProject. It is similar with CDT. I also do some research about static-code-analysis using JDT/CDT.

Using CDT without Eclipse

I want to use CDT parser in a project. The project would be a command-line, stand-alone project, i.e., not an Eclipse plugin.
All solutions that I've seen requires using a IWorkspace. But, I want to use the CDT parser on single files outside eclipse. Is there any way to do that?
It depends what you mean by "without Eclipse".
CDT's code is built on top of the Eclipse Platform, so you're going to need to be running an application that includes the Eclipse Platform. However, there's no reason that application can't be a command-line application. These are called "headless" applications in the Eclipse community, and you can find many tutorials for making one (here's one).
Requiring an IWorkspace shouldn't be a problem. You can e.g. create a workspace and a project in a temporary folder, and copy the code to be analyzed there.
If, for some reason, you really want to use just CDT's parser in an application that doesn't include the Eclipse Platform, you can probably copy the parser code from CDT, and replace any dependencies it has on the Eclipse Platform with your own implementations. However, this is likely to be a more labour-intensive approach, and I wouldn't recommend it.

Attempting to modify typesafe activator UI. How do I import/modify the activator jar files in eclipse scala IDE?

I am new to the scala eclipse environment and also new to typesafe/activator.
I need to modify some of the activator initialization code because of some very specific host-side dependencies.
I cannot see how to "import" the actual jar files into eclipse. I know exactly what I need to change and how (via manually opening the jar and looking at the code). But I want to maintain complete integrity with the change management (ivy and sbt) but I do understand how to do this.
Is there some basic way to pull in/open a source jar, modify it, and build/deploy it? I see lots of help on the export/build, but I need help with the open/import/modify portion of this task.
Thanks for your kind help.
Typically if you wanted to change how a project works you'd go back to the source repository (in Activator's case https://github.com/typesafehub/activator ) and modify from there and then rebuild. Source jars don't have the build configuration so they are not useful for creating new binaries. Usually source jars are used to show source in a debugger or to click on a type in the IDE and see the source code for that type.

How to create a Processing Language plugin for Eclipse?

I'm quite a noob programmer and I recently discovered Java Processing Language which can be run on Android.
So far I've been using a dedicated IDE to program it in but I've just found out I can program it in Eclipse which is my preferred IDE. The only problem is that they only tell you which libraries to import when creating a Processing project from a standard Java project. So every time I want to create a new project I have to create a Java project, go through all the import menus, search for the Processing system library, import the files, create a new class and import the library for the class.
Does anyone know how to create an eclipse plugin so I can just go to the NEW directory in eclipse and have a PROCESSING folder and a NEW PROCESSING PROJECT item that already has a generic class with the imported libraries?
I've been looking at online tutorials and I can't even figure out where to start.
The steps to create a Processing project from a Java one are explained here.
Thanks for any help!
I recommend having a look at the Proclipsing plugin which seems to do pretty much what you want to achieve. It's also open source so you can see how it was written and modify if you like.
A Processing project is a standard Java project with the Processing libraries added to build path. There is nothing more to Processing in this regard. So a specific Eclipse Processing plugin for this seems overkill (there are some other things like the different targets or samples that could make it useful though).
To easen up your current process: Create an Eclipse User Library for the Processing libraries. Menu Window > Preferences, Java > Build Path > User Libraries, New.... Add the Processing libraries. Now you can easily add the whole set to a project (right-click on the newly created Java project in the package explorer, Build Path > Add libraries > User Library).
If you want to change the standard template for Java classes to one including everything for Processing: Window > Preferences, Java > Code Style > Code Templates, Code > New Java files. This changes every newly created class, maybe it is better to just create a simple template to manually call at start: Java > Editor > Templates, New.... Then you would call the template every time you create a Processing main class but not for "normal" classes.
Ok... regarding the target audience of Processing a plugin may be a good idea. But then there is the dedicated Processing UI. Eclipse is not exactly a good introductory IDE.

How do I run an arbitrary java file with Eclipse?

I need to run some example java code. I like using eclipse because it shows the methods, properties, constructors and so on. The problem I'd like to solve is that unless I create a new project I can't compile and run the example code I'm using! Is there a way around this?
No, there is no way around this. A Java file is very rarely a self-contained program with no dependencies at all. Most of the time, a program is composed of many collaborating classes depending on external libraries.
If you just want to test a self-contained Java program consisting of just one java file, then create a "playground" eclipse project, drop this file inside this project, and run it. Use the same playground project for all the other self-contained java programs if you want: you may have several main classes inside a single eclipse project.