-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Convert MSC code Cleanup to Formatter #13233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
@koppor I think it's ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revet changes in sub modules - see https://devdocs.jabref.org/code-howtos/faq.html#submodules
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
return result.toString(); | ||
} | ||
// text contains comma separated codes | ||
String[] codeList = result.toString().split(","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java
Outdated
Show resolved
Hide resolved
@@ -87,6 +90,13 @@ public FieldFormatterCleanups(boolean enabled, List<FieldFormatterCleanup> actio | |||
this.actions = Objects.requireNonNull(actions); | |||
} | |||
|
|||
public FieldFormatterCleanups(boolean enabled, List<FieldFormatterCleanup> actions, BibEntryPreferences preferences) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 :) |
jablib/src/test/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatterTest.java
Show resolved
Hide resolved
👋 Hey, I completed the following:
|
@trag-bot didn't find any issues in the code! ✅✨ |
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.md
described in a way that is understandable for the average user (if change is visible to the user)