Skip to content
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

Fix MoStratum for LT-21941 #316

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/SIL.LCModel/DomainImpl/CmObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3413,6 +3413,10 @@ public virtual IEnumerable<ICmObject> ReferenceTargetCandidates(int flid)
var owner = ReferenceTargetOwner(flid) as ICmPossibilityList;
if (owner != null)
return owner.PossibilitiesOS.Cast<ICmObject>();
var mdc = m_cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
int classId = mdc.GetDstClsId(flid);
if (classId == MoStratumTags.kClassId)
return m_cache.LangProject.MorphologicalDataOA.StrataOS;

var type = (CellarPropertyType)m_cache.MetaDataCache.GetFieldType(flid);
if (type == CellarPropertyType.ReferenceSequence || type == CellarPropertyType.ReferenceCollection)
Expand Down
24 changes: 24 additions & 0 deletions src/SIL.LCModel/DomainImpl/OverridesLing_MoClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4637,4 +4637,28 @@ public override ITsString ShortNameTSS
}

}

internal partial class MoStratum
{
/// <summary>
/// The shortest, non abbreviated label for the content of this object.
/// </summary>
public override string ShortName
{
get
{
var result = ShortNameTSS.Text;
return String.IsNullOrEmpty(result) ? Strings.ksQuestions : result;
}
}

/// <summary>
/// Shortest reasonable name for the object.
/// </summary>
public override ITsString ShortNameTSS
{
get { return Name.BestAnalysisVernacularAlternative; }
}

}
}
19 changes: 18 additions & 1 deletion tests/SIL.LCModel.Tests/DomainImpl/LingTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2002-2017 SIL International
// Copyright (c) 2002-2017 SIL International
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

Expand Down Expand Up @@ -135,6 +135,23 @@ public void NewStemNameHasFeatures()
pos.StemNamesOC.Add(msn);
Assert.That(msn.RegionsOC, Has.Count.EqualTo(1)); // can only be FsFeatStruc, there are no subclasses.
}

[Test]
public void Strata()
{
int ws = Cache.DefaultAnalWs;
IMoStratumFactory stratumFactory = Cache.ServiceLocator.GetInstance<IMoStratumFactory>();
IMoStratum stratum = stratumFactory.Create();
Cache.LangProject.MorphologicalDataOA.StrataOS.Add(stratum);
ITsString tss = TsStringUtils.MakeString("Clitic", ws);
stratum.Name.set_String(ws, tss);
Assert.That(stratum.ChooserNameTS.Text.Equals(tss.Text));
IPhRegularRuleFactory ruleFactory = Cache.ServiceLocator.GetInstance<IPhRegularRuleFactory>();
IPhRegularRule rule = ruleFactory.Create();
Cache.LangProject.PhonologicalDataOA.PhonRulesOS.Add(rule);
var strata = new HashSet<ICmObject>(rule.ReferenceTargetCandidates(PhRegularRuleTags.kflidInitialStratum));
Assert.That(strata.First().Equals(stratum));
}
}


Expand Down
Loading