Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Points to discuss on saturday 29 April 2023 #236

Open
FanJups opened this issue Apr 27, 2023 · 2 comments
Open

Points to discuss on saturday 29 April 2023 #236

FanJups opened this issue Apr 27, 2023 · 2 comments
Labels
jsgenerator-core core module todo Ticket that has to be done

Comments

@FanJups
Copy link
Member

FanJups commented Apr 27, 2023

1- How to run only one test ?

2- Meaning of this code in ApiTest ?

        public Match(final String[] lines) {
            super("jsjenerator-matcher");
            this.lines = lines;
        }

3- What happens if we have 2000 divs ? The program goes from 0 to 999 as you can see 03d. Should we not start at 001 instead of 000 ? #239 #240

public class TypeBasedVariableNameStrategy implements VariableNameStrategy {
    private final Map<String, AtomicLong> counters = new HashMap<>();

    @Override
    public String nextName(@NonNull String type) {
        // NOTE: issue#145 careful with custom element about casing and dash, not to translate in JavaScript identifiers
        var identifier = type;
        final var HAS_DASH = type.contains("-");
        final var IS_ROOT = "targetElement".equals(type);
        final var HAS_UPPER_CASE = !type.chars()
                .allMatch(character -> Character.toLowerCase(character) == character);

        if (!IS_ROOT) {
            identifier = HAS_UPPER_CASE ? type.toLowerCase() : identifier;
            identifier = HAS_DASH
                    ? type.replaceAll("-", "_").replaceAll("_+", "_") : identifier;

            if (HAS_DASH || HAS_UPPER_CASE) {
                identifier = "custom_%s".formatted(identifier);
            }
        }

        return format("%s_%03d", identifier, counters.computeIfAbsent(type, __ -> new AtomicLong()).getAndIncrement());
    }
}
@FanJups FanJups added jsgenerator-core core module todo Ticket that has to be done labels Apr 27, 2023
@FanJups
Copy link
Member Author

FanJups commented Apr 27, 2023

#235

@FanJups
Copy link
Member Author

FanJups commented Apr 29, 2023

#238

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
jsgenerator-core core module todo Ticket that has to be done
Projects
None yet
Development

No branches or pull requests

1 participant