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

v1 of style Autodetect #120

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

v1 of style Autodetect #120

wants to merge 2 commits into from

Conversation

greg-at-moderne
Copy link
Contributor

@greg-at-moderne greg-at-moderne commented Jan 13, 2025

What's changed?

Adding Autodetect with basic implementation which identifies just one parameter for now - the indent size.
Not plugging in this implementation anywhere yet. I think that could be done when it's more complete.

What's your motivation?

@timtebeek timtebeek added the enhancement New feature or request label Jan 13, 2025
Comment on lines +81 to +84
private int countSpaces(String s) {
int withoutSpaces = s.replaceAll(" ", "").length();
return s.length() - withoutSpaces;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though this implementation currently only supports very simple detection, I would already now align it with the implementation we have for Java (see FindIndentJavaVisitor and IndentStatistics classes), as we will soon require that anyway to detect more complex cases (e.g. tabs or mixed spaces and tabs). Also note that we should try to avoid using methods like String#replaceAll() which behind the scenes will instantiate a regex pattern, as the allocation cost will put the GC under a lot of pressure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants