Skip to content

LT-21757: Allow moving templates and slots up or down in Category hierarchy#270

Merged
jtmaxwell3 merged 19 commits intorelease/9.3from
LT-21757
Feb 26, 2025
Merged

LT-21757: Allow moving templates and slots up or down in Category hierarchy#270
jtmaxwell3 merged 19 commits intorelease/9.3from
LT-21757

Conversation

@jtmaxwell3
Copy link
Collaborator

@jtmaxwell3 jtmaxwell3 commented Feb 21, 2025

I added code to move affix templates and affix slots in the right-click menu of Template Name and Slot Name. Moving a template up will also move local slots up if it doesn't cause a conflict. Moving a template anywhere else will leave the slot in place, but will highlight the slot in the template if it is out of scope.

This is for release/9.3.


This change is Reviewable

Copy link
Contributor

@JakeOliver28 JakeOliver28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion


Src/Common/Controls/XMLViews/XmlVc.cs line 3892 at r1 (raw file):

			while (partOfSpeech != null)
			{
				foreach (IMoInflAffixSlot slot in partOfSpeech.AllAffixSlots)

We can eliminate this foreach loop with a FirstOrDefault. I think this would be simpler, quicker, and more readable.

Code snippet:

while (partOfSpeech != null)
{
    var matchingSlot = partOfSpeech.AllAffixSlots
        .FirstOrDefault(slot => slot.Name.BestAnalysisVernacularAlternative.Text == name);

    if (matchingSlot != null)
        return matchingSlot;

    partOfSpeech = partOfSpeech.Owner as IPartOfSpeech;
}

Copy link
Contributor

@JakeOliver28 JakeOliver28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 9 files reviewed, 3 unresolved discussions (waiting on @jtmaxwell3)


Src/xWorks/DTMenuHandler.cs line 624 at r1 (raw file):

			while (partOfSpeech != null)
			{
				foreach (IMoInflAffixSlot slot in partOfSpeech.AllAffixSlots)

And here. Should we consolidate these GetPOSSlot methods into one since they're identical? Guessing that might not be easily doable.


Src/LexText/ParserCore/HCLoader.cs line 1503 at r1 (raw file):

			while (partOfSpeech != null)
			{
				foreach (IMoInflAffixSlot slot in partOfSpeech.AllAffixSlots)

Same thing here.

@jtmaxwell3
Copy link
Collaborator Author

I find Linq-style code less readable than for loops so I only use it if the for loops are hard to read. In these cases, it is easy to see what the for loop is doing, so I don't think that this is worth changing.

XmlVc, DTMenuHandler, and HCLoader don't have an import in common within FieldWorks and aren't accessible to each other, so it isn't obvious where to put GetPOSSlot so that it can be shared.

Copy link
Contributor

@JakeOliver28 JakeOliver28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 0 of 9 files reviewed, 3 unresolved discussions (waiting on @jtmaxwell3)

@jtmaxwell3 jtmaxwell3 merged commit f68f7ee into release/9.3 Feb 26, 2025
4 of 5 checks passed
@jtmaxwell3 jtmaxwell3 deleted the LT-21757 branch February 26, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants