eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
725 stars 65 forks source link

Wrapped utility functions in namespaces #1320

Closed spoenemann closed 8 months ago

spoenemann commented 9 months ago

This is a proposal following up on #1260.

Using the method described in #1260, this change reduces the number of top-level exported functions from the main export of langium by 67! That number will be further reduced once #1258 is merged.

spoenemann commented 9 months ago

If this is accepted, I can create a public Gist listing all functions contained in each namespace. Then we can attach that to our CHANGELOG to ease the migration to v3.0.0 (we should do the same with the new package exports).

sailingKieler commented 9 months ago

Please also rename the tests in test/utils corresponding to the renamed files in src/utils.

Lotes commented 9 months ago

I saw a difference in using the namespaces. On one side you are prefixing all olds methods with „XXXUtils.abc“ and one the other side you are deconstructing the namespace with „const { abc } = XXXUtils“. Minor thing, but why is this like that? Having the deconstructor has the advantage that all changes concentrate in the header of each file.

spoenemann commented 9 months ago

I saw a difference in using the namespaces. On one side you are prefixing all olds methods with „XXXUtils.abc“ and one the other side you are deconstructing the namespace with „const { abc } = XXXUtils“. Minor thing, but why is this like that? Having the deconstructor has the advantage that all changes concentrate in the header of each file.

These are two options that you can use as a consumer of the library. Both are ok – it depends on how often you use the functions and whether you want to make it explicit where they come from at the usage site.

Lotes commented 9 months ago

Apart from the REGEX(P) renaming, everything else looks good to me.