This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 49483 - Wrong error highlighting in editor on files in multiple folder freeform project
Summary: Wrong error highlighting in editor on files in multiple folder freeform project
Status: CLOSED WORKSFORME
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 4.x
Hardware: PC Linux
: P4 blocker (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks: 42682
  Show dependency tree
 
Reported: 2004-09-23 14:14 UTC by ladermann
Modified: 2006-03-24 10:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Shows the problem on project "NPI.ejb" via screenshot (77.23 KB, image/png)
2004-09-23 14:16 UTC, ladermann
Details
Screenshot of sample project (30.98 KB, image/png)
2004-09-27 10:17 UTC, ladermann
Details
project.xml for sample project (2.22 KB, text/xml)
2004-09-27 10:18 UTC, ladermann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ladermann 2004-09-23 14:14:41 UTC
In a freefrom project with multiple package 
folders I have a Java class in folder A refering 
to a class in folder B. The project is 
configured to use all folders on its classpath. 
While code completion and import (shift+alt+i) 
works, the editor shows all lines with 
referenced classes from the other folder as 
errors. The tooltip says "cannot find symbol".
Comment 1 ladermann 2004-09-23 14:16:03 UTC
Created attachment 17835 [details]
Shows the problem on project "NPI.ejb" via screenshot
Comment 2 Jesse Glick 2004-09-23 18:26:25 UTC
Probably a configuration problem in your project, not an IDE bug.
Please attach your project.xml together with a description of the
structure of your sources on disk, and your log file. (Or, better yet,
create a trivial self-contained test project that demonstrates the
problem.)

I don't know what "The project is configured to use all folders on its
classpath." is supposed to mean exactly, but if compilation unit A
(with one source root) refers to c.u. B, then B must have at least one
configured output directory or JAR (<built-to>) which is listed in A's
classpath (<classpath mode="compile">) in order for the IDE to know
that there is such a relationship. This roughly corresponds to (in Ant)

<javac srcdir="b-src" destdir="build/b-classes"/>
<javac srcdir="a-src" destdir="build/a-classes">
    <classpath>
        <pathelement location="build/b-classes"/>
    </>
</>

In such a case, A can refer to B but B cannot refer to A.

Alternatively, both package roots may be listed together in a single
c.u. if they are mutually interdependent. For example

<javac destdir="build/all-classes">
    <sourcepath>
        <pathelement location="a-src"/>
        <pathelement location="b-src"/>
    </>
</>

In this case, classes in either A or B can refer to one another
without constraint.

In most situations you want the first scenario (one-way dependency)
since it enforces better modularity, but depends on the details of
your project's setup. The GUI will only let you configure the first
scenario; the second scenario can be supported by direct editing of
project.xml.
Comment 3 ladermann 2004-09-24 08:38:59 UTC
With "The project is configured to use all folders on its 
classpath" I meant the following settings in the projects properties 
in the "classpath" panel: I switched "use seperate classpath" off 
and added explicitly the source folders to the list of clathpath 
elements. After tis it seemed to me, that code completion works 
(which didn't before), but may be this was just by accident and was 
indeed caused by delayed parsing? 
 
Your description of the two project types is quite clear and it 
looks like I have something like the second type in mind. Both 
folders are compiled together and also packaged in a single jar 
(which has not happend so far), so I excpected that the IDE is able 
to "merge" the folders, as NB3.6 does with mounted filesystems. 
 
I will try to create a minimal project to reproduce this. 
Comment 4 Jesse Glick 2004-09-24 17:58:38 UTC
Adding source folders to the list of classpath elements will probably
not work. Classpath entries are expected to contain class files, not
sources. Perhaps code completion works accidentally in this setup, but
I believe the background Java parser is not written to accommodate that.

As I mentioned, to support multiple folders in one compilation unit
you need to edit project.xml directly; the GUI will not permit you to
set up this configuration.

I should also mention that this scenario (several <package-root>s in
one <compilation-unit>) is rarely tested, so you may encounter
specific bugs which should be filed separately. (Typically in
java/code or editor - ant/code only if the project type is not
correctly reporting the situation to the other IDE components which do
the real work such as handling code completion or background parsing.)
Comment 5 ladermann 2004-09-27 10:16:00 UTC
Okay, here is minimal freeform project to show the problem: 
Two folders "srcA" and "srcB". In srcA is a class a.A refering to a 
class b.B in srcB. Find attached a screenshot and the project.xml. 
 
I have no idea how to change the project.xml by hand to solve this. 
As you can see, the two <package-root> elements are already present 
in one <comilation-unit>, the IDE did that when I switched off the 
"Seperate Classpath for Each Source Folder" in the projects property 
sheet. 
Comment 6 ladermann 2004-09-27 10:17:06 UTC
Created attachment 17882 [details]
Screenshot of sample project
Comment 7 ladermann 2004-09-27 10:18:51 UTC
Created attachment 17883 [details]
project.xml for sample project
Comment 8 David Konecny 2004-09-27 10:53:48 UTC
"As I mentioned, to support multiple folders in one compilation unit
you need to edit project.xml directly; the GUI will not permit you to
set up this configuration." - some basics are configurable in UI and
that's what Marco did - turning off "use seperate classpath" checkbox.
I tried it and it really does not work. I will check where is the problem.

Marco, thanx for the test case. In the meantime I was able to
reproduce it too.
Comment 9 David Konecny 2004-09-27 14:02:59 UTC
Marco, could you please zip and attach the whole project?

When I wrote that it does not work for me it was caused by my imports.
And when I created project which I would say is equal to your one it
works fine for me - nothing is underlined. Thanx.
Comment 10 ladermann 2004-09-27 16:05:31 UTC
David, I just restarted the IDE and to my total surprise everythings 
works like  expected, without any error line and with working code 
completion. I changed back (to "on") the "seperate classpath" option 
and code completion stopped to work, but no error was highlighted. 
After a restart of the IDE, the error was also shown. 
 
Maybe there is no "real" bug, but an issue, with the update of 
internal data?  
 
Do you want to see the zipped project anyway? 
Comment 11 David Konecny 2004-09-27 16:26:29 UTC
"Do you want to see the zipped project anyway? " - no, my one works
fine too. :-)

"Maybe there is no "real" bug, but an issue, with the update of 
internal data?" - then it is a bug. I will keep this issue opened for
me to return to it later this week and try to reproduce it. If I'm not
successful nor you provide more info in the meantime I will close it
as WORKSFORME.
Comment 12 David Konecny 2004-09-29 09:09:41 UTC
I'm not able to reproduce it. Feel free to reopen if you are.
Comment 13 Marian Mirilovic 2005-07-12 10:16:12 UTC
closed