mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-20 19:04:44 -04:00
Remove leftover @ApiStatus.Internal
annotations and add annotation validation (#2825)
* Remove leftover `@ApiStatus.Internal` annotations and add annotation validation * Simplify * Simplify more * Update gradle/validate-annotations.gradle Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com> Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>
This commit is contained in:
parent
abdb4ad90b
commit
1134c5b850
19 changed files with 41 additions and 104 deletions
build.gradle
fabric-client-tags-api-v1/src/client/java/net/fabricmc/fabric/impl/tag/client
fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen
fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/impl/gametest
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item
fabric-item-group-api-v1/src
client/java/net/fabricmc/fabric/impl/client/itemgroup
main/java/net/fabricmc/fabric/impl/itemgroup
fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync
fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions
gradle
|
@ -280,6 +280,7 @@ allprojects {
|
|||
|
||||
// Apply to each valid subproject.
|
||||
apply from: rootProject.file('gradle/package-info.gradle')
|
||||
apply from: rootProject.file('gradle/validate-annotations.gradle')
|
||||
}
|
||||
|
||||
remapTestmodJar {
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.google.gson.JsonElement;
|
|||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -46,7 +45,6 @@ import net.fabricmc.fabric.api.tag.client.v1.ClientTags;
|
|||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ClientTagsLoader {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("fabric-client-tags-api-v1");
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.concurrent.CompletableFuture;
|
|||
import com.mojang.logging.LogUtils;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -50,7 +49,6 @@ import net.fabricmc.loader.api.FabricLoader;
|
|||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class FabricDataGenHelper {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FabricDataGenHelper.class);
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package net.fabricmc.fabric.impl.datagen;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public interface FabricTagBuilder {
|
||||
void fabric_setReplace(boolean replace);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Map;
|
|||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.test.TestFunctions;
|
||||
|
||||
|
@ -30,7 +29,6 @@ import net.fabricmc.api.ModInitializer;
|
|||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class FabricGameTestModInitializer implements ModInitializer {
|
||||
private static final String ENTRYPOINT_KEY = "fabric-gametest";
|
||||
private static final Map<Class<?>, String> GAME_TEST_IDS = new HashMap<>();
|
||||
|
|
|
@ -16,11 +16,8 @@
|
|||
|
||||
package net.fabricmc.fabric.impl.item;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class RecipeRemainderHandler {
|
||||
public static final ThreadLocal<ItemStack> REMAINDER_STACK = new ThreadLocal<>();
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package net.fabricmc.fabric.impl.client.itemgroup;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public interface CreativeGuiExtensions {
|
||||
void fabric_nextPage();
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
@ -30,7 +29,6 @@ import net.minecraft.item.ItemGroups;
|
|||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class FabricCreativeGuiComponents {
|
||||
private static final Identifier BUTTON_TEX = new Identifier("fabric", "textures/gui/creative_buttons.png");
|
||||
public static final Set<ItemGroup> COMMON_GROUPS = Set.of(ItemGroups.SEARCH, ItemGroups.INVENTORY, ItemGroups.HOTBAR);
|
||||
|
|
|
@ -18,12 +18,9 @@ package net.fabricmc.fabric.impl.itemgroup;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class FabricItemGroupBuilderImpl extends ItemGroup.Builder {
|
||||
private final Identifier identifier;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package net.fabricmc.fabric.impl.itemgroup;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -28,7 +27,6 @@ import net.fabricmc.fabric.api.event.Event;
|
|||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ItemGroupEventsImpl {
|
||||
private static final Map<Identifier, Event<ItemGroupEvents.ModifyEntries>> IDENTIFIER_EVENT_MAP = new HashMap<>();
|
||||
|
||||
|
|
|
@ -19,14 +19,11 @@ package net.fabricmc.fabric.impl.itemgroup;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
|
||||
import net.fabricmc.fabric.mixin.itemgroup.ItemGroupsAccessor;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ItemGroupHelper {
|
||||
private ItemGroupHelper() {
|
||||
}
|
||||
|
|
|
@ -19,13 +19,11 @@ package net.fabricmc.fabric.impl.itemgroup;
|
|||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class MinecraftItemGroups {
|
||||
public static final Identifier BUILDING_BLOCKS_ID = new Identifier("minecraft:building_blocks");
|
||||
public static final Identifier COLOURED_BLOCKS_ID = new Identifier("minecraft:colored_blocks");
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains the Registry Sync implementation.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package net.fabricmc.fabric.impl.registry.sync;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains packet handlers used by Registry Sync.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package net.fabricmc.fabric.impl.registry.sync.packet;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains remap state trackers.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package net.fabricmc.fabric.impl.registry.sync.trackers;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
|
@ -18,8 +18,6 @@ package net.fabricmc.fabric.impl.registry.sync.trackers.vanilla;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -30,7 +28,6 @@ import net.minecraft.registry.Registry;
|
|||
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
|
||||
import net.fabricmc.fabric.mixin.registry.sync.DebugChunkGeneratorAccessor;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class BlockInitTracker implements RegistryEntryAddedCallback<Block> {
|
||||
private final Registry<Block> registry;
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package net.fabricmc.fabric.impl.registry.sync.trackers.vanilla;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -25,7 +23,6 @@ import net.minecraft.registry.Registry;
|
|||
|
||||
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class BlockItemTracker implements RegistryEntryAddedCallback<Item> {
|
||||
private BlockItemTracker() { }
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -48,7 +47,6 @@ import net.minecraft.util.JsonHelper;
|
|||
import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ResourceConditionsImpl {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("Fabric Resource Conditions");
|
||||
|
||||
|
|
40
gradle/validate-annotations.gradle
Normal file
40
gradle/validate-annotations.gradle
Normal file
|
@ -0,0 +1,40 @@
|
|||
task validateAnnotations(type: ValidateAnnotations) {
|
||||
group = 'fabric'
|
||||
description = "Validate annotations used in Fabric API code."
|
||||
|
||||
// Only apply to default source directories since there's also generated package-info files.
|
||||
source file("src/client/java")
|
||||
source file("src/main/java")
|
||||
}
|
||||
|
||||
tasks.check.dependsOn validateAnnotations
|
||||
|
||||
class ValidateAnnotations extends SourceTask {
|
||||
private static final def API_STATUS_INTERNAL = ~/@ApiStatus\.Internal/
|
||||
private static final def ENVIRONMENT = ~/@Environment/
|
||||
|
||||
@TaskAction
|
||||
def run() {
|
||||
for (def dir in ['api', 'impl', 'mixin']) {
|
||||
getSource().matching { include "net/fabricmc/fabric/$dir/" }.forEach {
|
||||
if (it.isDirectory()) {
|
||||
return
|
||||
}
|
||||
|
||||
def contents = it.text
|
||||
|
||||
// @Environment is never allowed
|
||||
if (ENVIRONMENT.matcher(contents).find()) {
|
||||
throw new RuntimeException("Found @Environment annotation in file: $it")
|
||||
}
|
||||
|
||||
// @ApiStatus.Internal is only allowed in api packages (it's auto-generated for impl and mixin packages)
|
||||
if (dir != "api") {
|
||||
if (API_STATUS_INTERNAL.matcher(contents).find()) {
|
||||
throw new RuntimeException("Found @ApiStatus.Internal in implementation file: " + it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue