eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
Extended folding ignoring single-expression if statements over multiple lines
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 35
Description
The "extended folding" option that Jakub implemented ensures that the line with the closing `}` is present.
With single-expression `if`s, there is no closing `}` so it includes the last line of the statement to fold.
This issue only occurs if the `if` statement consists of multiple lines.
Reproducer (note the empty line after the `if(b)` and the missing `{}`s):
```java
package org.example.test;
public class Repro {
public String test(boolean b) {
if (b)
return "a";
return "b";
}
}
```
Expected result after collapsing the `if(b)`:
```java
package org.example.test;
public class Repro {
public String test(boolean b) {
if (b)
return "a";
return "b";
}
}
```
Actual result after collapsing the `if(b)`:
```java
package org.example.test;
public class Repro {
public String test(boolean b) {
if (b)
return "a";
return "b";
}
}
```
I think it's the same for other control structures.
@fedejeanne
Contributor guide
Research direction
The issue names no source files or tests. Start by reproducing the Java example with extended folding enabled, then locate the folding implementation and related tests; done means collapsing a multiline single-expression if removes the empty line while preserving the return statement, with other control structures checked if applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100