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 268906 - Introduce function ignores Comment on last line
Summary: Introduce function ignores Comment on last line
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.2
Hardware: PC Windows 7
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-09 09:49 UTC by k_sch
Modified: 2016-11-09 09:49 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 k_sch 2016-11-09 09:49:06 UTC
Given the following code:
"
    private String testFunction()
    {
        final String testString = "Test";
        // comment at the end of introduce function
        return testString;
    }
"
Marking 
"
        final String testString = "Test";
        // comment at the end of introduce function
"
(The cursor is in the line of "return testString")
and pressing "Introduce Method" (Alt+Shift+M) the following code is generated:
"
    private String testFunction()
    {
        String testString = introducedMethod();
        // comment at the end of introduce function
        return testString;
    }

    private String introducedMethod()
    {
        final String testString = "Test";
        return testString;
    }
"
The comment should be in the introduced method, because it was in the marked area.

Just as a note: After the refactoring the text is marked in these lines:
"
        String testString = introducedMethod();
        // comment at the end of introduce function
        return testString;
    }

    private String introducedMethod()
    {
        final String testString = "Test";
"
To me, this doesn't make much sense. Maybe it would be better if there was no marked text after the refactoring.