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.
[Netbeans 200411101900; JDS v.2; JDK 1.5.0_01-b06] Try to create an empty class and change file attributes to read-only. The file needs to be completely empty (no source code). Then open the class in editor and launch from context menu on right-click any refactoring-related action. E.g. rename, change method parameters or move class. The attached NPE is thrown.
Created attachment 18850 [details] NPE
Honzo, please look at it.
Problem is in ASTProvider. See attachment. Tomasi, can you look at it? Thanks.
Created attachment 19390 [details] Dump file
lastToken of ASTree representing COMPILATION_UNIT is -1
Let me see if I get this right: there are no tokens, but you still want gjast to return a valid token and token index. Your team will first need to specify what behavior you want before asking me to implement it.
By the way, it was for exactly this sort of problem (and others) that I recommended last year that we have an EOF token. That suggestion was rejected by the rest of the team.
Tom, I am surprised by your comments and by the fact that we do not have the EOF token - I was under impression we do have it. It seems that we have forgotten about it along the way. As far as I remember, nobody refused it. Looking into my e-mails archive, I found an e-mail from you named "Need EOF token" containing the text (probably sent out after we had a call?): Martin, Here's the email you requested so we remember to define an EOF token, so that comments at the end of a file won't be discarded. I don't think Tomas needs to change his Scanner necessarily, as the token can be appended when scanning is finished. Whatever is easiest. Tom The e-mail apparently indicates we *agreed* to add the EOF token. The next day Tomas replied: OK, I will do it and let you know. These are the only two e-mails on this topic I found. If you look at the ParserTokens.java, the EOF token is there - it was added by you together with the new interfaces in the parser library to allow plugging the gjast in (about a week after the above e-mails were exchanged). It seems that since then we forgot about it and never actually added the token to the token array, which was kind of a surprise to me - I admit I completely forgot about it. Please let us know if you would consider it being risky to add it now. I will also discuss this with Tomas tomorrow.
FYI, Tomas was as surprised as me to hear that we don't have the EOF token, so we just checked it and found out the token array returned by gjast *does contain* EOF for both non-empty and empty files.
Added test for empty COMPILATION_UNIT trees.
Verified on 200502201900.
Reorganization of java component