From 5198b29b6972bc01ba281fa4073c462d908383cd Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Sun, 30 Jul 2023 20:35:53 -0500 Subject: [PATCH] Version 2.2.1, fix inverted condition in CopyRecordParameters --- gradle.properties | 2 +- .../dev/denwav/hypo/asm/scenarios/Scenario09Test.java | 4 ++++ .../denwav/hypo/hydrate/DefaultHydrationManager.java | 1 + .../mappings/contributors/CopyRecordParameters.java | 2 +- .../dev/denwav/hypo/model/HypoModelUtilHelper.java | 8 ++++++++ .../java/dev/denwav/hypo/model/data/ClassData.java | 10 ++++++++++ readme.md | 8 ++++---- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 66d37b2..6929fec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ group = dev.denwav.hypo -version = 2.2.1-SNAPSHOT +version = 2.2.1 org.gradle.parallel=true diff --git a/hypo-asm/src/test/java/dev/denwav/hypo/asm/scenarios/Scenario09Test.java b/hypo-asm/src/test/java/dev/denwav/hypo/asm/scenarios/Scenario09Test.java index adb27e0..fbe91bd 100644 --- a/hypo-asm/src/test/java/dev/denwav/hypo/asm/scenarios/Scenario09Test.java +++ b/hypo-asm/src/test/java/dev/denwav/hypo/asm/scenarios/Scenario09Test.java @@ -63,6 +63,10 @@ public void testAbstractEnums() throws Exception { assertTrue(testClass.isAll(ClassKind.ENUM, ClassKind.ABSTRACT_CLASS)); assertTrue(testClass.isAll(EnumSet.of(ClassKind.ENUM, ClassKind.ABSTRACT_CLASS))); + // `true` isNot + assertTrue(testClass.isNot(ClassKind.INTERFACE)); + assertTrue(testClass.isNot(ClassKind.RECORD)); + // `false` is assertFalse(testClass.is(ClassKind.INTERFACE)); assertFalse(testClass.is(ClassKind.RECORD)); diff --git a/hypo-hydrate/src/main/java/dev/denwav/hypo/hydrate/DefaultHydrationManager.java b/hypo-hydrate/src/main/java/dev/denwav/hypo/hydrate/DefaultHydrationManager.java index 404049b..6183985 100644 --- a/hypo-hydrate/src/main/java/dev/denwav/hypo/hydrate/DefaultHydrationManager.java +++ b/hypo-hydrate/src/main/java/dev/denwav/hypo/hydrate/DefaultHydrationManager.java @@ -170,6 +170,7 @@ private static boolean containsAny(final Set set, final List list) { return false; } + @SuppressWarnings("ReferenceEquality") private @NotNull Graph, DefaultEdge> createProviderGraph() { final ArrayList> allProviders = new ArrayList<>(this.classProviders.size() + this.methodProviders.size() + this.fieldProviders.size()); diff --git a/hypo-mappings/src/main/java/dev/denwav/hypo/mappings/contributors/CopyRecordParameters.java b/hypo-mappings/src/main/java/dev/denwav/hypo/mappings/contributors/CopyRecordParameters.java index e6d3842..8988873 100644 --- a/hypo-mappings/src/main/java/dev/denwav/hypo/mappings/contributors/CopyRecordParameters.java +++ b/hypo-mappings/src/main/java/dev/denwav/hypo/mappings/contributors/CopyRecordParameters.java @@ -70,7 +70,7 @@ public void contribute( return; } - if (currentClass.is(ClassKind.RECORD)) { + if (currentClass.isNot(ClassKind.RECORD)) { return; } diff --git a/hypo-model/src/main/java/dev/denwav/hypo/model/HypoModelUtilHelper.java b/hypo-model/src/main/java/dev/denwav/hypo/model/HypoModelUtilHelper.java index 125e77e..5b259e9 100644 --- a/hypo-model/src/main/java/dev/denwav/hypo/model/HypoModelUtilHelper.java +++ b/hypo-model/src/main/java/dev/denwav/hypo/model/HypoModelUtilHelper.java @@ -59,5 +59,13 @@ abstract class HypoModelUtilHelper { */ abstract @NotNull List asImmutableList(final @NotNull Collection list); + /** + * Create an immutable list from the given array. + * + * @param array The arry to return as an immutable list. + * @return The new immutable list. + * @param The type param of the list. + */ + @SuppressWarnings("unchecked") abstract @NotNull List immutableListOf(final @NotNull T @NotNull ... array); } diff --git a/hypo-model/src/main/java/dev/denwav/hypo/model/data/ClassData.java b/hypo-model/src/main/java/dev/denwav/hypo/model/data/ClassData.java index 2f674ef..5e678cc 100644 --- a/hypo-model/src/main/java/dev/denwav/hypo/model/data/ClassData.java +++ b/hypo-model/src/main/java/dev/denwav/hypo/model/data/ClassData.java @@ -182,6 +182,16 @@ default boolean is(final @NotNull ClassKind kind) { return this.kinds().contains(kind); } + /** + * Returns {@code true} if this class data does not represent the given kind. This is the inverse of {@link #is(ClassKind)}. + * @param kind The {@link ClassKind} to test against this class data + * @return {@code true} if this class data does not represent the given kind. + * @see #is(ClassKind) + */ + default boolean isNot(final @NotNull ClassKind kind) { + return !this.is(kind); + } + /** * Returns {@code true} if this class data represents any of the given kinds. * @param kinds The array of {@link ClassKind kinds} to test against this class data. diff --git a/readme.md b/readme.md index 1057501..38f833f 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ Hypo ==== -[![Maven Central Version 2.2.0](https://img.shields.io/badge/Maven_Central-2.2.0-blue?logo=apache-maven&style=flat)](https://search.maven.org/search?q=g:dev.denwav.hypo) +[![Maven Central Version 2.2.1](https://img.shields.io/badge/Maven_Central-2.2.1-blue?logo=apache-maven&style=flat)](https://search.maven.org/search?q=g:dev.denwav.hypo) [![Test](https://github.com/DenWav/Hypo/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/DenWav/Hypo/actions/workflows/test.yml) Hypo is a model for Java bytecode inspection. The main idea behind Hypo is to separate the process of determining @@ -51,7 +51,7 @@ If you're using Gradle 7.0+ you can also use `hypo-catalog` if you like. > } > > dependencies { -> implementation(platform("dev.denwav.hypo:hypo-platform:2.2.0")) +> implementation(platform("dev.denwav.hypo:hypo-platform:2.2.1")) > // Whichever modules you need: > implementation("dev.denwav.hypo:hypo-model") > implementation("dev.denwav.hypo:hypo-core") @@ -74,7 +74,7 @@ If you're using Gradle 7.0+ you can also use `hypo-catalog` if you like. > } > > dependencies { -> implementation platform('dev.denwav.hypo:hypo-platform:2.2.0') +> implementation platform('dev.denwav.hypo:hypo-platform:2.2.1') > // Whichever modules you need: > implementation 'dev.denwav.hypo:hypo-model' > implementation 'dev.denwav.hypo:hypo-core' @@ -98,7 +98,7 @@ If you're using Gradle 7.0+ you can also use `hypo-catalog` if you like. > > dev.denwav.hypo > hypo-platform -> 2.2.0 +> 2.2.1 > > >