Re: setting package on new Java objects
Tomas Zezula <[email protected]> Tue, 19 Aug 2003 15:05:16 +0200
| Newsgroups | gmane.comp.java.netbeans.modules.projects.devel |
|---|---|
| Organization | Sun Microsystems |
| Message-ID | <[email protected]> |
Hi Cliff,
I tried to reproduce it, but it worked fine:
Here is the code I used for test:
Repository rp = Repository.getDefault ();
FileObject fo =
rp.findResource("/tmp/Projects/SETest/src/test/SETest.java");
if (fo == null)
throw new RuntimeException ("No such FO");
ProjectMember[] pm = ProjectMember.findAll (fo);
if (pm.length != 1)
throw new RuntimeException ("No PM");
SourceCookie sc = (SourceCookie) pm[0].getLookup().lookup
(SourceCookie.class);
SourceElement se = sc.getSource ();
Identifier pkgIdent = se.getPackage();
System.out.println ("Package Full Name: " + pkgIdent.getFullName());
System.out.println ("Package Source Name: "+pkgIdent.getSourceName());
Here is the output:
Package Full Name: test
Package Source Name: test
The project was located in the folder: /tmp/Projects/SETest/
and the source root was /tmp/Projects/SETest/src
Are you using current build?
Could you be so kind and print out the path of all resources.
Collection c = cp.getAllResources ();
for (Iterator it = c.iterator(); it.hasNext();) {
PathResource pr = (PathResource) it.next();
System.out.println (pr.getFile().getPath());
}
Tomas
On Tue, 2003-08-19 at 00:07, Cliff Draper wrote:
> From: Svata Dedic <[email protected]>
> Date: Sat, 16 Aug 2003 15:29:21 +0200
> > Please check the setup of the project you are working with. Could you
> > please send back output from
> > ClassPath cp = ProjectPath.find(javaObject, ProjectPath.PATH_SOURCE);
> > System.err.println(cp);
> > this should pring out what the project thinks the source roots are.
> > You may get in trouble if the source is not in any project; maybe there
> > may be some issue left for template sources (those coming from
> > system/project filesystem), let us know if it is your case.
>
> Using the following code,
> ClassPath cp = ProjectPath.find(javaObject, ProjectPath.PATH_SOURCE);
> System.err.println("cp.class="+cp.getClass());
> System.err.println("cp="+cp);
> FileObject[] roots = cp.getRoots();
> for (int i = 0; i < roots.length; ++i)
> System.err.println("root="+roots[i]);
> System.err.println("entries="+cp.entries());
> System.err.println("type="+cp.getType());
> System.err.println("resources="+cp.getResources());
> System.err.println("allResources="+cp.getAllResources());
>
> I got the following output:
> cp.class=class org.netbeans.modules.java.classpath.DefaultProxyClassPath
> cp=org.netbeans.modules.java.classpath.DefaultProxyClassPath@7463b3
> root=/home/cliffwd/cvs/sequoia/ffjuserdir/samples/src
> entries=[org.netbeans.spi.java.classpath.ClassPathBase$CPEntryImpl@1d62b0c]
> type=source
> resources=[org.netbeans.modules.java.project.SourceContainer$ResourceImpl@1bb5d98]
> allResources=[org.netbeans.modules.java.project.SourceContainer$ResourceImpl@1bb5d98]
>
> And I'm getting a package Identifier of
> ".home.cliffwd.cvs.sequoia.ffjuserdir.samples.src.examples" where I
> expect "examples".
>
> The source java file is being created by the module. It's source is
> underneath the project's source root.
>
> regards,
> Cliff Draper Sun Microsystems, Forte Tools
> My opinions may or may not reflect those of my employer.
> ---------------------------- food for thought ---------------------------
> "Programmer, noun: A red-eyed, mumbling mammal capable of conversing with
> inanimate objects." [email protected]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>