Convert MSC code Cleanup to Formatter#13233
Conversation
…to ktooltip updates from jabref main
…to ktooltip pulling changes from main to local
…iptions, bug: error when trying to cleanup when editor is open
…er and special characters were added
…rors in other files
…to ktooltip Pulling changes from main
koppor
left a comment
There was a problem hiding this comment.
Please revet changes in sub modules - see https://devdocs.jabref.org/code-howtos/faq.html#submodules
| return result.toString(); | ||
| } | ||
| // text contains comma separated codes | ||
| String[] codeList = result.toString().split(","); |
There was a problem hiding this comment.
Use org.jabref.model.entry.KeywordList#parse(java.lang.String, java.lang.Character, java.lang.Character) and then work on KeywordList
Reason: Better data structure and adheres to user configuration (keyword delimiter) and escpaings.
See at other usages of the parser and how to pass the prefernces
At first, I thought:
| String[] codeList = result.toString().split(","); | |
| String[] codeList = text.toString().split(","); |
but this is wrong, because no escaping treatment etc.
| this.actions = Objects.requireNonNull(actions); | ||
| } | ||
|
|
||
| public FieldFormatterCleanups(boolean enabled, List<FieldFormatterCleanup> actions, BibEntryPreferences preferences) { |
There was a problem hiding this comment.
Needs to be reviewed in IDE - why this general method is needed - until now, this was not needed - and the formatter worked.
There was a problem hiding this comment.
I had no way to retrieve BibEntryPreferences so that I could call getKeywordSeperator. This is used to inject preferences so that the formatter can use a dynamic delimiter.
If there is another method of retrieving BibEntryPreferences pleases lmk.
There was a problem hiding this comment.
Why is getInstance() deprecated for JabrefCLIPreferences Class? Isn't the point of this class to allow preferences to be accessible globally. @koppor
I feel like it defeats the purpose to implement a Singleton design that isn't easily accessible. 😅
There was a problem hiding this comment.
Preferences are indeed singleton but nonetheless you should avoid calling get instance as it creates a tight coupling between the two classes and hinders testing.
That's why you should pass or inject them via constructor so you can still mock them
There was a problem hiding this comment.
Thanks for clarifying. @Siedlerchr
That said, do you think my approach was correct?
Creating a new constructor for FieldFormatterCleanups
In JabrefCliPreferences, passing BibEntryPreferences to this constructor
Finally, passing those preferences down to the formatter to get the keyword separator.
There was a problem hiding this comment.
I think, in this case, it is OK to use Injector.instantiateModelOrService(CliPreferences.class) and then get your preferences for that.
Do this at the latest point in time - and do not initialize a default value ,
Note that you already have
Character dlim = preferences.getKeywordSeparator();
At this place, use this injector "magic".
Add a javadoc comment to the class that it relies to on Injector.instantiateModelOrService(CliPreferences.class), and add a reason. Maybe "because routing through this dependency causes too much changes."
|
@JustinHennis1 Could you try to revert the change in the sub module - see https://devdocs.jabref.org/code-howtos/faq.html#submodules Which git client did you use? Maybe, we can search for a bug report there and ask all developers of JabRef to give a +1 there. (the bug is that |
I'm using Git CMD on my Windows Laptop. I just merged main back into my fork, did that fix it? |
The diff doesn't show any changes, thus this worked :) |
👋 Hey, I completed the following:
|
* upstream/main: New Crowdin updates (JabRef#13330) Add arm 64 linux runner (JabRef#13258) Rename strings and variables in New Entry (JabRef#13312) Let consistency checker yield a return code (JabRef#13329) Update LETTER fragment to resolve Windows parsing issue (JabRef#13327) Add support for "dev: no-bot-comments" Update dependency org.hibernate.validator:hibernate-validator to v9.0.1.Final (JabRef#13322) Endnote XML Exporter: Move factory initialization to constructor (JabRef#13321) Refine assignment reminder (JabRef#13315) Add welcome message to first time contributors (JabRef#13314)
|
@trag-bot didn't find any issues in the code! ✅✨ |
Siedlerchr
left a comment
There was a problem hiding this comment.
Sorry for the delay. The PR got a bit under the radar due to so many new contributors.
Lgtm now
Pull Request is not mergeable



Closes #13227
Removed Cleanup functionality for MSC Code conversion. Added formatter at bottom of preset panel because formatters handle single-field conversion.
Screenshot Before
Screenshot After
Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)