Fail to introduce method
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### 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:
```java
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)
```java
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
Contributor guide
Research direction
Reproduce the Java Maven example in Apache NetBeans 21 by selecting `int b = 10;` and choosing Refactor → Introduce → Method. Trace the Introduce Method refactoring flow for this selection context; done means the selection is accepted and the extracted method matches the expected result shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100