Skip to content

project property page for folding #1979

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

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

danthe1st
Copy link
Contributor

@danthe1st danthe1st commented Jan 24, 2025

What it does

This PR introduces a project properties page for Java editor folding as suggested in #1825 (comment)

This was originally part of #1825 but I split it into two PRs.

image

How to test

  • Go to Preferences > Java > Editor > Folding.
    • On the top right, an option "Configure Project specifc settings" should appear
  • Go to Project > Properties > Java Editor > Folding
    • The folding settings can be configured per project

If "Enable project specific settings" is checked, the settings from the project properties page should be used. Otherwise, the workspace preferences are used.

Author checklist

#1562 accesses JavaPlugin.getDefault().getPreferenceStore() in a few places. This will need to be updated when either PR is merged.

@danthe1st danthe1st mentioned this pull request Jan 24, 2025
3 tasks
@danthe1st danthe1st force-pushed the project-folding-preferences branch 4 times, most recently from 72d1a89 to 5a502f8 Compare January 31, 2025 17:40
@danthe1st danthe1st force-pushed the project-folding-preferences branch from 5a502f8 to 1d581ad Compare March 7, 2025 16:24
@jjohnstn jjohnstn force-pushed the project-folding-preferences branch from 1d581ad to 365530f Compare March 18, 2025 21:16
@danthe1st danthe1st force-pushed the project-folding-preferences branch 2 times, most recently from 8346a67 to 9703be4 Compare March 19, 2025 16:53
@danthe1st
Copy link
Contributor Author

^ I added a missing import (might have happened in the last rebase) and then rebased my changes onto master).

@jjohnstn jjohnstn self-requested a review March 24, 2025 20:02
@jjohnstn jjohnstn force-pushed the project-folding-preferences branch from 9703be4 to 432e69b Compare March 24, 2025 20:03
@jjohnstn
Copy link
Contributor

I'm seeing funky things happening with the extended folding preferences. It seems to be toggling instead of looking at the enabled/disabled state. When I try settting in the project settings, it doesn't turn on after Apply and Close. If I set the Workspace preferences and hit apply, it works right away. If I try turning it off and hitting apply again, it doesn't do anything. If I then turn on again in workspace, it turns off in the file. The project settings should take over entirely and the workspae should be ignored if set.

@danthe1st danthe1st force-pushed the project-folding-preferences branch from 432e69b to 7461848 Compare March 25, 2025 17:18
@danthe1st
Copy link
Contributor Author

danthe1st commented Mar 25, 2025

I'm seeing funky things happening with the extended folding preferences. It seems to be toggling instead of looking at the enabled/disabled state. When I try settting in the project settings, it doesn't turn on after Apply and Close. If I set the Workspace preferences and hit apply, it works right away. If I try turning it off and hitting apply again, it doesn't do anything. If I then turn on again in workspace, it turns off in the file. The project settings should take over entirely and the workspae should be ignored if set.

The issue here was that enabling/disabling these preferences required restarting the editor.
I now changed it such that the DefaultJavaFoldingStructureProvider also updates itself automatically when the the project properties are enabled/disabled.

One thing that's still left is completely enabling/disabling folding and switching the folding provider. Doing that cannot be handled by the folding provider and is handled by the JavaEditor (which doesn't seem to care about reacting to project property changes). For this, it's currently still necessary to restart the editor in order to apply the changes.

I am not sure about the toggling behavior you are seeing but I think that comes from there as well.

@danthe1st
Copy link
Contributor Author

Ok the issue above is that JavaEditor only reacts to changes to proerties coming from jdt.core and not jdt.ui.

@danthe1st danthe1st force-pushed the project-folding-preferences branch 3 times, most recently from bdada93 to f72cc05 Compare March 25, 2025 21:39
@danthe1st
Copy link
Contributor Author

danthe1st commented Mar 25, 2025

I fixed the issues.
JavaEditor has a listener that is executed when the corresponding preference changes and toggles whether folding is active. This only included workspace preferences and project properties from jdt.core. I changed it to also include jdt.ui properties.

I also ensured that the properties are set in a way that the listener there "sees" it and I changed the folding provider selection such that it is only available in the workspace preferences since having different folding providers for different projects would require more API changes. However, it is possible to configure any folding provider per-project, it is not just possible to use different folding providers for different projects in the same workspace.

image
image

@danthe1st danthe1st force-pushed the project-folding-preferences branch from f72cc05 to 6a30275 Compare March 25, 2025 22:17
Copy link
Contributor

@jjohnstn jjohnstn left a comment

Choose a reason for hiding this comment

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

LGTM and new version fixes the wonkiness I was seeing.

@jjohnstn jjohnstn merged commit 28920b0 into eclipse-jdt:master Mar 27, 2025
10 checks passed
@jjohnstn
Copy link
Contributor

Thanks @danthe1st If you are willing, please add a N&N entry for the new functionality.

@danthe1st danthe1st deleted the project-folding-preferences branch March 27, 2025 18:56
@danthe1st
Copy link
Contributor Author

@jjohnstn Should I create it for the property page only or also for the custom folding regions feature?

@danthe1st
Copy link
Contributor Author

danthe1st commented Mar 27, 2025

I decided to just create a PR for both.

@jjohnstn jjohnstn added this to the 4.36 M1 milestone May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request noteworthy Noteworthy feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants