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

Improve documentation for org.openrewrite.java.style.ImportLayoutStyle.layout #253

Open
MartinAhrer opened this issue Dec 20, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@MartinAhrer
Copy link

MartinAhrer commented Dec 20, 2023

What problem are you trying to solve?

Implementing a style for formatting (rearranging) Java import statements

Describe the solution you'd like

Add documentation and examples showing how the layout property's list elements need to look like.

Have you considered any alternatives or workarounds?

It was only possible to figure out the format of a layout list element by reading the source code for org.openrewrite.java.style.Deserializer.

Example:

      layout:
        - 'import import java.*'
        - 'import import javax.*'
        - 'import import org.*'
        - 'import import com.*'
        - 'import all other imports'
        - 'import static all other imports'

@MartinAhrer MartinAhrer added the enhancement New feature or request label Dec 20, 2023
@timtebeek timtebeek transferred this issue from openrewrite/rewrite Dec 20, 2023
@timtebeek
Copy link
Contributor

Hi @MartinAhrer , good seeing you here! Indeed seems like an area we haven't covered with our docs yet; thanks for pointing that out and providing an example. Perhaps we could work that into our page on Styles @mike-solomon ?

## Developing styles
There are two ways you can create a style: via a [declarative YAML file](../reference/yaml-format-reference.md) (**recommended**) or programmatically in Java.

@timtebeek timtebeek moved this to Backlog in OpenRewrite Dec 20, 2023
@timtebeek timtebeek added the documentation Improvements or additions to documentation label Dec 20, 2023
@mike-solomon
Copy link
Contributor

Hey there @MartinAhrer -- I'm taking a look at this issue now, but I'm a bit confused. Hoping you might be able to help me understand the issue. Were you trying to define your style declaratively in YAML?

In taking a look at the schema, I don't see any layout defined there.

Is the issue that layout works when defining a style declaratively but the schema doesn't show it as an option and we don't document it in this table -- or is there some other issue I'm not understanding here?

Thanks for your time!

@timtebeek
Copy link
Contributor

timtebeek commented Jan 23, 2024

Maybe you could even share the style yaml you arrived at, such that we can include it both in the docs and the json schema we have, if you're open to that.

@mike-solomon mike-solomon added the blocked When an issue can't be worked on right now label Jan 25, 2024
@MartinAhrer
Copy link
Author

Yes, I was trying to do that using YML. Here is a more complete example:

name: xxx.openrewrite.ImportLayoutStyle
styleConfigs:
  - org.openrewrite.java.style.ImportLayoutStyle:
      classCountToUseStarImport: 9999
      nameCountToUseStarImport: 9999
      layout:
        - 'import java.**'
        - 'import javax.**'
        - 'import org.**'
        - 'import com.**'
        - 'import **'
        - 'static import **'

However import formatting didn't work as expected and was only correct partially. And this was the reason for requesting a more comprehensive documentation on that configuration.

@mike-solomon mike-solomon removed the blocked When an issue can't be worked on right now label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

3 participants