Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » getting methods from IFILE
getting methods from IFILE [message #523671] Sun, 28 March 2010 10:18 Go to next message
Eclipse UserFriend
I have written this code and get the java file of the project, but now i want to get the methods in the file. i am unable to get how to do this.Urgent help required.

IProject project;
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
System.out.println("workspace length"+workspaceRoot.getProjects().length);

project = workspaceRoot.getProject("MoreUnit1");
IJavaProject javaProject = JavaCore.create(project);

IFile file=project.getFolder("src").getFolder("test").getFile( "Atest.java");

//////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
Now i want to get methods in the file and the type of methods should be IMethod.and also i want to convert the IFile to Compilationunit.
CompilationUnit fileComp=(CompilationUnit )project.getFolder("src").getFolder("test").getFile("Atest.java ");
when i do this it does not give me error at compile time but at run time it does not cast IFile to compilationUnit.

Any help to resolve both issues..
Re: getting methods from IFILE [message #523736 is a reply to message #523671] Mon, 29 March 2010 01:56 Go to previous message
Eclipse UserFriend
lehmia wrote:
> I have written this code and get the java file of the project, but now i
> want to get the methods in the file. i am unable to get how to do
> this.Urgent help required.
>
> IProject project;
> IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
> System.out.println("workspace length"+workspaceRoot.getProjects().length);
>
> project = workspaceRoot.getProject("MoreUnit1");
> IJavaProject javaProject = JavaCore.create(project);
>
> IFile file=project.getFolder("src").getFolder("test").getFile(
> "Atest.java");
>
> ////////////////////////////////////////////////////////////
> /////////////////////////////////////////////////////////
> Now i want to get methods in the file and the type of methods should be
> IMethod.and also i want to convert the IFile to Compilationunit.
> CompilationUnit fileComp=(CompilationUnit
> )project.getFolder("src").getFolder("test").getFile("Atest.java ");
> when i do this it does not give me error at compile time but at run time
> it does not cast IFile to compilationUnit.
>
> Any help to resolve both issues..

Please don't post the same question to multiple newsgroups; it wastes people's
time. I'll try to answer your post on eclipse.newcomer.
Previous Topic:Adding resource files in jar file, plus a export option questions
Next Topic:Source folder for test directory?
Goto Forum:
  


Current Time: Sat Mar 22 12:38:38 EDT 2025

Powered by FUDForum. Page generated in 0.02903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top