-
Notifications
You must be signed in to change notification settings - Fork 506
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
Fix import-ordering editorconifg generation #1011
Fix import-ordering editorconifg generation #1011
Conversation
@romtsn this experimental api is in alpha state so it is fine to find such issues and fix them 🙂 Thank you for finding this one 👏 Regarding the issue itself - current code should correctly parse The real "issue" is in My vision how it could be fixed:
public data class EditorConfigProperty<T>(
public val type: PropertyType<T>,
public val defaultValue: T,
public val defaultAndroidValue: T = defaultValue,
public val propertyWriter: (T) -> String = { it.toString() }
)
public fun <T> EditorConfigProperties.writeEditorConfigProperty(
property: EditorConfigProperty<T>,
isAndroidCodeStyle: Boolean
): String {
return property.propertyWriter(getEditorConfigValue(property, isAndroidCodeStyle))
}
Then to fix |
imho it makes rule code easier as you not deal with string of patterns, but already parsed list of pattern that it is easier to work with |
Yeah, makes sense 👍
That's true, it will correctly parse it. But when you try to write it back using As for your proposal, it looks good I will follow up on this soon 👍 |
@Tapchicoma updated accordingly 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@Tapchicoma not sure why you converted the properties to
List<PatternEntry>
but writing to editorconfig didn't work properly, because:toString
method was messed upList<PatternEntry>.toString()
returns something like[*,kotlin.**,java.**,^]
- mind the braces. This is an incorrect value if we wanna write to the standardij_kotlin_imports_layout
, to properly generate it we would need to usejoinToString
but we don't know the type in thegetEditorConfigValue
..So the easiest path I found is to revert properties to be strings, but not sure if it's the best approach. Maybe we could introduce some interface like
EditorconfigWriteable
which has atoString
method and put it as an upper bound for genericEditorConfigProperty<T : EditorconfigWriteable>