Skip to content

Commit

Permalink
fix (ide): Bump google-java-formatter from 1.20.0 to 1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Mar 16, 2024
1 parent 8cdefe8 commit 10289d5
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ repos:
hooks:
- id: pretty-format-java
# Keep this version in sync with the same version in .vscode/settings.json
args: [--autofix, --aosp, --google-java-formatter-version=1.20.0]
args: [--autofix, --aosp, --google-java-formatter-version=1.21.0]

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.12.1
Expand Down
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
"java.format.settings.google.extra": "--aosp", // For 4 instead of 2 spaces!
// Keep this version in sync with the same version in .pre-commit-config.yaml
// NB: Changes to this are only taken into account on start-up, so need to restart.
"java.format.settings.google.version": "1.20.0",
// TODO Remove when https://github.com/google/google-java-format/issues/1072 is fixed:
"java.format.settings.google.mode": "jar-file",
"java.format.settings.google.version": "1.21.0",
// TODO https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/3050
"java.compile.nullAnalysis.mode": "automatic",
"java.completion.importOrder": ["#", "", "javax", "java"], //# is static
Expand Down
10 changes: 5 additions & 5 deletions cli/src/test/java/dev/enola/cli/EnolaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ public void get() {
.out()
.startsWith(
"""
id {
ns: "test"
entity: "foobar"
paths: "helo"
""");
id {
ns: "test"
entity: "foobar"
paths: "helo"
""");
}

@Test
Expand Down
50 changes: 50 additions & 0 deletions common/common/src/main/java/dev/enola/common/io/iri/IRIs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2024 The Enola <https://enola.dev> Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.enola.common.io.iri;

import java.net.URI;
import java.net.URISyntaxException;

/**
* Utility methods for Internationalized Resource Identifiers (IRIs).
*
* <p>See <a href="https://datatracker.ietf.org/doc/html/rfc3987">RFC 3987</a>.
*/
public final class IRIs {
// see also (new) class dev.enola.common.io.resource.URIs

/**
* Resolves an IRI reference against a base IRI and returns the resulting IRI as a String.
*
* <p>See <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4">Section §4 of RFC
* 3986</a>.
*
* <p>This is currently implemented using {@link java.net.URI#resolve()}. This works great, but
* it creates (two) intermediate URI objects. If this ever becomes a problem for performance,
* this implementation could be optimized to work directly on Strings.
*/
public static String resolve(String base, String reference) throws URISyntaxException {
return toURI(base).resolve(reference).toString();
}

public static URI toURI(String iri) throws URISyntaxException {
return new URI(iri);
}

private IRIs() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.Map;

public final class URIs {
// see also class dev.enola.common.io.iri.IRIs
// TODO Move this from package io.resource to package io.iri

// URI Query Parameter Names
private static final String MEDIA_TYPE = "mediaType";
Expand Down
42 changes: 42 additions & 0 deletions common/common/src/test/java/dev/enola/common/io/iri/IRIsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2024 The Enola <https://enola.dev> Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.enola.common.io.iri;

import static com.google.common.truth.Truth.assertThat;

import org.junit.Test;

import java.net.URI;
import java.net.URISyntaxException;

public class IRIsTest {

@Test
public void toURI() throws URISyntaxException {
var iri = "https://en.wiktionary.org/wiki/Ῥόδος";
assertThat(IRIs.toURI(iri)).isEqualTo(new URI(iri));
}

@Test
public void resolve() throws URISyntaxException {
var base = "https://en.wiktionary.org/wiki/Ῥόδος";
var rel = "ῥόα";
var expected = "https://en.wiktionary.org/wiki/ῥόα";
assertThat(IRIs.resolve(base, rel)).isEqualTo(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MarkdownResourceTest {
...
-->
""";
""";

String FRONTMATTER =
"""
Expand All @@ -51,11 +51,12 @@ public class MarkdownResourceTest {
""";

String MD = """
String MD =
"""
# Thaw Blough!
**It rocks...**
""";
""";

@Test
public void commentFrontmatterMarkdown() throws IOException {
Expand Down
24 changes: 12 additions & 12 deletions core/impl/src/test/java/dev/enola/core/tbd/RosettaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ public void testTextprotoToYaml() throws Exception {
var expectedOut =
StringResource.of(
"""
id:
ns: demo
entity: bar
paths: [abc, def]
related:
one:
ns: demo
entity: baz
paths: [uvw]
link: {wiki:\
'https://en.wikipedia.org/w/index.php?fulltext=Search&search=def'}
""",
id:
ns: demo
entity: bar
paths: [abc, def]
related:
one:
ns: demo
entity: baz
paths: [uvw]
link: {wiki:\
'https://en.wikipedia.org/w/index.php?fulltext=Search&search=def'}
""",
YAML_UTF_8);
assertThat(out.charSource().read()).isEqualTo(expectedOut.charSource().read());
}
Expand Down

0 comments on commit 10289d5

Please sign in to comment.