Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .jbang/CheckoutPR.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
////usr/bin/env jbang "$0" "$@" ; exit $?

import java.io.File;
import java.util.List;
import java.util.Optional;
Expand All @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -165,9 +165,9 @@ private static void checkoutUpstreamMain() throws Exception {
// Check if a remote pointing to JabRef/jabref already exists
List<RemoteConfig> remotes = git.remoteList().call();
Optional<RemoteConfig> 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Eclipse did this I was hit by Olly and others to revert this...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koppor does this need revert?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - when touching the code, we can move remotes.stream() to the next line to have the dots properly aligned.

.filter(r -> r.getURIs().stream().anyMatch(uri -> uri.toString().contains("JabRef/jabref")))
.findFirst();

String remoteToUse;
if (jabrefRemote.isPresent()) {
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions .jbang/CloneJabRef.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Empty file modified .jbang/JabKitLauncher.java
100644 → 100755
Empty file.
Empty file modified .jbang/JabLsLauncher.java
100644 → 100755
Empty file.
Empty file modified .jbang/JabSrvLauncher.java
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions jablib/src/main/java/org/jabref/logic/bst/BstFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
119 changes: 56 additions & 63 deletions jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
* <code>&lt;case1>@&lt;range11>@"&lt;format>"@&lt;range12>@"&lt;format>"@&lt;range13>...@@
*
* &lt;case2>@&lt;range21>@...</code> 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 &lt;integer>..&lt;integer>, &lt;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 &lt;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:
///
/// ```
/// <case1>@<range11>@"<format>"@<range12>@"<format>"@<range13>...@@
/// <case2>@<range21>@...
///```
///
/// 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 `<integer>..<integer>`, `<integer>` 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 `<format>` 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}";
Expand Down
2 changes: 2 additions & 0 deletions jablib/src/main/java/org/jabref/logic/net/URLDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ public Optional<String> getMimeType() {
try {
String urlToCheck = source.toString();
String locationHeader;
// @formatter:off
do {
// @formatter:on
retries++;
HttpResponse<String> response = Unirest.head(urlToCheck).asString();
// Check if we have redirects, e.g. arxiv will give otherwise content type html for the original url
Expand Down
Loading