Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Nov 18, 2023
1 parent 2c409bb commit 6f151ec
Show file tree
Hide file tree
Showing 232 changed files with 2,004 additions and 5,925 deletions.
7 changes: 2 additions & 5 deletions src/jmh/java/org/jabref/benchmarks/Benchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public void init() throws Exception {
entry.setField(StandardField.TITLE, "This is my title " + i);
entry.setField(
StandardField.AUTHOR,
"Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" +
i
"Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i
);
entry.setField(StandardField.JOURNAL, "Journal Title " + i);
entry.setField(StandardField.KEYWORDS, "testkeyword");
Expand Down Expand Up @@ -100,9 +99,7 @@ private StringWriter getOutputWriter() throws IOException {

@Benchmark
public ParserResult parse() throws IOException {
BibtexParser parser = new BibtexParser(
Globals.prefs.getImportFormatPreferences()
);
BibtexParser parser = new BibtexParser(Globals.prefs.getImportFormatPreferences());
return parser.parse(new StringReader(bibtexString));
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
uses org.kordamp.ikonli.IkonHandler;
uses org.kordamp.ikonli.IkonProvider;

provides org.kordamp.ikonli.IkonHandler
with org.jabref.gui.icon.JabRefIkonHandler;
provides org.kordamp.ikonli.IkonProvider
with org.jabref.gui.icon.JabrefIconProvider;
provides org.kordamp.ikonli.IkonHandler with org.jabref.gui.icon.JabRefIkonHandler;
provides org.kordamp.ikonli.IkonProvider with org.jabref.gui.icon.JabrefIconProvider;

requires org.controlsfx.controls;
requires org.fxmisc.richtext;
Expand Down
240 changes: 57 additions & 183 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/main/java/org/jabref/cli/AuxCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public BibDatabase perform() {
AuxParserResult result = auxParser.parse(Path.of(auxFile));
subDatabase = result.getGeneratedBibDatabase();
// print statistics
System.out.println(
new AuxParserResultViewModel(result).getInformation(true)
);
System.out.println(new AuxParserResultViewModel(result).getInformation(true));
}
return subDatabase;
}
Expand Down
69 changes: 14 additions & 55 deletions src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,50 +199,30 @@ private static Options getOptions() {
"g",
"generateCitationKeys",
false,
Localization.lang(
"Regenerate all keys for the entries in a BibTeX file"
)
Localization.lang("Regenerate all keys for the entries in a BibTeX file")
);
options.addOption(
"b",
"blank",
false,
Localization.lang("Do not open any files at startup")
);
options.addOption(
"v",
"version",
false,
Localization.lang("Display version")
);
options.addOption(
null,
"debug",
false,
Localization.lang("Show debug level messages")
);
options.addOption("v", "version", false, Localization.lang("Display version"));
options.addOption(null, "debug", false, Localization.lang("Show debug level messages"));

// The "-console" option is handled by the install4j launcher
options.addOption(
null,
"console",
false,
Localization.lang(
"Show console output (only when the launcher is used)"
)
Localization.lang("Show console output (only when the launcher is used)")
);

options.addOption(
Option
.builder("i")
.longOpt("import")
.desc(
String.format(
"%s: '%s'",
Localization.lang("Import file"),
"-i library.bib"
)
)
.desc(String.format("%s: '%s'", Localization.lang("Import file"), "-i library.bib"))
.hasArg()
.argName("FILE[,FORMAT]")
.build()
Expand All @@ -252,11 +232,7 @@ private static Options getOptions() {
Option
.builder()
.longOpt("importToOpen")
.desc(
Localization.lang(
"Same as --import, but will be imported to the opened tab"
)
)
.desc(Localization.lang("Same as --import, but will be imported to the opened tab"))
.hasArg()
.argName("FILE[,FORMAT]")
.build()
Expand Down Expand Up @@ -397,16 +373,12 @@ private static Options getOptions() {
.desc(
String.format(
"%s: '%s'",
Localization.lang(
"Write BibTeXEntry as XMP metadata to PDF."
),
Localization.lang("Write BibTeXEntry as XMP metadata to PDF."),
"-w pathToMyOwnPaper.pdf"
)
)
.hasArg()
.argName(
"CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all"
)
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build()
);

Expand All @@ -422,9 +394,7 @@ private static Options getOptions() {
)
)
.hasArg()
.argName(
"CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all"
)
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build()
);

Expand All @@ -435,16 +405,12 @@ private static Options getOptions() {
.desc(
String.format(
"%s: '%s'",
Localization.lang(
"Write BibTeXEntry as metadata to PDF."
),
Localization.lang("Write BibTeXEntry as metadata to PDF."),
"-w pathToMyOwnPaper.pdf"
)
)
.hasArg()
.argName(
"CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all"
)
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build()
);

Expand All @@ -468,9 +434,7 @@ public static void printUsage(PreferencesService preferencesService) {
.stream()
.map(format -> new Pair<>(format.getName(), format.getId()))
.toList();
String importFormatsIntro = Localization.lang(
"Available import formats"
);
String importFormatsIntro = Localization.lang("Available import formats");
String importFormatsList = String.format(
"%s:%n%s%n",
importFormatsIntro,
Expand Down Expand Up @@ -523,9 +487,7 @@ protected static String alignStringTable(List<Pair<String, String>> table) {

int maxLength = table
.stream()
.mapToInt(pair ->
Objects.requireNonNullElse(pair.getKey(), "").length()
)
.mapToInt(pair -> Objects.requireNonNullElse(pair.getKey(), "").length())
.max()
.orElse(0);

Expand All @@ -547,10 +509,7 @@ protected static String alignStringTable(List<Pair<String, String>> table) {
/**
* Creates and wraps a multi-line and colon-seperated string from a List of Strings.
*/
protected static String wrapStringList(
List<String> list,
int firstLineIndentation
) {
protected static String wrapStringList(List<String> list, int firstLineIndentation) {
StringBuilder builder = new StringBuilder();
int lastBreak = -firstLineIndentation;

Expand Down
50 changes: 19 additions & 31 deletions src/main/java/org/jabref/cli/JournalListMvGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ public class JournalListMvGenerator {
public static void main(String[] args) throws IOException {
boolean verbose = (args.length == 1) && ("--verbose".equals(args[0]));

Path abbreviationsDirectory = Path.of(
"buildres",
"abbrv.jabref.org",
"journals"
);
Path abbreviationsDirectory = Path.of("buildres", "abbrv.jabref.org", "journals");
if (!Files.exists(abbreviationsDirectory)) {
System.out.println(
"Path " +
abbreviationsDirectory.toAbsolutePath() +
" does not exist"
"Path " + abbreviationsDirectory.toAbsolutePath() + " does not exist"
);
System.exit(0);
}
Expand Down Expand Up @@ -62,9 +56,7 @@ public static void main(String[] args) throws IOException {
.compressHigh()
.open()
) {
MVMap<String, Abbreviation> fullToAbbreviation = store.openMap(
"FullToAbbreviation"
);
MVMap<String, Abbreviation> fullToAbbreviation = store.openMap("FullToAbbreviation");
stream.forEach(
Unchecked.consumer(path -> {
String fileName = path.getFileName().toString();
Expand All @@ -75,27 +67,23 @@ public static void main(String[] args) throws IOException {
} else {
System.out.println("...");
Collection<Abbreviation> abbreviations =
JournalAbbreviationLoader.readAbbreviationsFromCsvFile(
path
);
Map<String, Abbreviation> abbreviationMap =
abbreviations
.stream()
.collect(
Collectors.toMap(
Abbreviation::getName,
abbreviation -> abbreviation,
(abbreviation1, abbreviation2) -> {
if (verbose) {
System.out.println(
"Double entry " +
abbreviation1.getName()
);
}
return abbreviation2;
JournalAbbreviationLoader.readAbbreviationsFromCsvFile(path);
Map<String, Abbreviation> abbreviationMap = abbreviations
.stream()
.collect(
Collectors.toMap(
Abbreviation::getName,
abbreviation -> abbreviation,
(abbreviation1, abbreviation2) -> {
if (verbose) {
System.out.println(
"Double entry " + abbreviation1.getName()
);
}
)
);
return abbreviation2;
}
)
);
fullToAbbreviation.putAll(abbreviationMap);
}
})
Expand Down
47 changes: 11 additions & 36 deletions src/main/java/org/jabref/cli/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,10 @@ public static void main(String[] args) {
Globals.entryTypesManager = entryTypesManager;

// Initialize preferences
final JabRefPreferences preferences =
JabRefPreferences.getInstance();
final JabRefPreferences preferences = JabRefPreferences.getInstance();

// Early exit in case another instance is already running
if (
!handleMultipleAppInstances(
ARGUMENTS,
preferences.getRemotePreferences()
)
) {
if (!handleMultipleAppInstances(ARGUMENTS, preferences.getRemotePreferences())) {
return;
}

Expand All @@ -88,8 +82,7 @@ public static void main(String[] args) {
clearOldSearchIndices();

try {
FileUpdateMonitor fileUpdateMonitor =
Globals.getFileUpdateMonitor();
FileUpdateMonitor fileUpdateMonitor = Globals.getFileUpdateMonitor();

// Process arguments
ArgumentProcessor argumentProcessor = new ArgumentProcessor(
Expand All @@ -101,9 +94,7 @@ public static void main(String[] args) {
);
argumentProcessor.processArguments();
if (argumentProcessor.shouldShutDown()) {
LOGGER.debug(
"JabRef shut down after processing command line arguments"
);
LOGGER.debug("JabRef shut down after processing command line arguments");
// A clean shutdown takes 60s time
// We don't need the clean shutdown here
System.exit(0);
Expand Down Expand Up @@ -161,9 +152,7 @@ private static void addLogToDisk() {

configuration
.entrySet()
.forEach(config ->
Configuration.set(config.getKey(), config.getValue())
);
.forEach(config -> Configuration.set(config.getKey(), config.getValue()));
initializeLogger();
}

Expand All @@ -177,9 +166,7 @@ private static boolean handleMultipleAppInstances(
) {
if (remotePreferences.useRemoteServer()) {
// Try to contact already running JabRef
RemoteClient remoteClient = new RemoteClient(
remotePreferences.getPort()
);
RemoteClient remoteClient = new RemoteClient(remotePreferences.getPort());
if (remoteClient.ping()) {
// We are not alone, there is already a server out there, send command line
// arguments to other instance
Expand All @@ -192,9 +179,7 @@ private static boolean handleMultipleAppInstances(
);
return false;
} else {
LOGGER.warn(
"Could not communicate with other running JabRef instance."
);
LOGGER.warn("Could not communicate with other running JabRef instance.");
}
}
}
Expand All @@ -210,17 +195,12 @@ private static void initGlobals(PreferencesService preferences) {

Globals.entryTypesManager = preferences.getCustomEntryTypesRepository();
Globals.protectedTermsLoader =
new ProtectedTermsLoader(
preferences.getProtectedTermsPreferences()
);
new ProtectedTermsLoader(preferences.getProtectedTermsPreferences());
}

private static void configureProxy(ProxyPreferences proxyPreferences) {
ProxyRegisterer.register(proxyPreferences);
if (
proxyPreferences.shouldUseProxy() &&
proxyPreferences.shouldUseAuthentication()
) {
if (proxyPreferences.shouldUseProxy() && proxyPreferences.shouldUseAuthentication()) {
Authenticator.setDefault(new ProxyAuthenticator());
}
}
Expand All @@ -232,9 +212,7 @@ private static void configureSSL(SSLPreferences sslPreferences) {
}

private static void clearOldSearchIndices() {
Path currentIndexPath = OS
.getNativeDesktop()
.getFulltextIndexBaseDirectory();
Path currentIndexPath = OS.getNativeDesktop().getFulltextIndexBaseDirectory();
Path appData = currentIndexPath.getParent();

try {
Expand All @@ -251,10 +229,7 @@ private static void clearOldSearchIndices() {
path.toString().contains("lucene") &&
!path.equals(currentIndexPath)
) {
LOGGER.info(
"Deleting out-of-date fulltext search index at {}.",
path
);
LOGGER.info("Deleting out-of-date fulltext search index at {}.", path);
Files
.walk(path)
.sorted(Comparator.reverseOrder())
Expand Down
Loading

0 comments on commit 6f151ec

Please sign in to comment.