Skip to content

Commit

Permalink
Bumped the google-java-format version to 1.22.0
Browse files Browse the repository at this point in the history
This updates the version of the google style that we use for formatting our
code. Consequently, the formatting in some of our java files gets updated.
  • Loading branch information
cmnrd committed Jun 3, 2024
1 parent 2873a18 commit f2e2050
Show file tree
Hide file tree
Showing 57 changed files with 1,284 additions and 1,228 deletions.
1 change: 1 addition & 0 deletions cli/lfc/src/main/java/org/lflang/cli/Lfc.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ private Integer getWorkers() {
}
return workers;
}

/** Check the values of the commandline arguments and return them. */
public GeneratorArguments getArgs() {

Expand Down
52 changes: 26 additions & 26 deletions cli/lfc/src/test/java/org/lflang/cli/LfcCliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,35 @@ public class LfcCliTest {

static final String LF_PYTHON_FILE =
"""
target Python
main reactor {
reaction(startup) {==}
}
""";
target Python
main reactor {
reaction(startup) {==}
}
""";

static final String JSON_STRING =
"""
{
"src": "src/File.lf",
"out": "src",
"properties": {
"build-type": "Release",
"clean": true,
"compiler": "gcc",
"external-runtime-path": "src",
"federated": true,
"logging": "info",
"lint": true,
"no-compile": true,
"print-statistics": true,
"quiet": true,
"rti": "path/to/rti",
"runtime-version": "rs",
"scheduler": "GEDF_NP",
"single-threaded": true
}
}
""";
{
"src": "src/File.lf",
"out": "src",
"properties": {
"build-type": "Release",
"clean": true,
"compiler": "gcc",
"external-runtime-path": "src",
"federated": true,
"logging": "info",
"lint": true,
"no-compile": true,
"print-statistics": true,
"quiet": true,
"rti": "path/to/rti",
"runtime-version": "rs",
"scheduler": "GEDF_NP",
"single-threaded": true
}
}
""";

@Test
public void testHelpArg() {
Expand Down
10 changes: 5 additions & 5 deletions cli/lfd/src/test/java/org/lflang/cli/LfdCliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class LfdCliTest {

private static final String VALID_FILE =
"""
target Python
main reactor {
reaction(startup) {==}
}
""";
target Python
main reactor {
reaction(startup) {==}
}
""";
LfdTestFixture lfdTester = new LfdTestFixture();

@Test
Expand Down
196 changes: 98 additions & 98 deletions cli/lff/src/test/java/org/lflang/cli/LffCliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,133 +45,133 @@ public class LffCliTest {

private static final String FILE_BEFORE_REFORMAT =
"""
target Python;
main reactor {
reaction(startup) {=
=}
}
""";
target Python;
main reactor {
reaction(startup) {=
=}
}
""";
private static final String FILE_AFTER_REFORMAT =
"""
target Python
target Python
main reactor {
reaction(startup) {= =}
}
""";
main reactor {
reaction(startup) {= =}
}
""";

private static final List<List<String>> TEST_CASES =
List.of(
List.of(
"""
target C
reactor Test { // this is a test
logical action a # this is an a
output humbug: int
reaction (a) -> /* moo */ humbug {= // this is a humbug reaction
/* it reacts like this*/ react react
=}
}
""",
target C
reactor Test { // this is a test
logical action a # this is an a
output humbug: int
reaction (a) -> /* moo */ humbug {= // this is a humbug reaction
/* it reacts like this*/ react react
=}
}
""",
"""
target C
// this is a test
reactor Test {
logical action a // this is an a
output humbug: int
/** moo */
// this is a humbug reaction
reaction(a) -> humbug {=
/* it reacts like this*/ react react
=}
}
"""),
target C
// this is a test
reactor Test {
logical action a // this is an a
output humbug: int
/** moo */
// this is a humbug reaction
reaction(a) -> humbug {=
/* it reacts like this*/ react react
=}
}
"""),
List.of(
"""
target C
// Documentation
@icon("Variables.png")
reactor Variables {}
""",
target C
// Documentation
@icon("Variables.png")
reactor Variables {}
""",
"""
target C
target C
// Documentation
@icon("Variables.png")
reactor Variables {
}
"""),
// Documentation
@icon("Variables.png")
reactor Variables {
}
"""),
List.of(
"""
target C
reactor Filter(period: int = 0, b: double[] = {0, 0}) {}
main reactor {
az_f = new Filter(
period = 100,
b = {0.229019233988375, 0.421510777305010}
)
}
""",
target C
reactor Filter(period: int = 0, b: double[] = {0, 0}) {}
main reactor {
az_f = new Filter(
period = 100,
b = {0.229019233988375, 0.421510777305010}
)
}
""",
"""
target C
target C
reactor Filter(period: int = 0, b: double[] = {0, 0}) {
}
reactor Filter(period: int = 0, b: double[] = {0, 0}) {
}
main reactor {
az_f = new Filter(period=100, b = {0.229019233988375, 0.421510777305010})
}
"""),
main reactor {
az_f = new Filter(period=100, b = {0.229019233988375, 0.421510777305010})
}
"""),
List.of(
"""
target Rust
reactor Snake { // q
state grid: SnakeGrid = {= /* foo */ SnakeGrid::new(grid_side, &snake) =}; // note that this one borrows snake temporarily
state grid2: SnakeGrid = {= // baz
SnakeGrid::new(grid_side, &snake) =};
}
""",
target Rust
reactor Snake { // q
state grid: SnakeGrid = {= /* foo */ SnakeGrid::new(grid_side, &snake) =}; // note that this one borrows snake temporarily
state grid2: SnakeGrid = {= // baz
SnakeGrid::new(grid_side, &snake) =};
}
""",
"""
target Rust
// q
reactor Snake {
// note that this one borrows snake temporarily
state grid: SnakeGrid = {= /* foo */ SnakeGrid::new(grid_side, &snake) =}
// baz
state grid2: SnakeGrid = {= SnakeGrid::new(grid_side, &snake) =}
}
"""),
target Rust
// q
reactor Snake {
// note that this one borrows snake temporarily
state grid: SnakeGrid = {= /* foo */ SnakeGrid::new(grid_side, &snake) =}
// baz
state grid2: SnakeGrid = {= SnakeGrid::new(grid_side, &snake) =}
}
"""),
List.of(
"""
target Cpp
target Cpp
reactor ContextManager<Req, Resp, Ctx> {
reactor ContextManager<Req, Resp, Ctx> {
\s
}
\s
}
reactor MACService {
mul_cm = new ContextManager<loooooooooooooooooooooooooooooong, looooooooooooooong, loooooooooooooong>()
}
reactor MACService {
mul_cm = new ContextManager<loooooooooooooooooooooooooooooong, looooooooooooooong, loooooooooooooong>()
}
""",
""",
"""
target Cpp
reactor ContextManager<Req, Resp, Ctx> {
}
reactor MACService {
mul_cm = new ContextManager<
loooooooooooooooooooooooooooooong,
looooooooooooooong,
loooooooooooooong>()
}
"""));
target Cpp
reactor ContextManager<Req, Resp, Ctx> {
}
reactor MACService {
mul_cm = new ContextManager<
loooooooooooooooooooooooooooooong,
looooooooooooooong,
loooooooooooooong>()
}
"""));

LffTestFixture lffTester = new LffTestFixture();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ private boolean get() {

/** The zero-based indices of the touched lines. */
private final List<Integer> badLines;

/** The original test on which this is based. */
private final Path srcFile;

/** The content of this test. */
private final LinkedList<String> lines;

/** Whether the error inserter is permitted to insert a line before the current line. */
private final Predicate<ListIterator<String>> insertCondition;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class LspTests extends LfInjectedTestBase {
diagnosticsHaveKeyword("libprotoc")
.or(diagnosticsHaveKeyword("protoc-c"))
.or(diagnosticsIncludeText("could not be found"));

/**
* The number of samples to take from each test category (with replacement) when doing validation
* tests.
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/lflang/InferredType.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class InferredType {

/** The AST node representing the inferred type if such a node exists. */
public final Type astType;

/** A flag indicating whether the inferred type has the base type time. */
public final boolean isTime;

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/lflang/TimeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class TimeValue implements Comparable<TimeValue> {

/** The maximum value of this type. This is approximately equal to 292 years. */
public static final TimeValue MAX_VALUE = new TimeValue(Long.MAX_VALUE, TimeUnit.NANO);

/** A time value equal to zero. */
public static final TimeValue ZERO = new TimeValue(0, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class DelayedConnectionTransformation implements AstTransformation {

private boolean transformAfterDelays = false;
private boolean transformPhysicalConnection = false;

/** Collection of generated delay classes. */
private final LinkedHashSet<Reactor> delayClasses = new LinkedHashSet<>();

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/lflang/ast/FormattingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static String lineWrapComments(List<String> comments, int width, String singleLi
ret.append(lineWrapComment(current.toString(), width, singleLineCommentPrefix));
return ret.toString();
}

/** Wrap lines. Do not merge lines that start with weird characters. */
private static String lineWrapComment(String comment, int width, String singleLineCommentPrefix) {
var multiline = MULTILINE_COMMENT.matcher(comment).matches();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ public class LayoutPostProcessing extends AbstractSynthesisExtensions {

/** Synthesis option to control the order of nodes and edges by model order. */
public static final String MODEL_ORDER_OPTION = "Model Order";

/** Uses semi-automatic layout. */
public static final String LEGACY = "Legacy";

/** Only reactions are strictly ordered by their model order. */
public static final String STRICT_REACTION_ONLY = "Reactions Only";

/** Reactions and reactor are strictly ordered by their model order. */
public static final String STRICT = "Reactions and Reactors";

/**
* Reactions and reactors are ordered by their model order if no additional crossing are created.
*/
public static final String TIE_BREAKER = "Optimize Crossings";

/**
* No crossing minimization is done at all. This requires that actions and timers are sorted based
* on their model order.
Expand Down
Loading

0 comments on commit f2e2050

Please sign in to comment.