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 182342 - code display confused when remove dead block in editor
Summary: code display confused when remove dead block in editor
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 6.x
Hardware: PC Linux
: P2 normal (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-19 01:08 UTC by tbrunhoff
Modified: 2010-05-07 15:54 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screenshot of the error (173.22 KB, image/png)
2010-03-19 01:08 UTC, tbrunhoff
Details
screenshot of the error in a newer version of the ide (179.91 KB, image/png)
2010-05-05 01:40 UTC, tbrunhoff
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tbrunhoff 2010-03-19 01:08:07 UTC
Created attachment 95405 [details]
screenshot of the error

The attached screenshot shows greyed-out code starting in the middle of a code block. This is what's left after deleting a section of fenced code (#if... #endif) which I thought was causing the problem. However, this persists even if I terminate the IDE and restart it. I did find a director under ~/.netbeans/6.9m1/var/cache ~/src/src1/omneon/shared/media/%2Fhome%2Ftoddb%2Fsrc%2Fsrc1%2Fomneon%2Fpcapps%2Fmediareader%2Ftlcopy.nbN which maches the badly rendered file.  After deleting that directory, it rendered the file correctly.

Product Version: NetBeans IDE Dev (Build 201002152000)
Java: 1.6.0_18; Java HotSpot(TM) 64-Bit Server VM 16.0-b13
System: Linux version 2.6.32.9-70.fc12.x86_64 running on amd64; UTF-8; en_US (nb)
Comment 1 Vladimir Voskresensky 2010-04-16 20:44:49 UTC
confirmed
Comment 2 Vladimir Voskresensky 2010-04-16 21:32:26 UTC
due to this issue when you type

#ifdef A
some comments
#endif

dead code is not marked as dead and a lot of unresolved IDs are highlighted
Comment 3 Vladimir Voskresensky 2010-04-16 22:13:50 UTC
fixed, please, verify when propagated into build:
http://hg.netbeans.org/cnd-main/rev/2c65e89ba611
http://hg.netbeans.org/cnd-main/rev/eb3b0b44c06f
Comment 4 Quality Engineering 2010-04-17 08:09:47 UTC
Integrated into 'main-golden', will be available in build *201004170515* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/eb3b0b44c06f
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: fixed #182342 -  code display confused
Comment 5 Quality Engineering 2010-04-20 05:14:17 UTC
Integrated into 'main-golden', will be available in build *201004200200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/f35228d493c2
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: test for #182342 code display confused
Comment 6 Quality Engineering 2010-04-24 05:21:24 UTC
Integrated into 'main-golden', will be available in build *201004240200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ecace18e2f2a
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: add fix for #182342 code display confused
Comment 7 tbrunhoff 2010-05-05 01:39:14 UTC
Today, in the version below, I ran across some code in a file that had not yet been edited but was clearly confused on the scope of the ifdef and what should be grayed out. The attached screenshot shows the code in the editor. Is this the same issue?

Product Version: NetBeans IDE Dev (Build 201005040200)
Java: 1.6.0_18; Java HotSpot(TM) 64-Bit Server VM 16.0-b13
System: Linux version 2.6.32.9-70.fc12.x86_64 running on amd64; UTF-8; en_US (nb)
Userdir: /home/toddb/.netbeans/dev
Comment 8 tbrunhoff 2010-05-05 01:40:31 UTC
Created attachment 98462 [details]
screenshot of the error in a newer version of the ide
Comment 9 tbrunhoff 2010-05-05 01:56:10 UTC
After editing some code below the area shown in the attachment, the code display corrected itself.
Comment 10 Vladimir Voskresensky 2010-05-05 11:59:38 UTC
Todd, was that project completely parsed when you opened IDE or there is a chance, that project was loaded from repository where old data was probably stored?
Comment 11 tbrunhoff 2010-05-05 16:41:17 UTC
Vladimir,
I did not consider that. So I exited the ide, removed all of the files under ~/.netbeans/dev/var/cache/cnd, and then restarted the ide. No problem. Starting from scratch works fine.

However, I think there's a normal workflow that will cause the problem. If I...
 - start the ide, wait for parse to finish, open a file, exit the ide
 - edit the file in an external editor, and add/remove some characters prior to the #if block
 - restart the ide, open the file

... then the rendering of the #if block is inconsistent. It would seem that the code needs to validate the creation time of each model file against the creation time of the source code file. As you know, the FS granularity is 1 second, so simply checking for >= leaves a window. I think the only reliable means is to store validation info in the model files, like size, checksum. But that might be a big code change.

In my case the "inserted characters" came from an svn update outside the ide. But on a hunch, I was able to cause the same problem by using the ide's svn tools to revert to previous versions. That seems like a big exposure, but using the FS mod time to validate would probably catch most instances.
Comment 12 Vladimir Voskresensky 2010-05-06 08:24:22 UTC
(In reply to comment #11)
> Vladimir,
> I did not consider that. So I exited the ide, removed all of the files under
> ~/.netbeans/dev/var/cache/cnd, and then restarted the ide. No problem. Starting
> from scratch works fine.
> 
> However, I think there's a normal workflow that will cause the problem. If I...
>  - start the ide, wait for parse to finish, open a file, exit the ide
>  - edit the file in an external editor, and add/remove some characters prior to
> the #if block
>  - restart the ide, open the file
> 
> ... then the rendering of the #if block is inconsistent. It would seem that the
> code needs to validate the creation time of each model file against the
> creation time of the source code file. As you know, the FS granularity is 1
> second, so simply checking for >= leaves a window. I think the only reliable
> means is to store validation info in the model files, like size, checksum. But
> that might be a big code change.
we are doing timestamps && CRC check already. May be there is a bug.

> 
> In my case the "inserted characters" came from an svn update outside the ide.
> But on a hunch, I was able to cause the same problem by using the ide's svn
> tools to revert to previous versions. That seems like a big exposure, but using
> the FS mod time to validate would probably catch most instances.
May be the issue in NB core if NB Platform doesn't send us file modify events...
Comment 13 Vladimir Voskresensky 2010-05-07 15:54:23 UTC
Tod,
I have checked IDE behavior on external changes and opened corresponding new issue 185712 .
Something is really broken, but it is different from what this issue was originally about. So I close this issue with updated summary.

Thanks for catching bugs!
Vladimir.