Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folding mechanism for while/for/if/switch-case #1550

Closed
wants to merge 0 commits into from

Conversation

jakub-suliga
Copy link

@jakub-suliga jakub-suliga commented Jul 26, 2024

Problem:
Currently, there is no folding mechanism for while/for/if/switch-case statements in Eclipse. VSCode and IntelliJ support a folding mechanism for these statements. Therefore, I have created a method that implements this folding mechanism. This is also an open issue: #1426.

Before:
image

After:
image

How to test:

  1. Start an Eclipse workspace and create a new class.
  2. Add while/for/if/switch-case statements to this class.
  3. Verify that the folding mechanism works as expected.

Here is a small program you can use to test:
public class SimpleProgram {
   public void checkNumber(int number) {
       if (number > 0) {
           System.out.println(number + " ist positiv.");
       } else {
           System.out.println(number + " ist null.");
       }
   }

   public static void main(String[] args) {
       SimpleProgram program = new SimpleProgram();
       int count = 1;
       while (count <= 5) {
           System.out.println("Count ist: " + count);
           count++;
       }
   }
}

Bugs:

@jakub-suliga jakub-suliga marked this pull request as draft July 26, 2024 08:34
@jakub-suliga
Copy link
Author

@fedejeanne

@jakub-suliga jakub-suliga marked this pull request as ready for review July 26, 2024 08:46
@jakub-suliga jakub-suliga marked this pull request as draft July 26, 2024 08:46
@iloveeclipse
Copy link
Member

FYI: the 23 test fails should be unrelated, I've just fixed last test that was failing on master after recent bigger changes on JDT core, so please rebase your branch on master if you want see whether your change breaks anything.

@iloveeclipse
Copy link
Member

And btw, the feature looks cool.

Copy link
Contributor

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing this, @jakub-suliga !

I tested it and it looks pretty good. I only have one improvement that I would like to add: the do-while loop and rename the new method to something more expressive.

One thing about the do-while loop is that it also suffers from #1539.

This is how it would look like if you include the do-while loop to this PR ...

image

... and fold it:
image

But that's a topic for another PR, I just wanted to point it out so it does not get forgotten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants