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 271508

Summary: Specific Organize Members settings and code produces compile-time errors
Product: editor Reporter: SunnyBat
Component: RefactoringAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 8.1   
Hardware: PC   
OS: Windows 10 x64   
Issue Type: DEFECT Exception Reporter:
Attachments: Examples of the issue

Description SunnyBat 2017-09-21 22:30:19 UTC
Created attachment 165158 [details]
Examples of the issue

OVERVIEW:
When the "Sort Members in Groups Alphabetically" option is enabled, specific code can cause invalid formatting (compile-time errors) upon running Organize Members. Tested with Java.

CONDITIONS:
- Sort alphabetically must be enabled
- You must have more than one variable declared on a single line
- You must have another variable on a different line that will be organized between your single-line variables

EXAMPLES:
I've attached a .txt file with multiple examples.

OBSERVATIONS:
This has several different results depending on how the code is organized before Organize Members is run. I get different outputs depending on where obj2 and second2 are in relation to their obviously-related variables as well as in relation to each other. For example, you get different results if second2 is declared after second1. You also get different results for obj1 if second2 is declare before obj1. It's very weird behavior.

The problem seems to stem from NetBeans not properly recognizing comma-separated variable formatting. NetBeans will either use a comma instead of a semicolon for the first variable, or NetBeans will declare the first variable a second time when declaring the third variable.

This also happens when using more than three variables.

Issue set at P2 due to needing to manually correct issues after Organize Members is run.

ENVIRONMENT:
Tested with NetBeans 8.1, Windows 10, JDK8u91, all 64-bit.