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 230006 - Rename method corrupts code when mixed with line wrap
Summary: Rename method corrupts code when mixed with line wrap
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-20 18:45 UTC by _ gtzabari
Modified: 2013-05-21 12:31 UTC (History)
1 user (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 _ gtzabari 2013-05-20 18:45:23 UTC
Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\7.3
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\7.3

When Rename Method is used against a method and that method is line-wrapped in the source-code, the operation ends up corrupting the source-code.

Repro steps:

1. Given:

public class Testcase
{
	public Testcase getSelf()
	{
		return this;
	}

	public static void main(String[] args)
	{
		Testcase testcase = new Testcase();
		testcase.getSelf().getSelf().getSelf().getSelf().getSelf().getSelf().getSelf().getSelf().
			getSelf().getSelf().getSelf().getSelf().getSelf().getSelf();
	}
}

2. Place caret on getSelf(), hit CTRL+R and rename the method to getSelf2().
3. The output will be:

public class Testcase
{
	public Testcase getSelf2()
	{
		return this;
	}

	public static void main(String[] args)
	{
		Testcase testcase = new Testcase();
		testcase.getSelf2().getSelf2().getSelf2().getSelf2().getSelf2().getSelf2().getSelf2().getSelf2().getSelf2Self().getSelf2().getSelf2().getSelf2().getSelf2().getSelf2();
	}
}

4. Notice the output contains two bugs:

a. The line-wrapped reference gets renamed to getSelf2Self() instead of getSelf2()
b. The line wrapping is removed and the method invocation now shows up on a single line.
Comment 1 Ralph Ruijs 2013-05-21 12:31:51 UTC
Seems to be already fixed in the latest dev-builds. Reproducible in 7.3, but not in today's build.