diff --git a/.jbang/CheckoutPR.java b/.jbang/CheckoutPR.java old mode 100644 new mode 100755 index 98801f5b4e8..c5979d22ada --- a/.jbang/CheckoutPR.java +++ b/.jbang/CheckoutPR.java @@ -1,3 +1,5 @@ +////usr/bin/env jbang "$0" "$@" ; exit $? + import java.io.File; import java.util.List; import java.util.Optional; @@ -15,8 +17,6 @@ import org.kohsuke.github.GitHubBuilder; import org.kohsuke.github.PagedIterator; -///usr/bin/env jbang "$0" "$@" ; exit $? - //JAVA 21+ //RUNTIME_OPTIONS --enable-native-access=ALL-UNNAMED @@ -62,7 +62,7 @@ public static void main(String[] args) throws Exception { while (prIterator.hasNext()) { pr = prIterator.next(); if ((contributor.isEmpty() || pr.getHead().getUser().getLogin().equals(contributor)) && - pr.getHead().getRef().equals(branchName)) { + pr.getHead().getRef().equals(branchName)) { found = true; System.out.println("Found pull request #" + pr.getNumber()); break; @@ -165,9 +165,9 @@ private static void checkoutUpstreamMain() throws Exception { // Check if a remote pointing to JabRef/jabref already exists List remotes = git.remoteList().call(); Optional jabrefRemote = remotes.stream() - // We use "contains", because there could be SSH remote URLs - .filter(r -> r.getURIs().stream().anyMatch(uri -> uri.toString().contains("JabRef/jabref"))) - .findFirst(); + // We use "contains", because there could be SSH remote URLs + .filter(r -> r.getURIs().stream().anyMatch(uri -> uri.toString().contains("JabRef/jabref"))) + .findFirst(); String remoteToUse; if (jabrefRemote.isPresent()) { @@ -176,9 +176,9 @@ private static void checkoutUpstreamMain() throws Exception { } else { System.out.println("Adding remote 'upstream' pointing to " + jabrefRepoUrl); git.remoteAdd() - .setName(upstreamName) - .setUri(new URIish(jabrefRepoUrl)) - .call(); + .setName(upstreamName) + .setUri(new URIish(jabrefRepoUrl)) + .call(); remoteToUse = upstreamName; } diff --git a/.jbang/CloneJabRef.java b/.jbang/CloneJabRef.java old mode 100644 new mode 100755 index 4b6fbb0e047..830787f8327 --- a/.jbang/CloneJabRef.java +++ b/.jbang/CloneJabRef.java @@ -1,8 +1,8 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? + import java.nio.file.Files; import java.nio.file.Path; -///usr/bin/env jbang "$0" "$@" ; exit $? - //JAVA 21+ //RUNTIME_OPTIONS --enable-native-access=ALL-UNNAMED diff --git a/.jbang/JabKitLauncher.java b/.jbang/JabKitLauncher.java old mode 100644 new mode 100755 diff --git a/.jbang/JabLsLauncher.java b/.jbang/JabLsLauncher.java old mode 100644 new mode 100755 diff --git a/.jbang/JabSrvLauncher.java b/.jbang/JabSrvLauncher.java old mode 100644 new mode 100755 diff --git a/jablib/src/main/java/org/jabref/logic/ai/summarization/GenerateSummaryTask.java b/jablib/src/main/java/org/jabref/logic/ai/summarization/GenerateSummaryTask.java index 55d84187e91..72a8e4b94fc 100644 --- a/jablib/src/main/java/org/jabref/logic/ai/summarization/GenerateSummaryTask.java +++ b/jablib/src/main/java/org/jabref/logic/ai/summarization/GenerateSummaryTask.java @@ -208,7 +208,9 @@ public String summarizeOneDocument(String filePath, String document) throws Inte int passes = 0; + // @formatter:off do { + // @formatter:on passes++; LOGGER.debug("Summarizing chunk(s) for file \"{}\" of entry {} ({} pass)", filePath, citationKey, passes); diff --git a/jablib/src/main/java/org/jabref/logic/bst/BstFunctions.java b/jablib/src/main/java/org/jabref/logic/bst/BstFunctions.java index b24c34d6460..843fd38eb38 100644 --- a/jablib/src/main/java/org/jabref/logic/bst/BstFunctions.java +++ b/jablib/src/main/java/org/jabref/logic/bst/BstFunctions.java @@ -895,7 +895,9 @@ private void bstWhile(BstVMVisitor visitor, ParserRuleContext ctx) { throw new BstVMException("Expecting two functions for while$ (line %d)".formatted(ctx.start.getLine())); } + // @formatter:off do { + // @formatter:on visitor.visit((ParseTree) f1); Object i = stack.pop(); diff --git a/jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java b/jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java index 2e091d568dd..ee07e34ad01 100644 --- a/jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java +++ b/jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java @@ -135,7 +135,9 @@ private String appendLettersToKey(String key, String oldKey) { int number = !alwaysAddLetter && !firstLetterA ? 1 : 0; String moddedKey; + // @formatter:off do { + // @formatter:on moddedKey = key + getAppendix(number); number++; diff --git a/jablib/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java b/jablib/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java index 7787f415871..52d85934c90 100644 --- a/jablib/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java +++ b/jablib/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java @@ -136,7 +136,9 @@ private GetTargetPathResult getTargetPath(Path sourcePath, Path targetDirectory, } Integer count = 1; boolean exists = false; + // @formatter:off do { + // @formatter:on targetPath = targetDirectory.resolve(sourcePath.getFileName() + " (" + count + ")"); exists = Files.exists(targetPath); if (exists && Files.mismatch(sourcePath, targetPath) == -1) { diff --git a/jablib/src/main/java/org/jabref/logic/formatter/casechanger/UnprotectTermsFormatter.java b/jablib/src/main/java/org/jabref/logic/formatter/casechanger/UnprotectTermsFormatter.java index cc2d5ab2096..d6dac214c65 100644 --- a/jablib/src/main/java/org/jabref/logic/formatter/casechanger/UnprotectTermsFormatter.java +++ b/jablib/src/main/java/org/jabref/logic/formatter/casechanger/UnprotectTermsFormatter.java @@ -22,7 +22,9 @@ public String format(String text) { StringBuilder result = new StringBuilder(); int level = 0; int index = 0; + // @formatter:off do { + // @formatter:on char charAtIndex = text.charAt(index); if (charAtIndex == '{') { level++; diff --git a/jablib/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/jablib/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index 86a38f69ca8..c933b9f9304 100644 --- a/jablib/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/jablib/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -192,7 +192,9 @@ private String determineNewLineSeparator() throws IOException { StringWriter stringWriter = new StringWriter(BibtexParser.LOOKAHEAD); int i = 0; int currentChar; + // @formatter:off do { + // @formatter:on currentChar = pushbackReader.read(); stringWriter.append((char) currentChar); i++; @@ -887,7 +889,9 @@ private String fixKey() throws IOException { char currentChar; // Find a char which ends key (','&&'\n') or entryfield ('='): + // @formatter:off do { + // @formatter:on currentChar = (char) read(); key.append(currentChar); lookaheadUsed++; @@ -1173,7 +1177,9 @@ private void consume(char expected) throws IOException { private boolean consumeUncritically(char expected) throws IOException { int character; + // @formatter:off do { + // @formatter:on character = read(); } while ((character != expected) && (character != -1) && (character != 65535)); diff --git a/jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java b/jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java index d848c3725d6..1765085fdc9 100644 --- a/jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java +++ b/jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java @@ -137,7 +137,9 @@ private String streamlineNames(String names) { boolean isFirst = true; int i = 0; res = ""; + // @formatter:off do { + // @formatter:on if (workedOnFirstOrMiddle) { // last item was a first or a middle name // we have to check whether we are on a middle name diff --git a/jablib/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java b/jablib/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java index 24896f997ad..f7c10027422 100644 --- a/jablib/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java +++ b/jablib/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java @@ -32,7 +32,9 @@ public INSPIREBibtexFilterReader(final Reader initialReader) { private String readpreLine() throws IOException { String l; + // @formatter:off do { + // @formatter:on l = inReader.readLine(); if (l == null) { return null; diff --git a/jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java b/jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java index e8812235435..c0aeae77bd4 100644 --- a/jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java +++ b/jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java @@ -9,69 +9,62 @@ import org.jabref.logic.layout.LayoutFormatter; import org.jabref.model.entry.AuthorList; -/** - * This layout formatter uses the Bibtex name.format$ method and provides ultimate flexibility: - * - * The formatter needs a parameter to be passed in that follows the following format: - * - * <case1>@<range11>@"<format>"@<range12>@"<format>"@<range13>...@@ - * - * <case2>@<range21>@... and so on. - * - * Individual cases are separated by @@ and items in a case by @. - * - * Cases are just integers or the character * and will tell the formatter to apply the following formats if there are - * less or equal authors given to it. The cases must be in strict increasing order with the * in the last position. - * - * For instance: - * - * case1 = 2 - * case2 = 3 - * case3 = * - * - * Ranges are either <integer>..<integer>, <integer> or the character * using a 1 based index for indexing - * authors from the given authorlist. Integer indexes can be negative to denote them to start from - * the end of the list where -1 is the last author. - * - * For instance with an authorlist of "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay": - * - * 1..3 will affect Joe, Mary and Bruce - * - * 4..4 will affect Arthur - * - * * will affect all of them - * - * 2..-1 will affect Mary, Bruce and Arthur - * - * The <format> uses the Bibtex formatter format: - * - * The four letter v, f, l, j indicate the name parts von, first, last, jr which - * are used within curly braces. A single letter v, f, l, j indicates that the name should be abbreviated. - * To put a quote in the format string quote it using \" (mh. this doesn't work yet) - * - * I give some examples but would rather point you to the bibtex documentation. - * - * "{ll}, {f}." Will turn "Joe Doe" into "Doe, J." - * - * Complete example: - * - * To turn: - * - * "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay" - * - * into - * - * "Doe, J., Jane, M., Bar, B. and Kay, A." - * - * you would use - * - * 1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, {f}. - * - * Yeah this is trouble-some to write, but should work. - * - * For more examples see the test-cases. - * - */ +/// This layout formatter uses the BibTeX `name.format$` method and provides ultimate flexibility. +/// +/// The formatter needs a parameter with the following format: +/// +/// ``` +/// @@""@@""@...@@ +/// @@... +///``` +/// +/// Individual cases are separated by `@@` and items in a case by `@`. +/// +/// Cases are just integers or the character `*` and tell the formatter to apply the following formats +/// if there are less or equal authors given. +/// The cases must be in strictly increasing order with `*` in the last position. +/// +/// Example: +/// - `case1 = 2` +/// - `case2 = 3` +/// - `case3 = *` +/// +/// Ranges are either `..`, `` or `*` (using a 1-based index). +/// Negative integers start from the end (`-1` = last author). +/// +/// Example with `Joe Doe and Mary Jane and Bruce Bar and Arthur Kay`: +/// - `1..3` → Joe, Mary, Bruce +/// - `4..4` → Arthur +/// - `*` → all authors +/// - `2..-1` → Mary, Bruce, Arthur +/// +/// The `` uses the BibTeX formatter syntax: +/// - The letters `v`, `f`, `l`, `j` indicate name parts (von, first, last, jr). Use them inside `{}` for full form. +/// - A single letter (`v`, `f`, `l`, `j`) abbreviates the part. +/// - Quotes must be escaped as `\"` (not fully supported yet). +/// +/// Example: +/// - `"{ll},{f}."` → `"Joe Doe"` becomes `"Doe, J."` +/// +/// Complete example: +/// +/// Input: +/// ``` +/// Joe Doe and Mary Jane and Bruce Bar and Arthur Kay +///``` +/// +/// Output: +/// ``` +/// Doe, J., Jane, M., Bar, B. and Kay, A. +///``` +/// +/// Formatter parameter: +/// ``` +/// 1@*@{ll},{f}.@@2@1@{ll},{f}.@2@ and {ll},{f}.@@*@1..-3@{ll},{f}., @-2@{ll},{f}.@-1@ and {ll},{f}. +///``` +/// +/// This is troublesome to write, but it works. +/// For more examples see the test cases. public class NameFormatter implements LayoutFormatter { public static final String DEFAULT_FORMAT = "1@*@{ff }{vv }{ll}{, jj}@@*@1@{ff }{vv }{ll}{, jj}@*@, {ff }{vv }{ll}{, jj}"; diff --git a/jablib/src/main/java/org/jabref/logic/net/URLDownload.java b/jablib/src/main/java/org/jabref/logic/net/URLDownload.java index 7eff72b29ef..0ddfe1dffb0 100644 --- a/jablib/src/main/java/org/jabref/logic/net/URLDownload.java +++ b/jablib/src/main/java/org/jabref/logic/net/URLDownload.java @@ -121,7 +121,9 @@ public Optional getMimeType() { try { String urlToCheck = source.toString(); String locationHeader; + // @formatter:off do { + // @formatter:on retries++; HttpResponse response = Unirest.head(urlToCheck).asString(); // Check if we have redirects, e.g. arxiv will give otherwise content type html for the original url