Eclipse 取得项目所有信息

public void getProjects(String nanme) throws JavaModelException{
		IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();		
		IJavaModel jModel= JavaCore.create(root);
		IJavaProject project=jModel.getJavaProject(nanme);
		IProject resourceProject= project.getProject();
		resourceProject.getName();
		
		IPackageFragmentRoot[] PackageFragmentRoots= project.getAllPackageFragmentRoots();
		for(int i=0;i<PackageFragmentRoots.length;i++){
			IPackageFragmentRoot PackageFragmentRoot =PackageFragmentRoots[i];
			PackageFragmentRoot.getElementName();
			IJavaElement[] packageFragments=PackageFragmentRoot.getChildren();
			List  packagefragmentlist=new ArrayList();
			for(int j=0;j<packageFragments.length;j++){
				IPackageFragment PackageFragment=(IPackageFragment) packageFragments[j];
				ICompilationUnit[] CompilationUnits=PackageFragment.getCompilationUnits();
				packagefragmentlist.add(PackageFragment);
				List  compilationunitslist=new ArrayList();
				for(int k=0;k<CompilationUnits.length;k++){
					ICompilationUnit CompilationUnit=CompilationUnits[k];
					CompilationUnit.getElementName();
					compilationunitslist.add(CompilationUnit);
				}
			}
			
		}
	}

 

你可能感兴趣的:(eclipse,插件,jdt)