netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Fail to introduce method

Open usersuis opened this issue 1 year ago • 0 comments

Apache NetBeans version

Apache NetBeans 21

What happened

When I tried to perform "introduce method" refactoring on "int b= 10;" using refactoring tool in NetBeans, it displayed a warning and failed to do the refactoring.

Language / Project Type / NetBeans Component

Java Maven Project Java Application

How to reproduce

Input Program:

public interface I1 {
	int foo(int a);
}

interface I2 {
	I1 i1= (a) -> {
		int b= 10; 
		return a + b;
	};
}

Steps: Select "int b = 10;" Refactor -> Introduce -> Method

Actual Result: a warning: "Invalid Selection."

Expected Result: (from Refactoring tool of IntelliJ)

    public interface I1 {
        int foo(int a);
    }

    interface I2 {
        I1 i1 = (a) -> {
            int b = getB();
            return a + b;
        };

        private static int getB() {
            int b = 10; 
            return b;
        }
    }

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

22.0.1

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

It always occurs.

Are you willing to submit a pull request?

No

usersuis avatar Jun 01 '24 20:06 usersuis