Add cursor area awareness to CSL citations#15728
Conversation
Review Summary by QodoAdd cursor area awareness to CSL citations
WalkthroughsDescription• Add cursor area awareness to CSL citations • Implement CSLCitationRanges() method for CSL style detection • Refactor citationRanges() to JStyleCitationRanges() for clarity • Pass OOStyle parameter to overlap checking logic Diagramflowchart LR
A["checkRangeOverlapsWithCursor"] -->|receives OOStyle| B["Style type check"]
B -->|JStyle| C["JStyleCitationRanges"]
B -->|CSL| D["CSLCitationRanges"]
C -->|returns ranges| E["Overlap detection"]
D -->|returns ranges| E
E -->|prevents cursor| F["Protected citation areas"]
File Changes1. jabgui/src/main/java/org/jabref/gui/openoffice/OOBibBase.java
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Looks good!
As a result of this, I think you have already started seeing the code unification that can be achieved eventually when we refactor in future, due to functional unifications like these. The split style-specific checkers will reduce to one function once we unify the backend.
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Thank you, that looks better! |
Do you mean after "unification", originally separated functions would be unified into one function? Similar to : |
Yes - think of it this way. The functionality is the same - there is a range of citation marker to be guarded, irrespective of it being a CSL or JStyle. So eventually this if-else can be let go of, and just one function can embed common logic with respect to either a style interface (which covers both style types, think OOStyle), or maybe even not be dependent on the style parameter at all anymore. |
|
|
||
| /// @return A RangeForOverlapCheck for each citation group. result.size() == nRefMarks | ||
| public List<RangeForOverlapCheck<CitationGroupId>> citationRanges(XTextDocument doc) | ||
| public List<RangeForOverlapCheck<CitationGroupId>> JStyleCitationRanges(XTextDocument doc) |
| return result; | ||
| } | ||
|
|
||
| private List<RangeForOverlapCheck<CitationGroupId>> CSLCitationRanges(XTextDocument doc) |
There was a problem hiding this comment.
I think then cslCitationRanges would be better than cSLCitationRanges, in terms of readability.
There was a problem hiding this comment.
yep cslCitationRanges would be fine
There was a problem hiding this comment.
even better if it can be an action verb instead of a noun. Maybe just add a "get" in front
|
Is the qodo concern valid? Do we check if it's a CSL or jstyle mark or will it check all kind of marks? |
No, JabRef does not check the citation style. Maybe we can add a filter in |
Related issues and pull requests
Closes #15701
PR Description
This PR adds a new function
CSLCitationRangeswhich collects the ranges of existing CSL citations, so that CSL citations can also have cursor area awareness.Steps to test
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)