fix(eda): inherit KiCad reference prefix from ancestor categories - #1547
Open
wangzhengzhuo05 wants to merge 1 commit into
Open
wangzhengzhuo05 wants to merge 1 commit into
wangzhengzhuo05 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1547 +/- ##
=========================================
Coverage 62.40% 62.40%
- Complexity 9879 9886 +7
=========================================
Files 736 736
Lines 31782 31795 +13
=========================================
+ Hits 19832 19842 +10
- Misses 11950 11953 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A part in a nested EDA category did not inherit the
Reference Prefixof an ancestor category.KiCadHelper::getKiCADPart()only consulted the part's own EDA info and then its immediatecategory, so in the tree below a part placed from
D-subgot refdesU?instead ofJ?:Why
src/Services/EDA/KiCadHelper.php:214resolved the prefix aspart->edaInfo->prefix ?? part->category->edaInfo->prefix ?? 'U'— the category lookup wassingle-level, so any deeper category lost the inherited prefix. Per #1535 the prefix should be
inherited from the next highest category that defines one.
How
Added a private
getReferencePrefix(Part $part)helper and used it for thereferencefield:that defines a non-empty prefix wins;
nulland''count as "not set", so a blank prefix field inherits (the reported case);'U'fallback is unchanged when nothing in the chain defines a prefix;in
AbstractStructuralDBElement.Only the
referencefield is affected — the other EDA fields and the visibility checks areuntouched.
Tests
Four new tests in
tests/Services/EDA/KiCadHelperTest.php:testReferencePrefixIsInheritedFromAncestorCategory— part blank,D-subblank, parentConnectors=J->JtestNearestCategoryWithPrefixWins—D-sub=X, parentConnectors=J->XtestPartReferencePrefixOverridesCategory— part =C, parentConnectors=J->CtestReferencePrefixFallsBackToUWhenNothingIsSet— nothing set ->UMutation check
Restoring line 214 to the previous single-level lookup (leaving the new tests in place) makes the
regression test fail with exactly the reported symptom, then reverting the mutation goes green:
Fixes #1535