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.
//////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
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.
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.