Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize nullability checks with checkerframework #3918

Merged
merged 1 commit into from
Nov 12, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.common.UntransformedInvokerError;

import java.util.function.IntConsumer;

import javax.annotation.Nullable;

@Mixin(CommandSourceStack.class)
public interface CommandSourceStackAccessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.util.Brightness;
import net.minecraft.world.entity.Display;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.common.UntransformedInvokerError;

import javax.annotation.Nullable;

@Mixin(Display.class)
public interface DisplayAccessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.common.UntransformedInvokerError;

import javax.annotation.Nullable;

@Mixin(AbstractFurnaceBlockEntity.class)
public interface AbstractFurnaceBlockEntityAccessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import net.minecraft.network.chat.ChatDecorator;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.event.CauseStackManager;
import org.spongepowered.api.event.SpongeEventFactory;
import org.spongepowered.api.event.message.PlayerChatEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package org.spongepowered.common.command.registrar;

import io.leangen.geantyref.TypeToken;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.api.command.manager.CommandManager;
import org.spongepowered.api.command.registrar.CommandRegistrar;
import org.spongepowered.api.command.registrar.CommandRegistrarType;
Expand All @@ -52,12 +52,12 @@ public SpongeCommandRegistrarType(
}

@Override
public @NotNull TypeToken<V> handledType() {
public @NonNull TypeToken<V> handledType() {
return this.handledType;
}

@Override
public @NotNull CommandRegistrar<V> create(final CommandManager.@NotNull Mutable manager) {
public @NonNull CommandRegistrar<V> create(final CommandManager.@NonNull Mutable manager) {
return this.supplier.apply(manager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.persistence.DataContainer;
Expand Down Expand Up @@ -136,7 +136,7 @@ private static DataQuery serializeMapKey(final Object value) {
throw new UnsupportedOperationException("Unsupported map-key type " + value.getClass());
}

@NotNull
@NonNull
private static Object serializeArray(final DataView.SafetyMode safetyMode, final Object value) {
switch (safetyMode) {
case ALL_DATA_CLONED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
package org.spongepowered.common.data.provider.entity;

import net.minecraft.world.entity.raid.Raider;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.data.Keys;
import org.spongepowered.common.accessor.world.entity.raid.RaiderAccessor;
import org.spongepowered.common.bridge.world.entity.raid.RaidBridge;
import org.spongepowered.common.data.provider.DataProviderRegistrator;

import javax.annotation.Nullable;

public final class AbstractRaiderData {

private AbstractRaiderData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.util.Brightness;
import net.minecraft.world.entity.Display;
import net.minecraft.world.item.ItemDisplayContext;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.joml.Quaterniond;
import org.joml.Vector3f;
import org.spongepowered.api.block.BlockState;
Expand All @@ -48,8 +49,6 @@

import java.awt.Color;

import javax.annotation.Nullable;

public class DisplayEntityData {

private DisplayEntityData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.data.persistence.DataContainer;
import org.spongepowered.api.data.persistence.DataFormats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package org.spongepowered.common.item.recipe.cooking;

import javax.annotation.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;

public interface ResultFunctionRecipe {
@Nullable String resultFunctionId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
import net.minecraft.core.NonNullList;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.common.SpongeCommon;

import java.text.MessageFormat;
import java.util.Map;
import java.util.function.Function;

import javax.annotation.Nullable;

public final class IngredientResultUtil {

private static final Map<String, Function<?, net.minecraft.world.item.ItemStack>> cachedResultFunctions = new Object2ObjectOpenHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.SmithingTransformRecipe;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.common.item.recipe.cooking.ResultFunctionRecipe;
import org.spongepowered.common.item.recipe.ingredient.IngredientResultUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.StonecutterRecipe;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.common.item.recipe.cooking.ResultFunctionRecipe;
import org.spongepowered.common.item.recipe.ingredient.IngredientResultUtil;

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

import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.util.Strings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.resource.ResourcePath;

Expand Down Expand Up @@ -97,7 +97,7 @@ public String extension() {
}

@Override
public int compareTo(@NotNull final ResourcePath o) {
public int compareTo(@NonNull final ResourcePath o) {
return this.key.compareTo(o.key());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.minecraft.world.level.levelgen.carver.CarverConfiguration;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.carver.WorldCarver;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.data.persistence.DataContainer;
import org.spongepowered.api.data.persistence.DataFormats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import net.minecraft.util.datafix.DataFixTypes;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockState;
Expand Down Expand Up @@ -246,7 +245,7 @@ private static Function<DataView, Optional<EntityArchetypeEntry>> deserializeEnt
};
}

@NotNull
@NonNull
private static Consumer<DataView> deserializeBlockEntities(
final Vector3i offset, final SpongeArchetypeVolume archetypeVolume,
final boolean needsFixers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.PrimaryLevelData;
import net.minecraft.world.level.storage.WorldData;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Server;
import org.spongepowered.api.Sponge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.data.DataManipulator;
Expand Down Expand Up @@ -287,7 +287,7 @@ protected WorldTemplate build0() {
return new SpongeWorldTemplate(this.key, levelStem, this.pack);
}

@NotNull
@NonNull
private static Holder<DimensionType> dimensionTypeHolder(final WorldType worldType) {
final Registry<DimensionType> dimensionTypeRegistry = SpongeCommon.server().registryAccess().registryOrThrow(Registries.DIMENSION_TYPE);
final ResourceLocation key = dimensionTypeRegistry.getKey((DimensionType) (Object) worldType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.trading.MerchantOffer;
import net.minecraft.world.item.trading.MerchantOffers;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.entity.living.Humanoid;
import org.spongepowered.api.item.merchant.Merchant;
Expand All @@ -38,8 +39,6 @@

import java.util.Collections;

import javax.annotation.Nullable;

@Mixin(value = Merchant.class)
@Implements(@Interface(iface = net.minecraft.world.item.trading.Merchant.class, prefix = "imerchant$"))
public interface MerchantMixin_API extends Merchant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.advancements.CriterionProgress;
import net.minecraft.resources.ResourceLocation;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.advancement.AdvancementProgress;
import org.spongepowered.api.advancement.criteria.AdvancementCriterion;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -38,8 +39,6 @@
import java.time.Instant;
import java.util.Optional;

import javax.annotation.Nullable;

@Mixin(CriterionProgress.class)
public abstract class CriterionProgressMixin_API implements org.spongepowered.api.advancement.criteria.CriterionProgress {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.ChatFormatting;
import net.minecraft.advancements.FrameType;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.advancement.AdvancementType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.common.adventure.SpongeAdventure;

import javax.annotation.Nullable;

@Mixin(FrameType.class)
public abstract class FrameTypeMixin_API implements AdvancementType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.Connection;
import net.minecraft.server.packs.repository.PackRepository;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.Game;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.client.LocalServer;
Expand All @@ -51,8 +52,6 @@
import java.util.Locale;
import java.util.Optional;

import javax.annotation.Nullable;

@Mixin(Minecraft.class)
public abstract class MinecraftMixin_API implements SpongeClient, SpongeRegistryHolder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.core.MappedRegistry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryEntry;
Expand All @@ -50,8 +51,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.annotation.Nullable;

@Mixin(MappedRegistry.class)
@Implements(@Interface(iface = Registry.class, prefix = "registry$", remap = Interface.Remap.NONE))
public abstract class MappedRegistryMixin_API<T> implements Registry<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.saveddata.maps.MapDecoration;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.data.persistence.DataContainer;
import org.spongepowered.api.map.decoration.MapDecorationType;
import org.spongepowered.api.map.decoration.orientation.MapDecorationOrientation;
Expand All @@ -40,8 +41,6 @@
import org.spongepowered.common.util.MapUtil;
import org.spongepowered.math.vector.Vector2i;

import javax.annotation.Nullable;

@Mixin(MapDecoration.class)
public abstract class MapDecorationMixin_API implements org.spongepowered.api.map.decoration.MapDecoration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.data.persistence.DataView;
import org.spongepowered.api.network.channel.ChannelBuf;
import org.spongepowered.asm.mixin.Implements;
Expand All @@ -48,8 +49,6 @@
import java.io.IOException;
import java.util.UUID;

import javax.annotation.Nullable;

@Mixin(FriendlyByteBuf.class)
@Implements(@Interface(iface = ChannelBuf.class, prefix = "cbuf$", remap = Remap.NONE))
public abstract class FriendlyByteBufMixin_API extends ByteBuf {
Expand Down
Loading
Loading