|
Re: How to get fully qualified names of classes in a project [message #330737 is a reply to message #330734] |
Tue, 12 August 2008 13:48 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: lifesting.gmail.com
kaprasanna wrote:
> Hi,
>
> I am sure there must be a way to achieve this.
> Let's say there is a package
> abc.pack.myFirst
> And there are two classes (java files) in this package : FirstClass.java
> SecondClass.java
> I want the list which should include two entries :
> abc.pack.myFirst.FirstClass,
> abc.pack.myFirst.SecondClass
>
> How do I achieve this?
>
> Thanks.
>
Yes, you can use JDT to visit Java resources such Package,
Class(CompilationUnit), Src Folder(PackageFragmentRoot) etc...
for example, define a WorbenchWindow action:
IPackageFragment pkg = null;
public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof IStructuredSelection)
{
Object select = ((IStructuredSelection)selection).getFirstElement();
if (select instanceof IPackageFragment)
pkg = (IPackageFragment) select;
else if (select instanceof IAdaptable)
pkg = (IPackageFragment)
((IAdaptable)select).getAdapter(IPackageFragment.class);
else ....
.....
......
}
public void run(IAction action) {
for(IJavaElement cls_or_pkg : pkg.getChildren())
{
if (cls_or_pkg instanceof ICompilationUnit)
fullNames.add(pkg.getElementName()+((ICompilationUnit)cls_or _pkg).getElementName());
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04780 seconds