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

Preference store provider extension point #109

Conversation

angelozerr
Copy link
Contributor

Preference store provider extension point

Signed-off-by: azerr [email protected]

@angelozerr
Copy link
Contributor Author

This PR is just a draft, because it depends from another PRs:

It provides the capability to add custom IPreferenceStore in the store of the generic editor with a new extension point org.eclipse.ui.genericeditor.preferenceStoreProviders. I have 2 usecases for this requirement:

   <extension
         point="org.eclipse.ui.genericeditor.preferenceStoreProviders">
      <provider
            class="org.eclipse.text.editorconfig.internal.EditorConfigPreferenceStoreProvider"
            contentType="org.eclipse.core.runtime.text">
      </provider>
   </extension>

I have a POC to customize insert spaces for XML with UI preferences

image

I use the new extension point like this:

   <extension
         point="org.eclipse.ui.genericeditor.preferenceStoreProviders">
      <provider
            class="org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceStoreProvider"
            contentType="org.eclipse.core.runtime.xml">
      </provider>
   </extension>

@angelozerr
Copy link
Contributor Author

@mickaelistria I know we disccus about using adapter factory for .editorconfig, but insert spaces / tab width for WWD becomes a priority I think and after a long investigation with this topic, I can manage all usescases:

  • editorconfig
  • customize insert spaces for each language of LSP4e. The API is not linked to an editor or viewer.

The API is not linked to an editor or source viewer, just with IResource that it is requires for .editorconfig (give me the preference store of the given resource, so the preference store could not be linked to an editor, just a resource file):

package org.eclipse.core.resources.proposed;

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.preference.IPreferenceStore;

public interface IPreferenceStoreProvider {

	IPreferenceStore getPreferenceStore(IResource resource);
}

See https://github.com/eclipse-platform/eclipse.platform.text/pull/109/files#diff-66a79c46ab5014d45f164ff0e7a1119c3744e77438d7cb7d311e085a9ecc8428

In the case of .editorconfig, I need to work with editor to retrieve the preference store and update it fire property declared in .editorconfig and update the editor with proper insert spaces / tab widh

See the following demo:

JSONEditorConfigDemo

To access to the editor, I return an instance of IPreferenceStore which implements ITextEditorAware in order to the extension point inject the instance of the generic editor. I create the API in #108

@angelozerr
Copy link
Contributor Author

I think this PR (which includes other PRs that I did) is very important for WWD specialy this issue eclipse-wildwebdeveloper/wildwebdeveloper#872

There are more and more users who complain that they cannot configure spaces / tabs for XML, HTML, etc although they could do that with Eclipse WTP and my fear is that users will start hating WWD because of missing preferences.

WWD with Generic Editor is so powerfull, combined with TM4e, LSP4e, and can provide the same features than other custom editor, but the custom preferences in Generic Editor is not possible and for a given editor I think it is very important to have the capability to customize it like insert spaces.

Once preference store provider for generic editor will be available, It will open the door for many features to customize the generic editor like

  • customize spaces / tabs for a given language
  • display max line height line renderer according line width of a given language (format)
  • support for .editorconfig.

I know that @mickaelistria is very busy, so I wonder if some other people could help me to review some PRs to provide step by step this preference store provider extension point.

Thanks for your help.

@angelozerr
Copy link
Contributor Author

Close for #130

@angelozerr angelozerr closed this Jan 3, 2023
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.

1 participant