Skip to content
Permalink
Browse files

Add new compiler warnings for deprecated functions

  • Loading branch information...
PseudoKnight committed Sep 9, 2019
1 parent 991b486 commit 340b111ac21209043587864362593500bd2b0f96
@@ -12,6 +12,8 @@
import com.laytonsmith.core.Optimizable;
import com.laytonsmith.core.ParseTree;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.compiler.CompilerEnvironment;
import com.laytonsmith.core.compiler.CompilerWarning;
import com.laytonsmith.core.compiler.FileOptions;
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
@@ -137,7 +139,7 @@ private static int getValue(char l) { //Converts the numeral to a number

@api(environments = {CommandHelperEnvironment.class})
@hide("Deprecated for enchant_item().")
public static class enchant_inv extends AbstractFunction {
public static class enchant_inv extends AbstractFunction implements Optimizable {

@Override
public String getName() {
@@ -224,6 +226,21 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
return CVoid.VOID;
}

@Override
public ParseTree optimizeDynamic(Target t, Environment env,
Set<Class<? extends Environment.EnvironmentImpl>> envs,
List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions,
new CompilerWarning(getName() + " is deprecated for enchant_item().", t, null));
return null;
}

@Override
public Set<Optimizable.OptimizationOption> optimizationOptions() {
return EnumSet.of(Optimizable.OptimizationOption.OPTIMIZE_DYNAMIC);
}
}

@api(environments = {CommandHelperEnvironment.class})
@@ -307,7 +324,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi

@api(environments = {CommandHelperEnvironment.class})
@hide("Deprecated for remove_item_enchant()")
public static class enchant_rm_inv extends AbstractFunction {
public static class enchant_rm_inv extends AbstractFunction implements Optimizable {

@Override
public String getName() {
@@ -377,6 +394,21 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
return CVoid.VOID;
}

@Override
public ParseTree optimizeDynamic(Target t, Environment env,
Set<Class<? extends Environment.EnvironmentImpl>> envs,
List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions,
new CompilerWarning(getName() + " is deprecated for remove_item_enchant().", t, null));
return null;
}

@Override
public Set<Optimizable.OptimizationOption> optimizationOptions() {
return EnumSet.of(Optimizable.OptimizationOption.OPTIMIZE_DYNAMIC);
}
}

@api(environments = {CommandHelperEnvironment.class})
@@ -456,7 +488,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi

@api(environments = {CommandHelperEnvironment.class})
@hide("Deprecated for get_item_enchants()")
public static class get_enchant_inv extends AbstractFunction {
public static class get_enchant_inv extends AbstractFunction implements Optimizable {

@Override
public String getName() {
@@ -523,6 +555,21 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi

return new CArray(t, enchants, levels);
}

@Override
public ParseTree optimizeDynamic(Target t, Environment env,
Set<Class<? extends Environment.EnvironmentImpl>> envs,
List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions,
new CompilerWarning(getName() + " is deprecated for get_item_enchants().", t, null));
return null;
}

@Override
public Set<Optimizable.OptimizationOption> optimizationOptions() {
return EnumSet.of(Optimizable.OptimizationOption.OPTIMIZE_DYNAMIC);
}
}

@api(environments = {CommandHelperEnvironment.class})
@@ -638,7 +685,8 @@ public ParseTree optimizeDynamic(Target t, Environment env,
Set<Class<? extends Environment.EnvironmentImpl>> envs, List<ParseTree> children,
FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, getName() + " is deprecated for can_enchant_item()", t);
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions,
new CompilerWarning(getName() + " is deprecated for can_enchant_item().", t, null));
return null;
}

@@ -34,6 +34,8 @@
import com.laytonsmith.core.Optimizable;
import com.laytonsmith.core.ParseTree;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.compiler.CompilerEnvironment;
import com.laytonsmith.core.compiler.CompilerWarning;
import com.laytonsmith.core.compiler.FileOptions;
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
@@ -78,7 +80,7 @@ public static String docs() {

@api(environments = {CommandHelperEnvironment.class})
@hide("Deprecated for spawn_entity().")
public static class spawn_mob extends AbstractFunction {
public static class spawn_mob extends AbstractFunction implements Optimizable {

// The max amount of mobs that can be spawned at once by this function.
private static final int SPAWN_LIMIT = 10000;
@@ -178,6 +180,21 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommand
throw new CREFormatException("Invalid mob name: " + mob, t);
}
}

@Override
public ParseTree optimizeDynamic(Target t, Environment env,
Set<Class<? extends Environment.EnvironmentImpl>> envs,
List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions,
new CompilerWarning(getName() + " is deprecated for spawn_entity().", t, null));
return null;
}

@Override
public Set<Optimizable.OptimizationOption> optimizationOptions() {
return EnumSet.of(Optimizable.OptimizationOption.OPTIMIZE_DYNAMIC);
}
}

@api(environments = {CommandHelperEnvironment.class})
@@ -262,7 +279,8 @@ public ParseTree optimizeDynamic(Target t, Environment env,
Set<Class<? extends Environment.EnvironmentImpl>> envs,
List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The function tame_mob() is deprecated for set_mob_owner().", t);
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions,
new CompilerWarning(getName() + " is deprecated for set_mob_owner().", t, null));
return null;
}

0 comments on commit 340b111

Please sign in to comment.
You can’t perform that action at this time.