-
Notifications
You must be signed in to change notification settings - Fork 5
Simplify to register additional/custom Typir services #78
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5f88820
simplified kind registry
JohannesMeierSE afea1cc
improved error message
JohannesMeierSE bb4a173
made test utility more flexible
JohannesMeierSE a6d81a2
fixed bug: the logic to ensure that types are not created multiple ti…
JohannesMeierSE 65d0faf
new feature: make the $names of kinds configurable
JohannesMeierSE 6ba8bef
enable additional services in Typir core with `createTypirServicesWit…
JohannesMeierSE 4ce6969
enable additional services in Typir-Langium with `createTypirLangiumS…
JohannesMeierSE 65aefc5
Langium services are stored in the TypirLangium services now
JohannesMeierSE d5d1421
rebasing fixes
JohannesMeierSE 2c7b673
demonstrate API for additional Typir services for the custom matrix t…
JohannesMeierSE faee192
polished the CHANGELOG.md
JohannesMeierSE d810785
specify sub-super-relationships of language nodes for the predefined …
JohannesMeierSE e027d6f
wrote documentation for customization
JohannesMeierSE ab78f9d
sketched alternative function to support additional services
JohannesMeierSE 01d1557
improvements according to the review
JohannesMeierSE 0c00785
removed skipped alternative solution, added forth customization param…
JohannesMeierSE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,13 +130,11 @@ export function createTypirServices<LanguageType>( | |
| ); | ||
| } | ||
|
|
||
| // TODO Review: Is it possible to merge/unify these two functions in a nice way? | ||
|
|
||
| /** | ||
| * Creates the TypirServices with the default module containing the default implements for Typir, | ||
| * which might be exchanged by the given optional customized modules. | ||
| * Additionally, some new services are defined, and implementations for them are registered. | ||
| * @param moduleForAdditionalServices contains configurations for all added services | ||
| * @param moduleForAdditionalServices contains the configurations for all added services | ||
| * @param customization1 optional Typir module with customizations (for new and existing services) | ||
| * @param customization2 optional Typir module with customizations (for new and existing services) | ||
| * @param customization3 optional Typir module with customizations (for new and existing services) | ||
|
|
@@ -161,6 +159,31 @@ export function createTypirServicesWithAdditionalServices<LanguageType, Addition | |
| ); | ||
| } | ||
|
|
||
| // TODO Review: Is it possible to merge/unify the two functions above in a nice way? | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure about this question. Could we discuss this? |
||
|
|
||
| // The following function is a possible solution, but with a small limitation: | ||
| // - If you specify non-empty additional services via the <AdditionalServices> generic, you will get no TypeScript compiler error, | ||
| // if you don't specify a value for 'moduleForAdditionalServices'. (Doing that makes no sense of course, but a hint would be nice nevertheless.) | ||
| // 'moduleForAdditionalServices' needs to be optional, otherwise, you need to add '{}' as value even when you specified no additional services. | ||
|
|
||
| export function createTypirServicesBoth<LanguageType, AdditionalServices = Record<string, never>>( // "Record<string, never>" means an empty object! | ||
| moduleForAdditionalServices?: Module<TypirServices<LanguageType> & AdditionalServices, AdditionalServices>, | ||
| customization1?: Module<TypirServices<LanguageType> & AdditionalServices, DeepPartial<TypirServices<LanguageType> & AdditionalServices>>, | ||
| customization2?: Module<TypirServices<LanguageType> & AdditionalServices, DeepPartial<TypirServices<LanguageType> & AdditionalServices>>, | ||
| customization3?: Module<TypirServices<LanguageType> & AdditionalServices, DeepPartial<TypirServices<LanguageType> & AdditionalServices>>, | ||
| ): TypirServices<LanguageType> & AdditionalServices { | ||
| return inject( | ||
| // use the default implementations for all core Typir services | ||
| createDefaultTypirServicesModule<LanguageType>(), | ||
| moduleForAdditionalServices, | ||
| // optionally add some more language-specific customization, e.g. for ... | ||
| customization1, // ... production | ||
| customization2, // ... testing (in order to replace some customizations of production) | ||
| customization3, // ... testing (e.g. to have customizations for all test cases and for single test cases) | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * A deep partial type definition for services. We look into T to see whether its type definition contains | ||
| * any methods. If it does, it's one of our services and therefore should not be partialized. | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.