Repository navigation
Add ILanguageGeneratorResolver to look up a generator by id or file extension [minor] - #218
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
…xtension [minor] AddLanguageGenerators now registers a resolver over the generators, with TryGetByLanguageId and TryGetByFileExtension. Both ignore case; the extension lookup takes a bare or dotted extension or a file path. When two generators claim the same id or extension, the first registered wins. The editor's preview lookup goes through it instead of its own FirstOrDefault. Fixes #184 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KjGQ13RexM4WYjuEaBtE6
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Fixes #184
What was missing
Generators are registered through DI and each one has a
LanguageIdand aFileExtension, but nothing turns an id or an extension into a generator. Each consumer wrote its ownFirstOrDefault, so they could disagree on case and on the leading dot. The CLI work in #116 has nothing to map--language pyor an output file's extension onto.Change
ILanguageGeneratorResolverandLanguageGeneratorResolverinCoder/Languages:Generatorslists the generators in registration order.TryGetByLanguageId(id, out generator)ignores case.TryGetByFileExtension(extensionOrPath, out generator)ignores case. It acceptspy,.py, or a path such asout/model.py. A path with no extension, and an extension no generator writes, returnfalse..Single(g => g.LanguageId == …)throws and the editor shows each language twice #150) ever comes back.AddLanguageGenerators, and thereforeAddCoder, registers the resolver withTryAddSingleton.CoderEditorAppbuilds its preview lookup and the language list on the resolver instead of its ownFirstOrDefault. Its constructor is unchanged, soProgram, the UI gallery and the tests don't change.Tests (
LanguageGeneratorResolverTests)/and\separators.falseand a null generator. Cases covered: empty,., an extensionless path, a dot in a directory name only, andmodel.py.bak.Generatorslists all seven.With the registration in
ServiceCollectionExtensionsreverted, 33 of the 35 cases fail. The other 2 construct the resolver directly. FullCoder.Testsuite: 1225 passed, 0 failed.Coder.slnbuilds clean.🤖 Generated with Claude Code
https://claude.ai/code/session_012KjGQ13RexM4WYjuEaBtE6
Generated by Claude Code