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 241839 - Make Controller sometimes removes code that it shouldn't
Summary: Make Controller sometimes removes code that it shouldn't
Status: NEW
Alias: None
Product: javafx
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 240037 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-02-13 17:35 UTC by swpalmer
Modified: 2014-11-30 04:39 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description swpalmer 2014-02-13 17:35:05 UTC
Product Version = NetBeans IDE Dev (Build 201402120001)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.8.0
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.0-b69

Struggling with Make controller which often appears to do nothing when it should be inserting methods or fields.  (Already reported as Bug 240037)
To work around that I sometimes find that modifying the controller class will  cause Make Controller to work the next time it is invoked.
In this case I expected two event handler methods to be added to the controller, but they would not be inserted.  I saw that the controller class was being saved though, every time I invoked Make Controller.
So I manually added one of the methods, saved the file, and tried again.  This time Make controller *removed* my method!

I was adding On Key Typed event handlers for ListViews in Scene builder 2.0

I  added one method to my controller class manually:

	@FXML
	private void assetListKeyTyped(KeyEvent event) {	
	}

Invoked Make Controller and the method was removed!
Comment 1 Lou Dasaro 2014-02-14 07:55:36 UTC
I haven't been able to get Make Controller to delete methods I've entered by hand.
But it does _consistently_ remove the @FXML annotation I had on them.

My environment: 
Product Version: NetBeans IDE Dev (Build 201402120001)
Java: 1.8.0; Java HotSpot(TM) Client VM 25.0-b69
Runtime: Java(TM) SE Runtime Environment 1.8.0-b129
System: Windows 8 version 6.2 running on x86; Cp1252; en_US (nb)
Comment 2 Roman Svitanic 2014-02-14 08:06:35 UTC
Changing component to Editor which is the correct one for "Make Controller".
Comment 3 swpalmer 2014-02-14 15:30:48 UTC
I have reproduced this in another class.  It seems Make Controller will remove things annotated with @FXML in cases where Bug 240037 applies.  It seems like NB is using an old version of the FXML file and is trying to sync the controller to it.
Comment 4 Lou Dasaro 2014-02-14 18:27:38 UTC
Correction: I HAVE been able to get Make Controller to delete methods I've entered by hand. Therefore UPGRADING to Priority 2 as per your email. So far it's been limited to the LAST method in the FXMLDocumentController, but there may be other cases. As documented before, it _consistently_ removes all of the @FXML annotation I had manually placed on other methods.
Comment 5 Lou Dasaro 2014-03-20 08:06:54 UTC
Can we get this whiteboarded for PATCH1. IT DELETES YOUR CODE!
Comment 6 Svata Dedic 2014-03-28 09:10:32 UTC
*** Bug 240037 has been marked as a duplicate of this bug. ***
Comment 7 Svata Dedic 2014-07-17 12:42:04 UTC
As for method deletion: a method is cleaned up from the source, if and only if:
* it is annotated by @FXML
* it is NOT referenced from the fxml file
* it is NOT used (search usages query is executed)
* it IS private (otherwise usage search could take ages)

Such methods, are either removed, provided that their body is empty (ignoring comments), OR their just @FXML annotation is removed.

So in end only unused stubs should be removed. Once you add a real code to your method, it will be preserved -> no real user code loss should happen.
Comment 8 Svata Dedic 2014-07-17 12:44:20 UTC
correction: @FXML is removed from all symbols not referenced from the fxml file; the stricter rules only apply for actual deletion of the method. Sorry for not being precise.
Comment 9 Svata Dedic 2014-11-28 17:00:01 UTC
(In reply to Lou Dasaro from comment #4)
> Correction: I HAVE been able to get Make Controller to delete methods I've
> entered by hand. Therefore UPGRADING to Priority 2 as per your email. So far
> it's been limited to the LAST method in the FXMLDocumentController, but
> there may be other cases. As documented before, it _consistently_ removes
> all of the @FXML annotation I had manually placed on other methods.

Please can you confirm that the IDE deletes your method with non-empty body ?
Comment 10 Svata Dedic 2014-11-28 18:41:16 UTC
Fixed in jet-main#32249f0a276f
Comment 11 Svata Dedic 2014-11-28 18:42:38 UTC
oops, mistakenly closed wrong issue, sorry.
Comment 12 Lou Dasaro 2014-11-28 20:39:30 UTC
@Svata, should I test it this weekend? Or am I waiting for a fix to propagate?
Comment 13 Svata Dedic 2014-11-28 21:04:12 UTC
Sorry I made a mistake - the fix mentioned in comment #10 actually applies to defect #242114 (the mistake was noted in comment #11). Sorry for the confusion.

As far as _this_ issue is concerned does it really delete non-empty user methods ?
Comment 14 Quality Engineering 2014-11-30 04:39:26 UTC
Integrated into 'main-silver', will be available in build *201411300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/32249f0a276f
User: Svata Dedic <sdedic@netbeans.org>
Log: #241839: fx:include is processed for fx:id field binding