Skip to content

Commit 7f1d648

Browse files
authored
Fix LT-22239: Missing updates in Parsing Development Mode (#422)
1 parent 0359d24 commit 7f1d648

3 files changed

Lines changed: 59 additions & 40 deletions

File tree

Src/LexText/Interlinear/InterlinDocRootSiteBase.cs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
using System.Drawing;
99
using System.Linq;
1010
using System.Windows.Forms;
11-
using SIL.FieldWorks.Common.ViewsInterfaces;
1211
using SIL.FieldWorks.Common.Controls;
13-
using SIL.LCModel.Core.KernelInterfaces;
1412
using SIL.FieldWorks.Common.FwUtils;
1513
using SIL.FieldWorks.Common.RootSites;
14+
using SIL.FieldWorks.Common.ViewsInterfaces;
15+
using SIL.FieldWorks.FwCoreDlgControls;
1616
using SIL.LCModel;
17+
using SIL.LCModel.Core.KernelInterfaces;
18+
using SIL.LCModel.Core.Text;
1719
using SIL.LCModel.DomainServices;
1820
using SIL.LCModel.Infrastructure;
19-
using SIL.FieldWorks.FwCoreDlgControls;
2021
using XCore;
21-
using SIL.LCModel.Core.Text;
2222

2323
namespace SIL.FieldWorks.IText
2424
{
@@ -919,11 +919,11 @@ internal virtual void UpdateGuesses(HashSet<IWfiWordform> wordforms)
919919
private void UpdateGuesses(HashSet<IWfiWordform> wordforms, bool fUpdateDisplayWhereNeeded)
920920
{
921921
// now update the guesses for the paragraphs.
922-
var pdut = new ParaDataUpdateTracker(Vc.GuessServices, Vc.GuessCache);
922+
var pdut = new ParaDataUpdateTracker(Vc.GuessServices, Vc.GuessCache, this);
923923
if (wordforms != null)
924924
// The user may have changed the analyses for wordforms. (LT-21814)
925925
foreach (var wordform in wordforms)
926-
pdut.NoteChangedAnalysis(wordform.Hvo);
926+
pdut.NoteChangedWordform(wordform.Hvo);
927927
foreach (IStTxtPara para in RootStText.ParagraphsOS)
928928
pdut.LoadAnalysisData(para, wordforms);
929929
if (fUpdateDisplayWhereNeeded)
@@ -1038,37 +1038,38 @@ public virtual void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDe
10381038
{
10391039
case WfiAnalysisTags.kflidEvaluations:
10401040
IWfiAnalysis analysis = m_cache.ServiceLocator.GetInstance<IWfiAnalysisRepository>().GetObject(hvo);
1041-
if (analysis.HasWordform && RootStText.UniqueWordforms().Contains(analysis.Wordform))
1042-
{
1043-
m_wordformsToUpdate.Add(analysis.Wordform);
1044-
m_mediator.IdleQueue.Add(IdleQueuePriority.High, PostponedUpdateWordforms);
1045-
}
1041+
CheckUpdateWordform(analysis.Wordform);
10461042
break;
10471043
case WfiWordformTags.kflidAnalyses:
10481044
IWfiWordform wordform = m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>().GetObject(hvo);
1049-
var uniqueWordforms = RootStText.UniqueWordforms();
1050-
if (uniqueWordforms.Contains(wordform))
1045+
CheckUpdateWordform(wordform);
1046+
break;
1047+
}
1048+
}
1049+
1050+
private void CheckUpdateWordform(IWfiWordform wordform)
1051+
{
1052+
var uniqueWordforms = RootStText.UniqueWordforms();
1053+
if (uniqueWordforms.Contains(wordform))
1054+
{
1055+
m_wordformsToUpdate.Add(wordform);
1056+
m_mediator.IdleQueue.Add(IdleQueuePriority.High, PostponedUpdateWordforms);
1057+
}
1058+
// Update uppercase versions of wordform.
1059+
// (When a lowercase wordform changes, it affects the best guess of its uppercase versions.)
1060+
var form = wordform.Form.VernacularDefaultWritingSystem;
1061+
var cf = new CaseFunctions(m_cache.ServiceLocator.WritingSystemManager.Get(form.get_WritingSystemAt(0)));
1062+
foreach (IWfiWordform ucWordform in uniqueWordforms)
1063+
{
1064+
var ucForm = ucWordform.Form.VernacularDefaultWritingSystem;
1065+
if (ucForm != form && ucForm != null && !string.IsNullOrEmpty(ucForm.Text))
1066+
{
1067+
if (cf.ToLower(ucForm.Text) == form.Text)
10511068
{
1052-
m_wordformsToUpdate.Add(wordform);
1069+
m_wordformsToUpdate.Add(ucWordform);
10531070
m_mediator.IdleQueue.Add(IdleQueuePriority.High, PostponedUpdateWordforms);
10541071
}
1055-
// Update uppercase versions of wordform.
1056-
// (When a lowercase wordform changes, it affects the best guess of its uppercase versions.)
1057-
var form = wordform.Form.VernacularDefaultWritingSystem;
1058-
var cf = new CaseFunctions(m_cache.ServiceLocator.WritingSystemManager.Get(form.get_WritingSystemAt(0)));
1059-
foreach (IWfiWordform ucWordform in uniqueWordforms)
1060-
{
1061-
var ucForm = ucWordform.Form.VernacularDefaultWritingSystem;
1062-
if (ucForm != form && ucForm != null && !string.IsNullOrEmpty(ucForm.Text))
1063-
{
1064-
if (cf.ToLower(ucForm.Text) == form.Text)
1065-
{
1066-
m_wordformsToUpdate.Add(ucWordform);
1067-
m_mediator.IdleQueue.Add(IdleQueuePriority.High, PostponedUpdateWordforms);
1068-
}
1069-
}
1070-
}
1071-
break;
1072+
}
10721073
}
10731074
}
10741075

Src/LexText/Interlinear/InterlinVc.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ private void EnsureLoader()
24262426

24272427
internal virtual IParaDataLoader CreateParaLoader()
24282428
{
2429-
return new InterlinViewCacheLoader(new AnalysisGuessServices(m_cache, IsParsingDevMode()), GuessCache);
2429+
return new InterlinViewCacheLoader(new AnalysisGuessServices(m_cache, IsParsingDevMode()), GuessCache, RootSite);
24302430
}
24312431

24322432
internal void RecordGuessIfNotKnown(AnalysisOccurrence selected)
@@ -2559,10 +2559,11 @@ public class InterlinViewCacheLoader : IParaDataLoader
25592559
{
25602560
private InterlinViewDataCache m_guessCache;
25612561
public InterlinViewCacheLoader(AnalysisGuessServices guessServices,
2562-
InterlinViewDataCache guessCache)
2562+
InterlinViewDataCache guessCache, InterlinDocRootSiteBase rootSite)
25632563
{
25642564
GuessServices = guessServices;
25652565
m_guessCache = guessCache;
2566+
RootSite = rootSite;
25662567
}
25672568

25682569
/// <summary>
@@ -2571,6 +2572,8 @@ public InterlinViewCacheLoader(AnalysisGuessServices guessServices,
25712572
public AnalysisGuessServices GuessServices { get; private set; }
25722573
public InterlinViewDataCache GuessCache { get { return m_guessCache; } }
25732574

2575+
public InterlinDocRootSiteBase RootSite;
2576+
25742577
#region IParaDataLoader Members
25752578

25762579
public void LoadParaData(IStTxtPara para)
@@ -2630,7 +2633,12 @@ private void RecordGuessIfAvailable(AnalysisOccurrence occurrence)
26302633

26312634
// we don't provide guesses for glosses
26322635
if (occurrence.Analysis is IWfiGloss)
2636+
{
2637+
if (IsParsingDevMode())
2638+
// Trigger redisplay.
2639+
SetObjProp(occurrence, InterlinViewDataCache.AnalysisMostApprovedFlid, 0);
26332640
return;
2641+
}
26342642
// next get the best guess for wordform or analysis
26352643

26362644
IAnalysis wag = occurrence.Analysis;
@@ -2647,6 +2655,13 @@ private void RecordGuessIfAvailable(AnalysisOccurrence occurrence)
26472655
}
26482656
}
26492657

2658+
internal bool IsParsingDevMode()
2659+
{
2660+
if (RootSite?.GetMaster() == null)
2661+
return false;
2662+
return RootSite.GetMaster().IsParsingDevMode();
2663+
}
2664+
26502665
public IAnalysis GetGuessForWordform(IWfiWordform wf, int ws)
26512666
{
26522667
return GuessServices.GetBestGuess(wf, ws);
@@ -2703,10 +2718,10 @@ internal class ParaDataUpdateTracker : InterlinViewCacheLoader
27032718
private HashSet<AnalysisOccurrence> m_annotationsChanged = new HashSet<AnalysisOccurrence>();
27042719
private HashSet<AnalysisOccurrence> m_annotationsUnchanged = new HashSet<AnalysisOccurrence>();
27052720
private AnalysisOccurrence m_currentAnnotation;
2706-
HashSet<int> m_analysesWithNewGuesses = new HashSet<int>();
2721+
HashSet<int> m_wordformsWithNewGuesses = new HashSet<int>();
27072722

2708-
public ParaDataUpdateTracker(AnalysisGuessServices guessServices, InterlinViewDataCache guessCache) :
2709-
base(guessServices, guessCache)
2723+
public ParaDataUpdateTracker(AnalysisGuessServices guessServices, InterlinViewDataCache guessCache, InterlinDocRootSiteBase rootSite) :
2724+
base(guessServices, guessCache, rootSite)
27102725
{
27112726
}
27122727

@@ -2716,9 +2731,9 @@ protected override void NoteCurrentAnnotation(AnalysisOccurrence occurrence)
27162731
base.NoteCurrentAnnotation(occurrence);
27172732
}
27182733

2719-
public void NoteChangedAnalysis(int hvo)
2734+
public void NoteChangedWordform(int hvo)
27202735
{
2721-
m_analysesWithNewGuesses.Add(hvo);
2736+
m_wordformsWithNewGuesses.Add(hvo);
27222737
}
27232738

27242739
private void MarkCurrentAnnotationAsChanged()
@@ -2739,7 +2754,7 @@ internal IList<AnalysisOccurrence> ChangedAnnotations
27392754
// Include occurrences that are unchanged but might add a yellow background.
27402755
foreach (var unchangedAnnotation in m_annotationsUnchanged)
27412756
{
2742-
if (m_analysesWithNewGuesses.Contains(unchangedAnnotation.Analysis.Hvo))
2757+
if (m_wordformsWithNewGuesses.Contains(unchangedAnnotation.Analysis.Wordform.Hvo))
27432758
{
27442759
m_annotationsChanged.Add(unchangedAnnotation);
27452760
}
@@ -2755,7 +2770,7 @@ protected override void SetObjProp(AnalysisOccurrence occurrence, int flid, int
27552770
{
27562771
base.SetObjProp(occurrence, flid, newObjValue);
27572772
m_annotationsChanged.Add(occurrence);
2758-
m_analysesWithNewGuesses.Add(occurrence.Analysis.Hvo);
2773+
m_wordformsWithNewGuesses.Add(occurrence.Analysis.Wordform.Hvo);
27592774
MarkCurrentAnnotationAsChanged();
27602775
}
27612776
else

Src/LexText/Morphology/ParserAnalysisRemover.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public void Process()
122122
m_dlg.ProgressBar.PerformStep();
123123
}
124124
});
125+
126+
// Interlin display may be affected.
127+
m_dlg.Mediator.SendMessage("RefreshInterlin", null);
125128
}
126129

127130
#endregion IUtility implementation

0 commit comments

Comments
 (0)