Make sure formatting is applied to std-bits projects (#3477)

@radeusgd discovered that no formatting was being applied to std-bits projects.
This was caused by the fact that `enso` project didn't aggregate them. Compilation and
packaging still worked because one relied on the output of some tasks but
```
sbt> javafmtAll
```
didn't apply it to `std-bits`.

# Important Notes
Apart from `build.sbt` no manual changes were made.
This commit is contained in:
Hubert Plociniczak 2022-05-25 11:26:50 +02:00 committed by GitHub
parent f5f6d264dd
commit 4918ccb5a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 171 additions and 160 deletions

View File

@ -273,7 +273,12 @@ lazy val enso = (project in file("."))
`library-manager-test`,
`connected-lock-manager`,
syntax.jvm,
testkit
testkit,
`std-base`,
`std-database`,
`std-google-api`,
`std-image`,
`std-table`
)
.settings(Global / concurrentRestrictions += Tags.exclusive(Exclusive))
.settings(

View File

@ -40,7 +40,7 @@ public @interface Builtin {
@interface WrapException {
/** @return Class of the potential exception to be caught during the execution of the method */
Class<? extends Exception> from();
/** @return Class of Enso's builtin (error) type * */
/** @return Class of Enso's builtin (error) type */
Class<?> to();
}

View File

@ -9,13 +9,14 @@ import java.util.function.BiFunction;
public class ObjectComparator implements Comparator<Object> {
private static ObjectComparator INSTANCE;
/***
/**
* A singleton instance of an ObjectComparator
* @param fallbackComparator this MUST be the default .compare_to function for Enso. Needs to be passed to allow calling back from Java.
*
* @param fallbackComparator this MUST be the default .compare_to function for Enso. Needs to be
* passed to allow calling back from Java.
* @return Comparator object
*/
public static ObjectComparator getInstance(
BiFunction<Object, Object, Long> fallbackComparator) {
public static ObjectComparator getInstance(BiFunction<Object, Object, Long> fallbackComparator) {
if (INSTANCE == null) {
INSTANCE = new ObjectComparator((l, r) -> fallbackComparator.apply(l, r).intValue());
}

View File

@ -59,8 +59,8 @@ public class Regex_Utils {
*
* <p>This should behave exactly the same as `Regex.compile regex . find text` in Enso, it is here
* only as a temporary workaround, because the Enso function gives wrong results on examples like
* `Regex.compile "([0-9]+|[^0-9]+)" . find "1a2c"` where it returns `[1, a, 2]` instead of
* `[1, a, 2, c]`.
* `Regex.compile "([0-9]+|[^0-9]+)" . find "1a2c"` where it returns `[1, a, 2]` instead of `[1,
* a, 2, c]`.
*/
public static String[] find_all_matches(String regex, String text) {
var allMatches = new ArrayList<String>();

View File

@ -49,10 +49,8 @@ public final class UrlencodedBodyBuilder {
}
private String encodePart(String name, String value) {
return
URLEncoder.encode(name, StandardCharsets.UTF_8)
return URLEncoder.encode(name, StandardCharsets.UTF_8)
+ "="
+ URLEncoder.encode(value, StandardCharsets.UTF_8);
}
}

View File

@ -34,8 +34,10 @@ public class CountMinMax {
if (!comparatorFailed) {
try {
minimum = minimum == null || objectComparator.compare(minimum, value) > 0 ? value : minimum;
maximum = maximum == null || objectComparator.compare(maximum, value) < 0 ? value : maximum;
minimum =
minimum == null || objectComparator.compare(minimum, value) > 0 ? value : minimum;
maximum =
maximum == null || objectComparator.compare(maximum, value) < 0 ? value : maximum;
} catch (ClassCastException e) {
comparatorFailed = true;
}

View File

@ -23,6 +23,7 @@ public class Kurtosis implements MomentStatistic {
double scale = n * (n + 1) / ((n - 1) * (n - 2) * (n - 3) * var * var);
double shift = 3.0 * (n - 1.0) * (n - 1.0) / ((n - 2.0) * (n - 3.0));
return (sums[3] - 4 * avg * sums[2] + 6 * avg * avg * sums[1] - 3 * avg * avg * avg * sums[0])
* scale - shift;
* scale
- shift;
}
}

View File

@ -1,14 +1,16 @@
package org.enso.base.statistics;
public interface MomentStatistic {
/***
/**
* Maximum order needed to compute the statistic
*
* @return Max order needed. 0 if only need the count.
*/
int order();
/***
/**
* Compute the statistic
*
* @param n the count of valid values
* @param sums the totals of each order
* @return computed statistic

View File

@ -2,9 +2,7 @@ package org.enso.base.statistics;
import java.util.Arrays;
/***
* Set of descriptive statistics for numerical data sets
*/
/** Set of descriptive statistics for numerical data sets */
public class Moments {
/** Statistic to compute the total of the values. */

View File

@ -15,9 +15,11 @@ public class GraphemeSpan extends Utf16Span {
/**
* Constructs a span of characters (understood as extended grapheme clusters).
* @param grapheme_start index of the first extended grapheme cluster contained within the span (or
* location of the span if it is empty)
* @param grapheme_end index of the first extended grapheme cluster after start that is not contained
*
* @param grapheme_start index of the first extended grapheme cluster contained within the span
* (or location of the span if it is empty)
* @param grapheme_end index of the first extended grapheme cluster after start that is not
* contained
* @param codeunit_start code unit index of {@code grapheme_start}
* @param codeunit_end code unit index of {@code grapheme_end}
*/

View File

@ -92,5 +92,4 @@ public class Codecs {
throw new WriteFailedException(path);
}
}
}

View File

@ -9,9 +9,7 @@ import org.opencv.imgproc.Imgproc;
import java.util.ArrayList;
import java.util.List;
/**
* A histogram calculated for a single channel of an image.
*/
/** A histogram calculated for a single channel of an image. */
public class Histogram {
private static final int BINS = 256;
@ -45,12 +43,7 @@ public class Histogram {
Core.split(image, images);
Imgproc.calcHist(
images,
new MatOfInt(channel),
new Mat(),
histogram,
new MatOfInt(BINS),
valuesRange);
images, new MatOfInt(channel), new Mat(), histogram, new MatOfInt(BINS), valuesRange);
Core.normalize(histogram, histogram, 0, MAX_VALUE, Core.NORM_MINMAX);
float[] histogramData = new float[(int) histogram.total() * histogram.channels()];

View File

@ -147,6 +147,7 @@ public class Matrix {
/**
* Subtract the scalar from each element of the matrix.
*
* @param mat the matrix.
* @param scalar the scalar to subtract.
* @param dst the matrix holding the result of the operation.
@ -168,6 +169,7 @@ public class Matrix {
/**
* Multiply the scalar with each element of the matrix.
*
* @param mat the matrix.
* @param scalar the scalar to multiply with.
* @param dst the matrix holding the result of the operation.

View File

@ -1,4 +1,5 @@
// Copied unmodified from https://github.com/openpnp/opencv/blob/v4.5.1-0/src/main/java/nu/pattern/OpenCV.java
// Copied unmodified from
// https://github.com/openpnp/opencv/blob/v4.5.1-0/src/main/java/nu/pattern/OpenCV.java
// to allow library loading on GraalVM.
package org.enso.image.opencv;

View File

@ -7,9 +7,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/***
* Interface used to define aggregate columns.
*/
/** Interface used to define aggregate columns. */
public abstract class Aggregator {
private final String name;
private final int type;
@ -21,14 +19,18 @@ public abstract class Aggregator {
this.problems = null;
}
/***
/**
* Return name of the new column
*
* @return Name of the new column.
*/
public final String getName() {
return name;
}
/***
/**
* Return type of the column
*
* @return The type of the new column.
*/
public int getType() {
@ -39,8 +41,9 @@ public abstract class Aggregator {
return problems;
}
/***
/**
* Compute the value for a set of rows
*
* @param indexes - indexes to the rows in the source table to aggregate on
* @return aggregated value
*/
@ -48,8 +51,9 @@ public abstract class Aggregator {
return this.aggregate(Arrays.stream(indexes).boxed().collect(Collectors.toList()));
}
/***
/**
* Compute the value for a set of rows
*
* @param indexes - indexes to the rows in the source table to aggregate on
* @return aggregated value
*/

View File

@ -4,9 +4,7 @@ import org.enso.table.data.column.storage.Storage;
import java.util.List;
/***
* Aggregate Column counting the number of entries in a group.
*/
/** Aggregate Column counting the number of entries in a group. */
public class Count extends Aggregator {
public Count(String name) {
super(name, Storage.Type.LONG);

View File

@ -10,9 +10,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
/***
* Aggregate Column counting the number of distinct items in a group.
* If `ignoreAllNull` is true, does count when all items are null.
/**
* Aggregate Column counting the number of distinct items in a group. If `ignoreAllNull` is true,
* does count when all items are null.
*/
public class CountDistinct extends Aggregator {
private final Storage[] storage;
@ -20,6 +20,7 @@ public class CountDistinct extends Aggregator {
/**
* Constructs a CountDistinct Aggregator
*
* @param name output column name
* @param columns input columns
* @param ignoreAllNull if true ignore then all values are null
@ -34,7 +35,8 @@ public class CountDistinct extends Aggregator {
public Object aggregate(List<Integer> indexes) {
Set<MultiValueKey> set = new HashSet<>();
for (int row : indexes) {
MultiValueKey key = new MultiValueKey(Arrays.stream(storage).map(s->s.getItemBoxed(row)).toArray());
MultiValueKey key =
new MultiValueKey(Arrays.stream(storage).map(s -> s.getItemBoxed(row)).toArray());
if (key.hasFloatValues()) {
this.addProblem(new FloatingPointGrouping(this.getName(), row));
}

View File

@ -6,10 +6,9 @@ import org.enso.table.data.table.problems.InvalidAggregation;
import java.util.List;
/***
* Aggregate Column counting the number of (non-)empty entries in a group.
* If `isEmpty` is true, counts null or empty entries.
* If `isEmpty` is false, counts non-empty entries.
/**
* Aggregate Column counting the number of (non-)empty entries in a group. If `isEmpty` is true,
* counts null or empty entries. If `isEmpty` is false, counts non-empty entries.
*/
public class CountEmpty extends Aggregator {
private final Storage storage;
@ -17,6 +16,7 @@ public class CountEmpty extends Aggregator {
/**
* Constructs a CountNothing Aggregator
*
* @param name output column name
* @param column input column
* @param isEmpty true to count nulls or empty, false to count non-empty

View File

@ -5,10 +5,9 @@ import org.enso.table.data.table.Column;
import java.util.List;
/***
* Aggregate Column counting the number of (not-)null entries in a group.
* If `isNothing` is true, counts null entries.
* If `isNothing` is false, counts non-null entries.
/**
* Aggregate Column counting the number of (not-)null entries in a group. If `isNothing` is true,
* counts null entries. If `isNothing` is false, counts non-null entries.
*/
public class CountNothing extends Aggregator {
private final Storage storage;
@ -16,6 +15,7 @@ public class CountNothing extends Aggregator {
/**
* Constructs a CountNothing Aggregator
*
* @param name output column name
* @param column input column
* @param isNothing true to count nulls, false to count non-nulls

View File

@ -8,9 +8,7 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
/***
* Aggregate Column finding the first value in a group.
*/
/** Aggregate Column finding the first value in a group. */
public class First extends Aggregator {
private final Storage storage;
private final Storage[] ordering;

View File

@ -5,9 +5,7 @@ import org.enso.table.data.table.Column;
import java.util.List;
/***
* Aggregate Column getting the grouping key.
*/
/** Aggregate Column getting the grouping key. */
public class GroupBy extends Aggregator {
private final Storage storage;

View File

@ -6,9 +6,7 @@ import org.enso.table.data.table.problems.InvalidAggregation;
import java.util.List;
/***
* Aggregate Column computing the mean value in a group.
*/
/** Aggregate Column computing the mean value in a group. */
public class Mean extends Aggregator {
private static class Calculation {
public long count;
@ -35,7 +33,8 @@ public class Mean extends Aggregator {
if (value != null) {
Double dValue = CastToDouble(value);
if (dValue == null) {
this.addProblem(new InvalidAggregation(this.getName(), row, "Cannot convert to a number."));
this.addProblem(
new InvalidAggregation(this.getName(), row, "Cannot convert to a number."));
return null;
}

View File

@ -7,7 +7,7 @@ import org.enso.table.data.table.problems.InvalidAggregation;
import java.util.Comparator;
import java.util.List;
/***
/**
* Aggregate Column finding the minimum (minOrMax = -1) or maximum (minOrMax = 1) entry in a group.
*/
public class MinOrMax extends Aggregator {
@ -36,7 +36,8 @@ public class MinOrMax extends Aggregator {
Object value = storage.getItemBoxed(row);
if (value != null) {
try {
if (current == null || Integer.signum(objectComparator.compare(value, current)) == minOrMax) {
if (current == null
|| Integer.signum(objectComparator.compare(value, current)) == minOrMax) {
current = value;
}
} catch (ClassCastException e) {

View File

@ -8,9 +8,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/***
* Aggregate Column computing the most common value in a group (ignoring Nothing).
*/
/** Aggregate Column computing the most common value in a group (ignoring Nothing). */
public class Mode extends Aggregator {
private final Storage storage;

View File

@ -8,9 +8,7 @@ import org.enso.table.data.column.storage.Storage;
import org.enso.table.data.table.Column;
import org.enso.table.data.table.problems.InvalidAggregation;
/***
* Aggregate Column computing a percentile value in a group.
*/
/** Aggregate Column computing a percentile value in a group. */
public class Percentile extends Aggregator {
private final Storage storage;
private final double percentile;

View File

@ -7,9 +7,7 @@ import org.enso.table.data.table.problems.InvalidAggregation;
import java.util.List;
/***
* Aggregate Column finding the longest or shortest string in a group.
*/
/** Aggregate Column finding the longest or shortest string in a group. */
public class ShortestOrLongest extends Aggregator {
private final Storage storage;
private final int minOrMax;

View File

@ -5,9 +5,7 @@ import org.enso.table.data.column.storage.Storage;
import org.enso.table.data.table.Column;
import org.enso.table.data.table.problems.InvalidAggregation;
/***
* Aggregate Column computing the standard deviation of a group.
*/
/** Aggregate Column computing the standard deviation of a group. */
public class StandardDeviation extends Aggregator {
private static class Calculation {
public long count;

View File

@ -6,9 +6,7 @@ import org.enso.table.data.table.problems.InvalidAggregation;
import java.util.List;
/***
* Aggregate Column computing the total value in a group.
*/
/** Aggregate Column computing the total value in a group. */
public class Sum extends Aggregator {
private final Storage storage;
@ -37,7 +35,8 @@ public class Sum extends Aggregator {
if (dCurrent != null && dValue != null) {
current = dCurrent + dValue;
} else {
this.addProblem(new InvalidAggregation(this.getName(), row, "Cannot convert to a number."));
this.addProblem(
new InvalidAggregation(this.getName(), row, "Cannot convert to a number."));
return null;
}
}

View File

@ -6,9 +6,9 @@ import java.util.stream.IntStream;
/**
* Represents a fold-like operation on a storage. An aggregator is usually created for a given
* storage, then {@link #nextGroup(IntStream)} is repeatedly called and the aggregator is responsible for
* collecting the results of such calls. After that, {@link #seal()} is called to obtain a storage
* containing all the results.
* storage, then {@link #nextGroup(IntStream)} is repeatedly called and the aggregator is
* responsible for collecting the results of such calls. After that, {@link #seal()} is called to
* obtain a storage containing all the results.
*/
public abstract class Aggregator {
/**

View File

@ -32,9 +32,7 @@ public class StringStorage extends ObjectStorage {
return (String) super.getItem(idx);
}
/**
* @inheritDoc
*/
/** @inheritDoc */
@Override
public long getType() {
return Type.STRING;

View File

@ -31,7 +31,9 @@ public class MultiValueIndex {
int size = keyColumns[0].getSize();
for (int i = 0; i < size; i++) {
int finalI = i;
MultiValueKey key = new MultiValueKey(Arrays.stream(keyColumns).map(c -> c.getStorage().getItemBoxed(finalI)).toArray());
MultiValueKey key =
new MultiValueKey(
Arrays.stream(keyColumns).map(c -> c.getStorage().getItemBoxed(finalI)).toArray());
if (key.hasFloatValues()) {
problems.add(new FloatingPointGrouping("GroupBy", i));
@ -41,7 +43,9 @@ public class MultiValueIndex {
ids.add(i);
}
} else {
this.locs.put(new MultiValueKey(new Object[0]), IntStream.range(0, tableSize).boxed().collect(Collectors.toList()));
this.locs.put(
new MultiValueKey(new Object[0]),
IntStream.range(0, tableSize).boxed().collect(Collectors.toList()));
}
}
@ -50,7 +54,8 @@ public class MultiValueIndex {
final int size = locs.size();
boolean emptyScenario = size == 0 & keyColumnsLength == 0;
Builder[] storage = Arrays.stream(columns)
Builder[] storage =
Arrays.stream(columns)
.map(c -> getBuilderForType(c.getType(), emptyScenario ? 1 : size))
.toArray(Builder[]::new);
@ -84,11 +89,16 @@ public class MultiValueIndex {
private static Builder getBuilderForType(int type, int size) {
switch (type) {
case Storage.Type.BOOL: return new BoolBuilder();
case Storage.Type.DOUBLE: return NumericBuilder.createDoubleBuilder(size);
case Storage.Type.LONG: return NumericBuilder.createLongBuilder(size);
case Storage.Type.STRING: return new StringBuilder(size);
case Storage.Type.OBJECT: return new ObjectBuilder(size);
case Storage.Type.BOOL:
return new BoolBuilder();
case Storage.Type.DOUBLE:
return NumericBuilder.createDoubleBuilder(size);
case Storage.Type.LONG:
return NumericBuilder.createLongBuilder(size);
case Storage.Type.STRING:
return new StringBuilder(size);
case Storage.Type.OBJECT:
return new ObjectBuilder(size);
}
return new InferredBuilder(size);
}

View File

@ -57,7 +57,9 @@ public class MultiValueKey implements Comparable<MultiValueKey> {
return allNull;
}
public boolean hasFloatValues() { return floatValue; }
public boolean hasFloatValues() {
return floatValue;
}
protected static Object foldObject(Object value) {
if (value instanceof Long) {

View File

@ -46,7 +46,11 @@ public class Table {
private Table(Column[] columns, Index index, AggregatedProblems problems) {
this.columns = columns;
this.index = index == null ? (new DefaultIndex((columns == null || columns.length == 0) ? 0 : columns[0].getSize())) : index;
this.index =
index == null
? (new DefaultIndex(
(columns == null || columns.length == 0) ? 0 : columns[0].getSize()))
: index;
this.problems = problems;
}
@ -64,9 +68,7 @@ public class Table {
return columns;
}
/**
* @return Attached set of any problems from the Java side
*/
/** @return Attached set of any problems from the Java side */
public AggregatedProblems getProblems() {
return problems;
}

View File

@ -39,8 +39,8 @@ public class AggregatedProblems {
public void add(Problem problem) {
if (problem instanceof ColumnAggregatedProblems) {
for (Problem p : problems) {
if (p instanceof ColumnAggregatedProblems &&
((ColumnAggregatedProblems) p).merge((ColumnAggregatedProblems)problem)) {
if (p instanceof ColumnAggregatedProblems
&& ((ColumnAggregatedProblems) p).merge((ColumnAggregatedProblems) problem)) {
return;
}
}

View File

@ -21,7 +21,9 @@ public abstract class ColumnAggregatedProblems implements Problem {
return rows.stream().mapToInt(Integer::intValue).toArray();
}
public int count() { return rows.size(); }
public int count() {
return rows.size();
}
public abstract boolean merge(ColumnAggregatedProblems another);

View File

@ -12,8 +12,8 @@ public class FloatingPointGrouping extends ColumnAggregatedProblems {
@Override
public boolean merge(ColumnAggregatedProblems another) {
if (another instanceof FloatingPointGrouping &&
this.getColumnName().equals(another.getColumnName())) {
if (another instanceof FloatingPointGrouping
&& this.getColumnName().equals(another.getColumnName())) {
this.rows.addAll(another.rows);
return true;
}

View File

@ -9,13 +9,15 @@ public class InvalidAggregation extends ColumnAggregatedProblems {
}
@Override
public String getMessage() { return message; }
public String getMessage() {
return message;
}
@Override
public boolean merge(ColumnAggregatedProblems another) {
if (another instanceof InvalidAggregation &&
this.getColumnName().equals(another.getColumnName()) &&
this.message.equals(((InvalidAggregation) another).message)) {
if (another instanceof InvalidAggregation
&& this.getColumnName().equals(another.getColumnName())
&& this.message.equals(((InvalidAggregation) another).message)) {
this.rows.addAll(another.rows);
return true;
}

View File

@ -5,4 +5,3 @@ import java.util.List;
public interface Problem {
String getMessage();
}

View File

@ -9,13 +9,15 @@ public class UnquotedDelimiter extends ColumnAggregatedProblems {
}
@Override
public String getMessage() { return message; }
public String getMessage() {
return message;
}
@Override
public boolean merge(ColumnAggregatedProblems another) {
if (another instanceof UnquotedDelimiter &&
this.getColumnName().equals(another.getColumnName()) &&
this.message.equals(((UnquotedDelimiter) another).message)) {
if (another instanceof UnquotedDelimiter
&& this.getColumnName().equals(another.getColumnName())
&& this.message.equals(((UnquotedDelimiter) another).message)) {
this.rows.addAll(another.rows);
return true;
}

View File

@ -44,7 +44,10 @@ public class Range {
private static int[] parseRange(String range) throws IllegalArgumentException {
for (Pattern pattern : new Pattern[] {RANGE_A1, RANGE_COL, RANGE_ROW, RANGE_RC}) {
Optional<int[]> parsed =
parseRange(range, pattern, pattern == RANGE_RC ? Range::parseR1C1StyleAddress : Range::parseA1StyleAddress);
parseRange(
range,
pattern,
pattern == RANGE_RC ? Range::parseR1C1StyleAddress : Range::parseA1StyleAddress);
if (parsed.isPresent()) {
return parsed.get();
@ -142,13 +145,9 @@ public class Range {
}
private static class ParsedInteger {
/**
* Index to the next character after the parsed value
*/
/** Index to the next character after the parsed value */
public final int index;
/**
* Parsed integer value or 0 if not valid
*/
/** Parsed integer value or 0 if not valid */
public final int value;
public ParsedInteger(int index, int value) {