Skip to content

Commit

Permalink
Merge branch 'release/9.1' into cross-thread
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOliver28 authored Nov 14, 2024
2 parents c220055 + 67cf893 commit 4fabbdd
Show file tree
Hide file tree
Showing 23 changed files with 328 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: NDP461-DevPack-KB3105179-ENU.exe /q

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
2.1.x
Expand Down
2 changes: 1 addition & 1 deletion Build/mkall.targets
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
<ParatextNugetVersion>9.4.0.1-beta</ParatextNugetVersion>
<LcmNugetVersion>11.0.0-beta0104</LcmNugetVersion>
<IcuNugetVersion>70.1.123</IcuNugetVersion>
<HermitCrabNugetVersion>3.4.1</HermitCrabNugetVersion>
<HermitCrabNugetVersion>3.4.2</HermitCrabNugetVersion>
<IPCFrameworkVersion>1.1.1-beta0001</IPCFrameworkVersion>
<!-- bt393 is the master branch build of ExCss for Windows development. Update when appropriate. -->
<ExCssBuildType Condition="'$(OS)'=='Windows_NT'">bt393</ExCssBuildType>
Expand Down
4 changes: 2 additions & 2 deletions Build/nuget-common/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<package id="SIL.libpalaso.l10ns" version="6.0.0" targetFramework="net461" />
<package id="SIL.Lift" version="13.0.0-beta0076" targetFramework="net461" />
<package id="SIL.Media" version="13.0.0-beta0076" targetFramework="net461" />
<package id="SIL.Machine" version="3.4.1" targetFramework="netstandard2.0" />
<package id="SIL.Machine.Morphology.HermitCrab" version="3.4.1" targetFramework="netstandard2.0" />
<package id="SIL.Machine" version="3.4.2" targetFramework="netstandard2.0" />
<package id="SIL.Machine.Morphology.HermitCrab" version="3.4.2" targetFramework="netstandard2.0" />
<package id="SIL.ParatextShared" version="7.4.0.1" targetFramework="net40" /> <!-- REVIEW (Hasso) 2023.05: do we still integrate with PT 7? -->
<package id="SIL.Scripture" version="13.0.0-beta0076" targetFramework="net461" />
<package id="SIL.TestUtilities" version="13.0.0-beta0076" targetFramework="net461" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@
</ComplexFormOptions>
<ReferenceItem>MainEntrySubentries</ReferenceItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" isEnabled="true" style="Dictionary-Pictures" before="" between=" " after="" field="PicturesOfSenses">
<ConfigurationItem name="Pictures" isEnabled="true" style="Dictionary-Pictures" before="" between="" after="" field="PicturesOfSenses">
<PictureOptions minimumHeight="0" maximumHeight="1" minimumWidth="0" maximumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" isEnabled="true" before=" " between=" " after="" field="PictureFileRA" cssClassNameOverride="thumbnail" />
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down Expand Up @@ -2113,7 +2113,7 @@
</ConfigurationItem>
<ConfigurationItem name="Date Created" isEnabled="false" before=" Created on: " after="" field="DateCreated" />
<ConfigurationItem name="Date Modified" isEnabled="false" before=" Modified on: " after="" field="DateModified" />
<ConfigurationItem name="Pictures" between=" " after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" maximumWidth="0" minimumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after="" isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down Expand Up @@ -3628,7 +3628,7 @@
</ConfigurationItem>
<ConfigurationItem name="Date Created" before=" Created on: " after="" isEnabled="false" field="DateCreated"/>
<ConfigurationItem name="Date Modified" before=" Modified on: " after="" isEnabled="false" field="DateModified"/>
<ConfigurationItem name="Pictures" between=" " after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" minimumWidth="0" maximumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after=" " isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@
</WritingSystemOptions>
</ConfigurationItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" before=" " between=" " after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" before="" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" minimumWidth="0" maximumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" before=" " isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down Expand Up @@ -1949,7 +1949,7 @@
</WritingSystemOptions>
</ConfigurationItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" between=" " after=" " style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" maximumWidth="0" minimumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after="" isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@
</ConfigurationItem>
</ConfigurationItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" between=" " after=" " style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" maximumWidth="0" minimumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after="" isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down Expand Up @@ -1919,7 +1919,7 @@
</WritingSystemOptions>
</ConfigurationItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" between=" " after=" " style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" maximumWidth="0" minimumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after="" isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down Expand Up @@ -2956,7 +2956,7 @@
</WritingSystemOptions>
</ConfigurationItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" between=" " after=" " style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" maximumWidth="0" minimumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after="" isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down Expand Up @@ -4405,7 +4405,7 @@
</ConfigurationItem>
</ConfigurationItem>
</ConfigurationItem>
<ConfigurationItem name="Pictures" between=" " after=" " style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<ConfigurationItem name="Pictures" between="" after="" style="Dictionary-Pictures" isEnabled="true" field="PicturesOfSenses" cssClassNameOverride="pictures">
<PictureOptions minimumHeight="0" maximumHeight="1" minimumWidth="0" maximumWidth="0" pictureLocation="right" stackPictures="false" />
<ConfigurationItem name="Thumbnail" after="" isEnabled="true" field="PictureFileRA" cssClassNameOverride="thumbnail"/>
<ConfigurationItem name="Caption (or Headword)" between=" " isEnabled="false" field="CaptionOrHeadword">
Expand Down
3 changes: 0 additions & 3 deletions Src/LexText/ParserCore/ParseFiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ private bool UpdateWordforms(object parameter)
if (work.CheckParser)
{
// This was just a test. Don't update data.
string testform = work.Wordform.Form.BestVernacularAlternative.Text;
using (new TaskReport(String.Format(ParserCoreStrings.ksTestX, testform), m_taskUpdateHandler))
{ }
FireWordformUpdated(work.Wordform, work.Priority, work.ParseResult, work.CheckParser);
continue;
}
Expand Down
18 changes: 9 additions & 9 deletions Src/LexText/ParserCore/ParserCoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Src/LexText/ParserCore/ParserCoreStrings.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -186,8 +186,8 @@
<data name="ksUnknownNaturalClass" xml:space="preserve">
<value>Unknown Natural Class!</value>
</data>
<data name="ksTestX" xml:space="preserve">
<value>Tested {0}</value>
<data name="ksParsingX" xml:space="preserve">
<value>Parsing {0}</value>
</data>
<data name="ksMaxElementsInRule" xml:space="preserve">
<value>A rule can't have more than one element in its left-hand side or its right-hand side.</value>
Expand Down
12 changes: 10 additions & 2 deletions Src/LexText/ParserCore/ParserWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ public bool UpdateWordform(IWfiWordform wordform, ParserPriority priority, bool
CheckNeedsUpdate();
var normalizer = CustomIcu.GetIcuNormalizer(FwNormalizationMode.knmNFD);
var word = normalizer.Normalize(form.Text.Replace(' ', '.'));
ParseResult result = null;
var stopWatch = System.Diagnostics.Stopwatch.StartNew();
ParseResult result = m_parser.ParseWord(word);
using (var task = new TaskReport(String.Format(ParserCoreStrings.ksParsingX, word), m_taskUpdateHandler))
{
result = m_parser.ParseWord(word);
}
stopWatch.Stop();
result.ParseTime = stopWatch.ElapsedMilliseconds;

Expand All @@ -160,8 +164,12 @@ public bool UpdateWordform(IWfiWordform wordform, ParserPriority priority, bool
if (m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>().TryGetObject(text, out lcWordform))
{
var lcWord = normalizer.Normalize(sLower.Replace(' ', '.'));
ParseResult lcResult = null;
stopWatch.Start();
var lcResult = m_parser.ParseWord(lcWord);
using (var task = new TaskReport(String.Format(ParserCoreStrings.ksParsingX, word), m_taskUpdateHandler))
{
lcResult = m_parser.ParseWord(lcWord);
}
stopWatch.Stop();
lcResult.ParseTime = stopWatch.ElapsedMilliseconds;
if (lcResult.Analyses.Count > 0 && lcResult.ErrorMessage == null)
Expand Down
2 changes: 2 additions & 0 deletions Src/XCore/xWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,8 @@ public bool OnCloseWindow(object sender)
{
CheckDisposed();

if (Mediator != null)
Mediator.SendMessage("StopParser", null);
this.Close();

return true;
Expand Down
5 changes: 3 additions & 2 deletions Src/xWorks/ConfigurableDictionaryNode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2017 SIL International
// Copyright (c) 2014-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 @@ -334,7 +334,8 @@ internal ConfigurableDictionaryNode DeepCloneUnderParent(ConfigurableDictionaryN

public override int GetHashCode()
{
return Parent == null ? DisplayLabel.GetHashCode() : DisplayLabel.GetHashCode() ^ Parent.GetHashCode();
object hashingObject = DisplayLabel ?? FieldDescription;
return Parent == null ? hashingObject.GetHashCode() : hashingObject.GetHashCode() ^ Parent.GetHashCode();
}

public override bool Equals(object other)
Expand Down
68 changes: 21 additions & 47 deletions Src/xWorks/DictionaryConfigurationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,14 +1558,12 @@ private static void SetIsEnabledForSubTree(ConfigurableDictionaryNode node, bool
}

/// <summary>
/// Search the TreeNode tree to find a starting node based on matching the "class"
/// attributes of the generated XHTML tracing back from the XHTML element clicked.
/// If no match is found, SelectedNode is not set. Otherwise, the best match found
/// is used to set SelectedNode.
/// Search the TreeNode tree to find a starting node based on nodeId attribute - a hash of a ConfigurableDictionaryNode
/// generated into the xhtml. If nothing is found SelectedNode is not set.
/// </summary>
internal void SetStartingNode(List<string> classList)
internal void SetStartingNode(string nodeId)
{
if (classList == null || classList.Count == 0)
if (string.IsNullOrEmpty(nodeId))
return;
if (View != null &&
View.TreeControl != null &&
Expand All @@ -1579,22 +1577,15 @@ internal void SetStartingNode(List<string> classList)
var configNode = node.Tag as ConfigurableDictionaryNode;
if (configNode == null)
continue;
var cssClass = CssGenerator.GetClassAttributeForConfig(configNode);
if (classList[0].Split(' ').Contains(cssClass))
topNode = FindConfigNode(configNode, nodeId, new List<ConfigurableDictionaryNode>());
if (topNode != null)
{
topNode = configNode;
break;
}
}
if (topNode == null)
return;
// We have a match, so search through the TreeNode tree to find the TreeNode tagged
// with the given configuration node. If found, set that as the SelectedNode.
classList.RemoveAt(0);
var startingConfigNode = FindConfigNode(topNode, classList);
foreach (TreeNode node in View.TreeControl.Tree.Nodes)
{
var startingTreeNode = FindMatchingTreeNode(node, startingConfigNode);
var startingTreeNode = FindMatchingTreeNode(node, topNode);
if (startingTreeNode != null)
{
View.TreeControl.Tree.SelectedNode = startingTreeNode;
Expand All @@ -1605,48 +1596,31 @@ internal void SetStartingNode(List<string> classList)
}

/// <summary>
/// Recursively descend the configuration tree, progressively matching nodes against CSS class path. Stop
/// when we run out of both tree and classes. Classes can be skipped if not matched. Running out of tree nodes
/// before running out of classes causes one level of backtracking up the configuration tree to look for a better match.
/// Recursively descend the configuration tree depth first until a matching nodeId is found
/// </summary>
/// <remarks>LT-17213 Now 'internal static' so DictionaryConfigurationDlg can use it.</remarks>
internal static ConfigurableDictionaryNode FindConfigNode(ConfigurableDictionaryNode topNode, List<string> classPath)
internal static ConfigurableDictionaryNode FindConfigNode(ConfigurableDictionaryNode topNode, string nodeId, List<ConfigurableDictionaryNode> visited)
{
if (classPath.Count == 0)
if (string.IsNullOrEmpty(nodeId) || $"{topNode.GetHashCode()}".Equals(nodeId))
{
return topNode; // what we have already is the best we can find.
}
visited.Add(topNode);

// If we can't go further down the configuration tree, but still have classes to match, back up one level
// and try matching with the remaining classes. The configuration tree doesn't always map exactly with
// the XHTML tree structure. For instance, in the XHTML, Examples contains instances of Example, each
// of which contains an instance of Translations, which contains instances of Translation. In the configuration
// tree, Examples contains Example and Translations at the same level.
if (topNode.ReferencedOrDirectChildren == null || topNode.ReferencedOrDirectChildren.Count == 0)
{
var match = FindConfigNode(topNode.Parent, classPath);
return ReferenceEquals(match, topNode.Parent)
? topNode // this is the best we can find.
: match; // we found something better!
}
ConfigurableDictionaryNode matchingNode = null;
foreach (var node in topNode.ReferencedOrDirectChildren)
if (topNode.ReferencedOrDirectChildren != null)
{
var cssClass = CssGenerator.GetClassAttributeForConfig(node);
// LT-17359 a reference node might have "senses mainentrysubsenses"
if (cssClass == classPath[0].Split(' ')[0])
foreach (var node in topNode.ReferencedOrDirectChildren)
{
matchingNode = node;
break;
if (visited.Contains(node))
continue;
var match = FindConfigNode(node, nodeId, visited);
if (match != null)
{
return match;
}
}
}
// If we didn't match, skip this class in the list and try the next class, looking at the same configuration
// node. There are classes in the XHTML that aren't represented in the configuration nodes. ("sensecontent"
// and "sense" among others)
if (matchingNode == null)
matchingNode = topNode;
classPath.RemoveAt(0);
return FindConfigNode(matchingNode, classPath);
return null;
}

/// <summary>
Expand Down
17 changes: 1 addition & 16 deletions Src/xWorks/DictionaryConfigurationDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,28 +230,13 @@ private static ConfigurableDictionaryNode GetTopLevelNode(ConfigurableDictionary
return childNode;
}

private static bool DoesGeckoElementOriginateFromConfigNode(ConfigurableDictionaryNode configNode, GeckoElement element,
ConfigurableDictionaryNode topLevelNode)
{
Guid dummyGuid;
GeckoElement dummyElement;
var classListForGeckoElement = XhtmlDocView.GetClassListFromGeckoElement(element, out dummyGuid, out dummyElement);
classListForGeckoElement.RemoveAt(0); // don't need the top level class
var nodeToMatch = DictionaryConfigurationController.FindConfigNode(topLevelNode, classListForGeckoElement);
return Equals(nodeToMatch, configNode);
}

private static IEnumerable<GeckoElement> FindMatchingSpans(ConfigurableDictionaryNode selectedNode, GeckoElement parent,
ConfigurableDictionaryNode topLevelNode, LcmCache cache)
{
var elements = new List<GeckoElement>();
var desiredClass = CssGenerator.GetClassAttributeForConfig(selectedNode);
if (ConfiguredLcmGenerator.IsCollectionNode(selectedNode, cache))
desiredClass = CssGenerator.GetClassAttributeForCollectionItem(selectedNode);
foreach (var span in parent.GetElementsByTagName("span"))
{
if (span.GetAttribute("class") != null && span.GetAttribute("class").Split(' ')[0] == desiredClass &&
DoesGeckoElementOriginateFromConfigNode(selectedNode, span, topLevelNode))
if (span.GetAttribute("nodeId") != null && span.GetAttribute("nodeId").Equals($"{selectedNode.GetHashCode()}"))
{
elements.Add(span);
}
Expand Down
Loading

0 comments on commit 4fabbdd

Please sign in to comment.