warning cleanup

This commit is contained in:
gnembon committed 2023-02-08 21:13:15 +01:00
1 parent 5ab4a9e442
commit 277872b33c
106 files changed
+4495 -4345

No files matched your search

@@ -2,9 +2,11 @@ package carpet.script.exception;
import carpet.script.value.Value;
import javax.annotation.Nullable;
public class BreakStatement extends ExitStatement
{
public BreakStatement(final Value value)
public BreakStatement(@Nullable Value value)
{
super(value);
}
@@ -11,17 +11,17 @@ public class CarpetExpressionException extends StacklessRuntimeException impleme
{
public final List<FunctionValue> stack;
public CarpetExpressionException(final String message, final List<FunctionValue> stack)
public CarpetExpressionException(String message, List<FunctionValue> stack)
{
super(message);
this.stack = stack;
}
public void printStack(final CommandSourceStack source)
public void printStack(CommandSourceStack source)
{
if (stack != null && !stack.isEmpty())
{
for (final FunctionValue fun : stack)
for (FunctionValue fun : stack)
{
Carpet.Messenger_message(source, "e ... in " + fun.fullName(), "e /" + (fun.getToken().lineno + 1) + ":" + (fun.getToken().linepos + 1));
}
@@ -2,9 +2,11 @@ package carpet.script.exception;
import carpet.script.value.Value;
import javax.annotation.Nullable;
public class ContinueStatement extends ExitStatement
{
public ContinueStatement(final Value value)
public ContinueStatement(@Nullable Value value)
{
super(value);
}
@@ -2,12 +2,15 @@ package carpet.script.exception;
import carpet.script.value.Value;
import javax.annotation.Nullable;
/* Exception thrown to terminate execution mid expression (aka return statement) */
public class ExitStatement extends StacklessRuntimeException
{
@Nullable
public final Value retval;
public ExitStatement(final Value value)
public ExitStatement(@Nullable Value value)
{
retval = value;
}
@@ -6,6 +6,7 @@ import carpet.script.Tokenizer;
import carpet.script.external.Carpet;
import carpet.script.value.FunctionValue;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -25,17 +26,17 @@ public class ExpressionException extends StacklessRuntimeException implements Re
Carpet.Messenger_compose("foo bar");
}
public ExpressionException(final Context c, final Expression e, final String message)
public ExpressionException(Context c, Expression e, String message)
{
this(c, e, Tokenizer.Token.NONE, message);
}
public ExpressionException(final Context c, final Expression e, final Tokenizer.Token t, final String message)
public ExpressionException(Context c, Expression e, Tokenizer.Token t, String message)
{
this(c, e, t, message, Collections.emptyList());
}
public ExpressionException(final Context c, final Expression e, final Tokenizer.Token t, final String message, final List<FunctionValue> stack)
public ExpressionException(Context c, Expression e, Tokenizer.Token t, String message, List<FunctionValue> stack)
{
super("Error");
this.stack.addAll(stack);
@@ -44,7 +45,7 @@ public class ExpressionException extends StacklessRuntimeException implements Re
context = c;
}
public ExpressionException(final Context c, final Expression e, final Tokenizer.Token t, final Supplier<String> messageSupplier, final List<FunctionValue> stack)
public ExpressionException(Context c, Expression e, Tokenizer.Token t, Supplier<String> messageSupplier, List<FunctionValue> stack)
{
super("Error");
this.stack.addAll(stack);
@@ -53,13 +54,13 @@ public class ExpressionException extends StacklessRuntimeException implements Re
context = c;
}
private static List<String> makeError(final Expression expr, /*Nullable*/final Tokenizer.Token token, String errmessage)
private static List<String> makeError(Expression expr, @Nullable Tokenizer.Token token, String errmessage)
{
final List<String> errMsg = new ArrayList<>();
List<String> errMsg = new ArrayList<>();
errmessage += expr.getModuleName() == null ? "" : (" in " + expr.getModuleName());
if (token != null)
{
final List<String> snippet = expr.getExpressionSnippet(token);
List<String> snippet = expr.getExpressionSnippet(token);
errMsg.addAll(snippet);
if (snippet.size() != 1)
@@ -75,11 +76,11 @@ public class ExpressionException extends StacklessRuntimeException implements Re
return errMsg;
}
static synchronized String makeMessage(final Context c, final Expression e, final Tokenizer.Token t, final String message) throws ExpressionException
static synchronized String makeMessage(Context c, Expression e, Tokenizer.Token t, String message) throws ExpressionException
{
if (c.getErrorSnooper() != null)
{
final List<String> alternative = c.getErrorSnooper().apply(e, t, c, message);
List<String> alternative = c.getErrorSnooper().apply(e, t, c, message);
if (alternative != null)
{
return String.join("\n", alternative);
@@ -2,7 +2,7 @@ package carpet.script.exception;
public class IntegrityException extends RuntimeException
{
public IntegrityException(final String message)
public IntegrityException(String message)
{
super(message);
}
@@ -13,7 +13,7 @@ public class InternalExpressionException extends StacklessRuntimeException
{
public List<FunctionValue> stack = new ArrayList<>();
public InternalExpressionException(final String message)
public InternalExpressionException(String message)
{
super(message);
}
@@ -30,7 +30,7 @@ public class InternalExpressionException extends StacklessRuntimeException
* @return The new {@link ExpressionException} (or {@link ProcessedThrowStatement}),
* depending on the implementation.
*/
public ExpressionException promote(final Context c, final Expression e, final Tokenizer.Token token)
public ExpressionException promote(Context c, Expression e, Tokenizer.Token token)
{
return new ExpressionException(c, e, token, getMessage(), stack);
}
@@ -12,7 +12,7 @@ public class LoadException extends RuntimeException implements ResolvedException
{
super();
}
public LoadException(final String message)
public LoadException(String message)
{
super(message);
}
@@ -13,7 +13,7 @@ public class ProcessedThrowStatement extends ExpressionException
public final Throwables thrownExceptionType;
public final Value data;
public ProcessedThrowStatement(final Context c, final Expression e, final Token token, final List<FunctionValue> stack, final Throwables thrownExceptionType, final Value data)
public ProcessedThrowStatement(Context c, Expression e, Token token, List<FunctionValue> stack, Throwables thrownExceptionType, Value data)
{
super(c, e, token, () -> "Unhandled " + thrownExceptionType.getId() + " exception: " + data.getString(), stack);
this.thrownExceptionType = thrownExceptionType;
@@ -4,7 +4,7 @@ import carpet.script.value.Value;
public class ReturnStatement extends ExitStatement
{
public ReturnStatement(final Value value)
public ReturnStatement(Value value)
{
super(value);
}
@@ -10,7 +10,7 @@ public abstract class StacklessRuntimeException extends RuntimeException
super();
}
public StacklessRuntimeException(final String message)
public StacklessRuntimeException(String message)
{
super(message);
}
@@ -18,14 +18,14 @@ public class ThrowStatement extends InternalExpressionException
* @param data The value to pass
* @param type Exception type
*/
public ThrowStatement(final Value data, final Throwables type)
public ThrowStatement(Value data, Throwables type)
{
super(type.getId());
this.data = data;
this.type = type;
}
public ThrowStatement(final Value data, final Throwables parent, final String subtype)
public ThrowStatement(Value data, Throwables parent, String subtype)
{
super(subtype);
this.data = data;
@@ -42,7 +42,7 @@ public class ThrowStatement extends InternalExpressionException
* for this exception. When throwing from Java,
* those exceptions should be pre-registered.
*/
public ThrowStatement(final String message, final Throwables type)
public ThrowStatement(String message, Throwables type)
{
super(type.getId());
this.data = StringValue.of(message);
@@ -50,7 +50,7 @@ public class ThrowStatement extends InternalExpressionException
}
@Override
public ExpressionException promote(final Context c, final Expression e, final Token token)
public ExpressionException promote(Context c, Expression e, Token token)
{
return new ProcessedThrowStatement(c, e, token, stack, type, data);
}
@@ -1,5 +1,6 @@
package carpet.script.exception;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -10,6 +11,7 @@ import java.util.Map;
public class Throwables
{
private final String id;
@Nullable
private final Throwables parent;
private static final Map<String, Throwables> byId = new HashMap<>();
@@ -41,9 +43,9 @@ public class Throwables
* @param parent The parent of the exception being created, or <code>null</code> if top-level
* @return The created exception
*/
public static Throwables register(final String id, final Throwables parent)
public static Throwables register(String id, @Nullable Throwables parent)
{
final Throwables exc = new Throwables(id, parent);
Throwables exc = new Throwables(id, parent);
byId.put(id, exc);
return exc;
}
@@ -55,15 +57,15 @@ public class Throwables
*
* @param id The exception's value as a {@link String}
*/
public Throwables(final String id, final Throwables parent)
public Throwables(String id, @Nullable Throwables parent)
{
this.id = id;
this.parent = parent;
}
public static Throwables getTypeForException(final String type)
public static Throwables getTypeForException(String type)
{
final Throwables properType = byId.get(type);
Throwables properType = byId.get(type);
if (properType == null)
{
throw new InternalExpressionException("Unknown exception type: " + type);
@@ -78,7 +80,7 @@ public class Throwables
* @param filter The type to check against
* @return Whether or not the given value matches this exception's hierarchy
*/
public boolean isRelevantFor(final String filter)
public boolean isRelevantFor(String filter)
{
return (id.equals(filter) || (parent != null && parent.isRelevantFor(filter)));
}