Skip to content
Open
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
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object Libs {
const val junitEngine = "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
const val junitPlatformLauncher = "org.junit.platform:junit-platform-launcher:$junitVersion"
const val guava = "com.google.guava:guava:33.6.0-jre"
private const val kyoriTextVersion = "3.0.4"
const val kyoriText = "net.kyori:text-api:$kyoriTextVersion"
const val kyoriTextPlain = "net.kyori:text-serializer-plain:$kyoriTextVersion"
private const val kyoriAdventureVersion = "5.1.1"
const val kyoriAdventure = "net.kyori:adventure-api:$kyoriAdventureVersion"
const val kyoriAdventureTextPlain = "net.kyori:adventure-text-serializer-plain:$kyoriAdventureVersion"
const val autoCommon = "com.google.auto:auto-common:1.2.2"
private const val autoValueVersion = "1.11.1"
const val autoValueAnnotations = "com.google.auto.value:auto-value-annotations:$autoValueVersion"
Expand All @@ -17,7 +17,7 @@ object Libs {
private const val log4jVersion = "2.26.0"
const val log4jApi = "org.apache.logging.log4j:log4j-api:$log4jVersion"
const val log4jCore = "org.apache.logging.log4j:log4j-core:$log4jVersion"
const val javaxAnnotations = "com.google.code.findbugs:jsr305:3.0.2"
const val jspecify = "org.jspecify:jspecify:1.0.0"
const val compileTesting = "com.google.testing.compile:compile-testing:0.23.0"
const val mockito = "org.mockito:mockito-core:5.23.0"
}
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@org.enginehub.piston.util.NonnullByDefault
@org.jspecify.annotations.NullMarked
package org.enginehub.piston.annotation;
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.enginehub.piston.util;

import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Marks a package, class, or method as having all elements {@link Nonnull} by default.
*/
@Documented
@Nonnull
@TypeQualifierDefault({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD})
public @interface NonnullByDefault {
}
@org.jspecify.annotations.NullMarked
package org.enginehub.piston.annotation.param;
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
import org.enginehub.piston.gen.value.CommandInfo;
import org.enginehub.piston.gen.value.CommandParamInfo;
import org.enginehub.piston.gen.value.RegistrationInfo;
import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
import javax.annotation.processing.Processor;
import javax.annotation.processing.SupportedOptions;
import javax.lang.model.SourceVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
import org.enginehub.piston.inject.Key;

import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

public interface GenerationSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.enginehub.piston.gen.value.KeyInfo;
import org.enginehub.piston.gen.value.RegistrationInfo;
import org.enginehub.piston.gen.value.RequiredVariable;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@NonnullByDefault
@org.jspecify.annotations.NullMarked
package org.enginehub.piston.gen.optimize;

import org.enginehub.piston.util.NonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@org.enginehub.piston.util.NonnullByDefault
@org.jspecify.annotations.NullMarked
package org.enginehub.piston.gen;
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Primitives;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.AnnotationValueVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import com.google.common.collect.ImmutableList;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;
import net.kyori.adventure.text.Component;
import org.enginehub.piston.internal.RegistrationUtil;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import javax.lang.model.element.ExecutableElement;
import java.lang.reflect.Method;
import java.util.function.Supplier;
Expand Down Expand Up @@ -72,11 +71,11 @@ public static CodeBlock listForGen(Stream<CodeBlock> rawCode) {
}

public static CodeBlock textCompOf(String text) {
return CodeBlock.of("$T.of($S)", TextComponent.class, text);
return CodeBlock.of("$T.text($S)", Component.class, text);
}

public static CodeBlock transCompOf(String text) {
return CodeBlock.of("$T.of($S)", TranslatableComponent.class, text);
return CodeBlock.of("$T.translatable($S)", Component.class, text);
}

public static Collector<CodeBlock, ?, CodeBlock> joining(String delimiter) {
Expand Down Expand Up @@ -107,8 +106,7 @@ private static final class CodeBlockJoiner {
private final CodeBlock suffix;
@Nullable
private CodeBlock emptyValue;
@Nullable
private CodeBlock.Builder value;
private CodeBlock.@Nullable Builder value;

CodeBlockJoiner(CodeBlock prefix, CodeBlock delimiter, CodeBlock suffix) {
this.prefix = requireNonNull(prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

package org.enginehub.piston.gen.util;

import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@NonnullByDefault
@org.jspecify.annotations.NullMarked
package org.enginehub.piston.gen.util;

import org.enginehub.piston.util.NonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import javax.lang.model.element.ExecutableElement;
import java.util.Collection;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
import org.enginehub.piston.CommandParameters;

import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Information that can be used to supply a parameter for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import com.google.auto.value.extension.memoized.Memoized;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import java.util.Objects;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import org.enginehub.piston.gen.util.SafeName;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.util.CaseHelper;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.squareup.javapoet.ClassName;
import org.jspecify.annotations.Nullable;

import javax.annotation.Nullable;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@NonnullByDefault
@org.jspecify.annotations.NullMarked
package org.enginehub.piston.gen.value;

import org.enginehub.piston.util.NonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.enginehub.piston

import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.commands.RegressionCommands
import org.enginehub.piston.commands.RegressionCommandsRegistration
import org.enginehub.piston.converter.SimpleArgumentConverter
Expand All @@ -36,7 +36,6 @@ import org.junit.jupiter.api.assertThrows
import org.mockito.Mockito.mock
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyNoInteractions

@DisplayName("Regression tests")
class RegressionTest {
Expand Down Expand Up @@ -94,10 +93,10 @@ class RegressionTest {
action(it.valueOf(arg).asString())
1
}
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
description(TextComponent.of("Issue 9 #2"))
description(Component.text("Issue 9 #2"))
// Optional arg prior to sub-command
addPart(arg)
addPart(subs(sub))
Expand Down Expand Up @@ -137,11 +136,11 @@ class RegressionTest {
}
val sub = manager.newCommand("vert")
.action { SUB_ACTION }
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
action { ROOT_ACTION }
description(TextComponent.of("Issue 14"))
description(Component.text("Issue 14"))
addPart(subs(sub, required = false))
addPart(req)
addPart(optAfter)
Expand Down Expand Up @@ -171,10 +170,10 @@ class RegressionTest {
val sub = manager.newCommand("world")
.action { SUB_ACTION }
.aliases(setOf("there"))
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
description(TextComponent.of("hello"))
description(Component.text("hello"))
addPart(subs(sub, required = true))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ package org.enginehub.piston

import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableSet
import net.kyori.text.TextComponent
import net.kyori.text.TranslatableComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.gen.CommandRegistration
import org.enginehub.piston.part.ArgAcceptingCommandFlag
import org.enginehub.piston.part.CommandArgument
Expand Down Expand Up @@ -54,30 +53,30 @@ inline fun <reified CI> withMockedContainer(block: (CI) -> Unit) {

inline fun arg(name: String, desc: String, block: CommandArgument.Builder.() -> Unit = {}): CommandArgument =
CommandParts.arg(
TranslatableComponent.of(name),
TextComponent.of(desc)
Component.translatable(name),
Component.text(desc)
).also(block).build()

inline fun flag(name: Char, desc: String, block: NoArgCommandFlag.Builder.() -> Unit = {}): NoArgCommandFlag =
CommandParts.flag(
name,
TextComponent.of(desc)
Component.text(desc)
).also(block).build()

inline fun argFlag(name: Char, desc: String, argName: String,
block: ArgAcceptingCommandFlag.Builder.() -> Unit = {}): ArgAcceptingCommandFlag =
CommandParts.flag(
name,
TextComponent.of(desc)
Component.text(desc)
)
.withRequiredArg()
.argNamed(argName)
.also(block).build()

fun subs(vararg subCommands: Command, required: Boolean = true): SubCommandPart =
SubCommandPart.builder(
TranslatableComponent.of("actions"),
TextComponent.of("Sub-actions")
SubCommandPart.builder(
Component.translatable("actions"),
Component.text("Sub-actions")
).run {
withCommands(ImmutableList.copyOf(subCommands))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

package org.enginehub.piston.suggestion

import net.kyori.text.Component
import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.converter.ArgumentConverter
import org.enginehub.piston.converter.ConversionResult
import org.enginehub.piston.converter.FailedConversion
Expand All @@ -37,7 +36,7 @@ class EmptyAcceptingSuggestingConverter(private val suggestions: List<String>) :
}

override fun describeAcceptableArguments(): Component {
return TextComponent.of("Empty, or any of $suggestions")
return Component.text("Empty, or any of $suggestions")
}

override fun getSuggestions(input: String, context: InjectedValueAccess): List<String> =
Expand Down
Loading