Repository navigation
LT-22822: Don't display autogenerated Natural Classes #1198
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
Open
aror92
wants to merge
5
commits into
main
Choose a base branch
from
LT-22822-dont-display-autogen-NCs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
115ffdd
LT-22822: Part 1 Update IsFeatureBasedNCUserDefined logic
aror92 d6688aa
LT-22822: Don't display autogenerated Natural Classes
aror92 c2f87eb
LT-22822: Add tests for hiding auto-generated Natural Classes
aror92 6b57706
Merge branch 'main' into LT-22822-dont-display-autogen-NCs
aror92 cf36e63
LT-22822: Exclude autogen NCs from record list instead of via filter
aror92 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
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
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
64 changes: 64 additions & 0 deletions
64
Src/LexText/Morphology/MorphologyEditorDllTests/NaturalClassRecordListTests.cs
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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) 2026 SIL International | ||
| // This software is licensed under the LGPL, version 2.1 or later | ||
| // (http://www.gnu.org/licenses/lgpl-2.1.html) | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using NUnit.Framework; | ||
| using SIL.LCModel; | ||
|
|
||
| namespace SIL.FieldWorks.XWorks.MorphologyEditor | ||
| { | ||
| /// <summary> | ||
| /// Tests to confirm that <see cref="NaturalClassRecordList"/> includes every | ||
| /// natural class except a feature-based one generated automatically for a rule. | ||
| /// </summary> | ||
| [TestFixture] | ||
| public class NaturalClassRecordListTests : RuleFormulaVcTestBase | ||
| { | ||
| private IEnumerable<int> NCRecordList(params ICmObject[] natClasses) | ||
| { | ||
| return NaturalClassRecordList.ExcludeAutoGenerated( | ||
| natClasses.Select(nc => nc.Hvo), Cache); | ||
| } | ||
| [Test] | ||
| public void AutoGeneratedClass_IsExcluded() | ||
| { | ||
| IPhNCFeatures natClass = AddAutoGeneratedFeatureNaturalClass("s to n", | ||
| new Dictionary<string, string> { { "vd", "+" } }); | ||
|
|
||
| // Since the only NC is autogenerated, the NC record list should be empty | ||
| Assert.That(NCRecordList(natClass), Is.Empty); | ||
| } | ||
|
|
||
| [Test] | ||
| public void NamedFeatureClass_IsIncluded() | ||
| { | ||
| IPhNCFeatures natClass = AddFeatureNaturalClass("Voiced", "Vd", | ||
| new Dictionary<string, string> { { "vd", "+" } }); | ||
|
|
||
| Assert.That(NCRecordList(natClass), Is.EqualTo(new[] { natClass.Hvo })); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// A feature-based class the user creates starts with no name, so an unnamed class must | ||
| /// be included for the user to be able to name it. | ||
| /// </summary> | ||
| [Test] | ||
| public void UnnamedFeatureClass_IsIncluded() | ||
| { | ||
| IPhNCFeatures natClass = AddFeatureNaturalClass(null, null, | ||
| new Dictionary<string, string> { { "vd", "+" } }); | ||
|
|
||
| Assert.That(NCRecordList(natClass), Is.EqualTo(new[] { natClass.Hvo })); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SegmentClass_IsIncluded() | ||
| { | ||
| IPhNCSegments natClass = AddSegmentNaturalClass("Vowels", "V"); | ||
|
|
||
| Assert.That(NCRecordList(natClass), Is.EqualTo(new[] { natClass.Hvo })); | ||
| } | ||
| } | ||
| } |
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright (c) 2026 SIL International | ||
| // This software is licensed under the LGPL, version 2.1 or later | ||
| // (http://www.gnu.org/licenses/lgpl-2.1.html) | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using SIL.LCModel; | ||
|
|
||
| namespace SIL.FieldWorks.XWorks.MorphologyEditor | ||
| { | ||
| /// <summary> | ||
| /// Exclude all auto-generated feature-based natural classes from the NC record list. | ||
| /// </summary> | ||
| public class NaturalClassRecordList : RecordList | ||
| { | ||
| protected override IEnumerable<int> GetObjectSet() | ||
| { | ||
| return ExcludeAutoGenerated(base.GetObjectSet(), m_cache); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The given natural class HVOs, less the feature-based classes generated automatically | ||
| /// for a rule. | ||
| /// </summary> | ||
| internal static IEnumerable<int> ExcludeAutoGenerated(IEnumerable<int> hvos, LcmCache cache) | ||
| { | ||
| var repo = cache.ServiceLocator.GetInstance<ICmObjectRepository>(); | ||
| return hvos.Where(hvo => | ||
| !RuleFormulaControl.IsAutoGeneratedNaturalClass(repo.GetObject(hvo) as IPhNaturalClass)); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once a rule stops using one of its auto-generated classes, I can't find a way for the user to delete it now. Nothing deletes the class when the context is removed from the rule, when the rule itself is deleted, or when Set Mapping Features clears an affix mapping back to a copy (
AffixRuleFormulaControl.SetMappingFeaturesremoves the mapping and leaves its class inNaturalClassesOS). Until now the user could find these leftovers in Grammar > Natural Classes and delete them; this list now hides them. They still show in the environment natural-class chooser, so the user will see "Created automatically for rule …" entries there that they can't remove.Should a class be deleted when its rule stops using it? Or should the list still show the leftovers?