Skip to content

Commit

Permalink
Fix MoStratum for LT-21941 (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmaxwell3 authored Nov 25, 2024
1 parent 2820554 commit d0d49ca
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
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

0 comments on commit d0d49ca

Please sign in to comment.