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 257599 - Organize Members deletes annotations and comments
Summary: Organize Members deletes annotations and comments
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P1 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-16 14:00 UTC by _ gtzabari
Modified: 2016-03-03 02:06 UTC (History)
0 users

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 _ gtzabari 2016-01-16 14:00:52 UTC
Product Version: NetBeans IDE Dev (Build 201601130002)
Java: 1.8.0_66; Java HotSpot(TM) 64-Bit Server VM 25.66-b17
Runtime: Java(TM) SE Runtime Environment 1.8.0_66-b17
System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

This is a simple bug, but causes data loss silently so I set the priority at P1.

Given:

@JsonTypeInfo(use = JsonTypeInfo.Id.CUSTOM, property = "type", include = JsonTypeInfo.As.EXISTING_PROPERTY)
@JsonTypeIdResolver(WorkerTypeIdResolver.class)
// TODO: https://github.com/FasterXML/jackson-databind/issues/1056#issuecomment-172208353
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")
public class SomeClass
{
}

If you invoke Organize Members, Netbeans deletes all lines between the imports the last annotation. Meaning, it deletes the line comment and the two annotations above it.

Expected behavior: Netbeans should not provide the hint Organize Members, and even if it does (because some other lines trigger Organize Members) then it should not modify the annotations and line comment.
Comment 1 _ gtzabari 2016-01-16 14:06:43 UTC
Sorry, the code sniplet I posted was incorrect. Here is an easier way to reproduce code sniplet that will work:

---------
package somepackage;

/**
 * Some block comment.
 */
@SuppressWarnings("unchecked")
// Some line comment
@Deprecated
public class Test
{
	private int test;

	public int getTest()
	{
		return test;
	}
}
---------

After Organize Members you will end up with:

---------
package somepackage;

@Deprecated
public class Test
{
	private int test;

	public int getTest()
	{
		return test;
	}
}
---------

Notice that the block comment, @SuppressWarnings, and line comment were all deleted.
Comment 2 Jiri Prox 2016-02-09 11:40:10 UTC
Reproducible

The cause is the comment between annotations
Comment 3 Svata Dedic 2016-02-26 18:50:14 UTC
Seems like the // comment gets incorrectly assigned to TWO trees (annotation, class) instead of just annotation tree.

I've made adjustments so that comments are assigned to the nearby annotations.

Fixed in jet-main#bb79176c8f8f
Comment 4 Quality Engineering 2016-03-03 02:06:13 UTC
Integrated into 'main-silver', will be available in build *201603030002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/bb79176c8f8f
User: Svata Dedic <sdedic@netbeans.org>
Log: #257599: dive into ModifiersTree to assign comments to annotations