Retrieve value from ".editorconfig" properties directly from ASTNode #1389
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
From the perspective of the Rule developer, simplify the retrieval of an ".editorconfig" property for the current ASTNode. By using the ASTNode as receiver, it is no longer needed to pass the "isAndroidCodeStyle" boolean as well.
Example of new usage:
All logic regarding the determination of the actual value of the property is now defined as part of the definition of that property instead of being spread around multiple places in the ktlint code. Especially the handling of value "unset" (for properties max_line_length and indent_size) and "off" (property max_line_length) is now clearly centralized. This closes #1387.
Most extensive definition at this moment:
Property definitions indentStyleProperty, indentSizeProperty, insertNewLineProperty and maxLineLengthProperty are moved to the DefaultEditorConfigProperties as those properties are based on types provided by the ec4j library.
Class IndentConfig now needs to be initialized based on the values of ".editorconfig" properties indentStyleProperty and indentSizeProperty. Although, this is less convenient, it is more explicit and consistent with how rules should interact with the ".editorconfig" properties.
All rules provided by KtLint itself, now only use the interface UsesEditorConfigProperties to retrieve values for the ".editorconfig" property. As a result, the EditConfig became obsolete. It is marked for deletion in Ktlint 0.46.
Checklist
CHANGELOG.md
is updated