Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to org.eclipse.core.resources.IResource -> org.eclipse.jdt.core.ICompilationUnit
How to org.eclipse.core.resources.IResource -> org.eclipse.jdt.core.ICompilationUnit [message #841946] Wed, 11 April 2012 17:59 Go to next message
Davide M is currently offline Davide M
Messages: 17
Registered: April 2012
Junior Member
Hi,

In a IncrementalProjectBuilder I like to find the compilation unit of iresources notified by the builder (if the iresource is a java source class).

What is the best way to match this objects?

Thanks in advance!

[Updated on: Wed, 11 April 2012 18:18]

Report message to a moderator

Re: How to org.eclipse.core.resources.IResource -> org.eclipse.jdt.core.ICompilationUnit [message #842718 is a reply to message #841946] Thu, 12 April 2012 11:08 Go to previous messageGo to next message
Michael Rennie is currently offline Michael Rennie
Messages: 65
Registered: July 2009
Location: Canada
Member
Once you determine that the IResource is indeed a source file you could simply call org.eclipse.jdt.core.JavaCore.createCompilationUnitFrom(IFile).

A more complete snippet could look like:


if(resource.getType() == IResource.FILE &&
JavaCore.isJavaLikeFileName(resource.getName())) {
ICompilationUnit unit = JavaCore.createCompilationUnitFrom((IFile) resource);

}
Re: How to org.eclipse.core.resources.IResource -> org.eclipse.jdt.core.ICompilationUnit [message #842723 is a reply to message #841946] Thu, 12 April 2012 11:11 Go to previous message
Satyam Kandula is currently offline Satyam Kandula
Messages: 444
Registered: July 2009
Senior Member
Look at JavaCore#Create(IResource) and JavaCore#createCompilationUnitFrom()
Previous Topic:Debugging Bash with a jar
Next Topic:Reuse Java components (parser, auto completion, ...) for composite language
Goto Forum:
  


Current Time: Tue Jul 29 21:01:52 EDT 2014

Powered by FUDForum. Page generated in 0.03109 seconds