jdt

How can I use the JDT in eclipse to import classes?

I want to do the following imports in a class import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compil...

When writing Eclipse JDT plugins, is there a way to track appearace of certain strings in code?

I'm writing an Eclipse plugin for the JDT. I need a functionality that tracks certain strings or regular expressions and possibly creates markers. I know that Eclipse already does that for //TODO comments, for example (creating task markers for them) but I'm not sure if I can use the same mechanism. I can write my own but worried it wo...

When writing Eclipse plugins, what is the correct way for checking if an IEditorPart is a Java editor?

I am writing Eclipse plugins for Java, and have the following problem: Given an IEditorPart, I need to check if it is a java editor. I could do (IEditor instanceof JavaEditor), but JavaEditor is an org.eclipse.jdt.internal.ui.javaeditor.JavaEditor, which falls under the JDT's "internal" classes. Is there a smarter and safer way to do ...

In the Eclipse JDT, how do I most efficiently find a typeroot in the workspace corresponding to a fully qualified name?

The JavaCore class includes a create method that allows me to get the ITypeRoot (representation of class file or compilation unit) given a handle identifier that embodies the location of the file. However, I am trying to find the typeroot (if there is one) that corresponds to a specific fullname. The only implementation that I can thin...

Java refactoring tools

Hi, I make very heavy use of the Java code refactoring tools provided by Eclipse (extract interface, rename method, etc.). Does anyone knows of other similar tools (preferably Eclipse plugins) that can perform Java code refactorings that are not available in Eclipse by default, or that can perform the same refactorings better? I'm awar...

Eclipse 3.3 Europa JDT TextHover

I want to show my own text hover in eclipse for some specific words? Please provide me some examples ...

Write Java Method Signature with Annotated paramaters with JDT

Hi, I am writing an eclipse plug-in which generates code. I am leveraging eclipse jdt to gen out classes, fields, and methods. One of the requirements I have is to generate methods with annotated paramaters... public returnType foo(@someAnnotation int id) { ..... ..... } Does anybody know how to write out the @someAnnotat...

Can i get the project build path programicaly?

I want to a project build path (default is src...). Can I do it using some java API? ...

Plugin: how to get all the types available in my eclipse Workspace?

Hi, I'm writing an eclipse plugin, and I want to get all the types that are available in my workspace, like when pressing Ctrl+Shift+T, but in a list or array. How can I do it? ...

Running an Eclipse Plugin

How do I run the plugin project under Resources [1] here: http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation%5FAST/index.html If I am not wrong, the project starting point is here public class ASTArticleActionDelegate implements IObjectActionDelegate -> public void run(IAction action) public void run(IAction ...

How can I add build path items to Eclipse 3.5 using relative paths?

Eclipse 3.5 added support for relative buildpath/classpath items, yet I cannot seem to find a graphical way to add relatively pathed items. The example in new and noteworthy (search the page for 'relative', about 40% of the way down) seems to indication I have to manually edit the .classpath file. Am I just missing something? ...

Eclipse "Open Type" dialog restricted to a particular interface

I'm trying to create a JavaUI.createTypeDialog() which restricts the user to selecting only types belonging to a particular interface. How could I do this? ...

Eclipse plugin: NoClassDefFoundError on org/eclipse/jdt/ui/JavaUI

I am creating a plugin which requires jdt.ui.JavaUI class. I included the jdt.ui plugin into the dependencies. This is my Manifest.MF: Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: PanelGenerator Plug-in Bundle-SymbolicName: PanelGeneratorPlugin; singleton:=true Bundle-Version: 0.1.0 Bundle-Activator: panelgenerator.plugi...

Eclipse JDT ASTVisitor - how to tell if a field is read or written in a method?

I am writing a Eclipse ASTVisitor. How to tell if a field is read or written in a method? The idea provided was "You need to vist Assignment node. Field on the LHS is written, while fields on the RHS expression is read." After I visit the assignment and get the LHS and RHS which are both of Expression, how do I tell if the Expression c...

Using class as a field name in JDT dom

Hello, I'm trying to add a call to the StaticClassName.class field access to an existing class using JDT's Dom methods. I get an IllegalArgumentException when I try to create a simple name using ast.newSimpleName("class"). I think this is because JDT treats it as a keyword when it is also used as a field name. Is there anyway to make ...

How to detect eclipse compile errors (Java - JDT)

Hi everybody, I need to detect compile errors in the java source code after a POST_CHANGE event (usually it is fired after saving changes in the java file). I'm using IElementChangedListener for doing that. So, for detecting errors I tried the two possibilities bellow: 1: boolean error = IMarker.SEVERITY_ERROR == iFile.findMaxProblemS...

Use JDT to get full method name

I am new to eclipse plugin development and I am trying to convert a IMethod to a string representation of the full method name. I.E. my.full.package.ClassName.methodName(int param, String string) so far I have had to hand roll my own solution. Is there a better way? private static String getMethodFullName(IMethod iMethod) { String p...

How to undo TextEdit in eclipse JDT in a single step

I implemented an eclipse quick fix to change a block of code. I'm using something like this to save my changes: TextEdit edits = rewrite.rewriteAST(); UndoEdit undo = edits.apply(document); But when i undo my changes (CTRL+Z), i have to step through all the TextEdit actions one by one. Is there a way to group them so the quick fix ...

Install eclipse JDT on top of CDT

I have the eclipse CDT installed, and I would like to install Java development functionality (JDT) on top of my CDT installation. I've been Googling from an hour but I can't figure out how to do this. Any ideas? What plugin do I need to install? What update site do I need to use? Thanks. ...

How do i find the project of the contents of an ITextViewer?

I'm trying to implement a HyperlinkDetector for an Eclipse plug-in and the callback method is giving me an ITextViewer to work with. How do i get the project, IPath or IFile of the viewer's IDocument? Apparently the concept of an IDocument is to only allow access to the content regardless of the source. All i can come up with is to chec...