Home
.. Links
.. Search
.. Plugins
.. Help
.. Irc Faq

Projects
.. Platform/Faq
.. JDT/Faq/Plan
.. PDE/Faq
.. SWT/Faq
.. RCP/Faq

Tools Projects
.. CDT/Faq
.. GEF/Faq
.. EMF/Faq

Wiki Tutorials

Hosted Projects
.. MTJ
.. Google Summer Of Code 2007
.. Update Manager 2.0
.. EasyEclipse
.. Stylebase for Eclipse

Archives

DeveloppingPluginsWithJDT


How to get the java projects?

IJavaProject javaProject = (IJavaProject) .
org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getProjects()
once it is obtained youcan filter on the projects which have a java nature



How to invoke a wizard (and pass some parameters to it) after the completion of another wizard ?

If so, the last page of you first first simply needs to return the first
page of the second wizard when asked (getNextPage()). Note, you'll need
to create an instance of the second wizard and call addPages() on it
once (and only once).
Simon

I have an IFile in hand (for a .java file). How do I get access to some java information (types declared in that file etc.)?

Use org.eclipse.jdt.core.JavaCore::create(IFile). This will give you an ICompilationUnit.

How to search programatically for references to a given class/method etc. ?

Use class SearchEngine from org.eclipse.jdt.core plugin.

How to programatically format a fragment of code?

Use the ToolFactory class from org.eclipse.jdt.core plugin to get ICodeFormatter.

How to create an Abstract Syntax Tree for a given ICompilationUnit?

Use the ASTParser class from the org.eclipse.jdt.core plugin (AST class for parsing CompilationUnits is deprecated).


How to scan code for method comments?

Use ISourceReference::getSourceRange to get the method code range and then
use IScanner to find the exact offsets for the beginning and start of the comments.

How do I instantiate a class from the runtime workspace?

You shouldn't. It would be very dangerous if you did this, since the class would run code in the same VM that Eclipse is running in. Imagine what would happen if it has a static initializer that does a System.exit(0)!

Usually people want to do this so that they can use reflection to find out information about the class. The org.eclipse.jdt.core package already provides a rich set of APIs to do this without loading the class, or running any untrusted code in the IDE. See How do I get access to some java information to get you started.


How do I programmatically, create a class, set it's superclass, add a constructor and a method, then "Organize Imports", format the source, and write out the resulting .java file?

Last Modified 6/21/06 10:31 AM

Hide Tools