Fixed some SonarLint complaints in Model

This commit is contained in:
uogau 2021-03-09 23:00:08 +01:00
parent 92296a8373
commit 232a5e21af
13 changed files with 26 additions and 26 deletions

View File

@ -20,7 +20,7 @@ public class Unification {
*
* @param constraints constraints to execute the unification for
*/
protected Unification(Deque<Constraint> constraints) { // TODO: document List->Deque
protected Unification(Deque<Constraint> constraints) {
steps = new ArrayList<>();
List<Substitution> substitutions = new ArrayList<>();

View File

@ -12,7 +12,7 @@ import java.util.Set;
/**
* Representation of an abstraction term with its two sub-lambda terms.
*/
public class AbsTerm extends LambdaTerm {
public class AbsTerm implements LambdaTerm {
private final VarTerm var;
private final LambdaTerm body;

View File

@ -9,7 +9,7 @@ import java.util.*;
/**
* Representation of an application term consisting of a function and the parameter passed to it.
*/
public class AppTerm extends LambdaTerm {
public class AppTerm implements LambdaTerm {
private final LambdaTerm left;
private final LambdaTerm right;

View File

@ -12,7 +12,7 @@ import java.util.Set;
/**
* Abstract representation of a constant lambda term that has a predetermined type and a value of that type.
*/
public abstract class ConstTerm extends LambdaTerm {
public abstract class ConstTerm implements LambdaTerm {
/**
* Returns the named type of the constant

View File

@ -12,27 +12,27 @@ import java.util.Set;
* Depending on the subclass used, a lambda term may contain several other lambda terms
* and thus form a tree-like structure of lambda terms.
*/
public abstract class LambdaTerm {
public interface LambdaTerm {
/**
* Returns whether the lambda term contains a let expression
*
* @return whether the lambda term contains a let expression
*/
public abstract boolean hasLet();
boolean hasLet();
/**
* Returns a set of all free variables occurring in the lambda term.
*
* @return all free variables
*/
public abstract Set<VarTerm> getFreeVariables();
Set<VarTerm> getFreeVariables();
/**
* Calls exactly one method on the visitor depending on the lambda term type.
*
* @param termVisitor a visitor
*/
public abstract void accept(TermVisitor termVisitor);
void accept(TermVisitor termVisitor);
/**
* Uses exactly one method of the visitor and provides the arguments passed.
@ -42,6 +42,6 @@ public abstract class LambdaTerm {
* @param type a type
* @return the result returned by the visitor
*/
public abstract InferenceStep accept(TermVisitorTree termVisitorTree,
InferenceStep accept(TermVisitorTree termVisitorTree,
Map<VarTerm, TypeAbstraction> assumptions, Type type);
}

View File

@ -13,7 +13,7 @@ import java.util.Set;
* Representation of a let term with its variable, the lambda term assigned
* to this variable and the lambda term the variable is used in.
*/
public class LetTerm extends LambdaTerm {
public class LetTerm implements LambdaTerm {
private final VarTerm variable;
private final LambdaTerm definition;
private final LambdaTerm body;

View File

@ -9,7 +9,7 @@ import java.util.*;
/**
* Representation of a variable term with its name.
*/
public class VarTerm extends LambdaTerm {
public class VarTerm implements LambdaTerm {
private final String name;
/**

View File

@ -10,7 +10,7 @@ import java.util.Set;
/**
* Models the type of an abstraction/function.
*/
public class FunctionType extends Type {
public class FunctionType implements Type {
private final Type parameter;
private final Type output;

View File

@ -10,7 +10,7 @@ import java.util.Set;
/**
* Models a simple named type.
*/
public class NamedType extends Type {
public class NamedType implements Type {
/**
* boolean type
*/

View File

@ -9,21 +9,21 @@ import java.util.Set;
/**
* Models the type of a lambda term.
*/
public abstract class Type {
public interface Type {
/**
* Checks whether some type occurs in this type.
*
* @param x the type to look for
* @return whether the specified type occurs in this type
*/
public abstract boolean contains(Type x);
boolean contains(Type x);
/**
* Returns a set of all free type variables occurring in the type.
*
* @return all free type variables
*/
public abstract Set<TypeVariable> getFreeTypeVariables();
Set<TypeVariable> getFreeTypeVariables();
/**
* Substitutes a type Variable for a different type.
@ -32,7 +32,7 @@ public abstract class Type {
* @param b the type to insert
* @return a Type that is created by replacing a with b
*/
public abstract Type substitute(TypeVariable a, Type b);
Type substitute(TypeVariable a, Type b);
/**
* Applies the given substitution to the type.
@ -40,7 +40,7 @@ public abstract class Type {
* @param substitution the substitution to apply to the type
* @return the substituted type
*/
public Type substitute(Substitution substitution) {
default Type substitute(Substitution substitution) {
return substitute(substitution.getVariable(), substitution.getType());
}
@ -49,7 +49,7 @@ public abstract class Type {
*
* @param typeVisitor the visitor that wants to visit this
*/
public abstract void accept(TypeVisitor typeVisitor);
void accept(TypeVisitor typeVisitor);
/**
* Computes the necessary constraints (and substitution) to unify this type with
@ -58,7 +58,7 @@ public abstract class Type {
* @param type the other type
* @return unification steps necessary, or an error if that is impossible
*/
public abstract Result<UnificationActions, UnificationError> constrainEqualTo(Type type);
Result<UnificationActions, UnificationError> constrainEqualTo(Type type);
/**
* Computes the necessary constraints (and substitution) to unify this type with a
@ -67,7 +67,7 @@ public abstract class Type {
* @param type the function type
* @return unification steps necessary, or an error if that is impossible
*/
public abstract Result<UnificationActions, UnificationError> constrainEqualToFunction(FunctionType type);
Result<UnificationActions, UnificationError> constrainEqualToFunction(FunctionType type);
/**
* Computes the necessary constraints (and substitution) to unify this type with a
@ -76,7 +76,7 @@ public abstract class Type {
* @param type the named type
* @return unification steps necessary, or an error if that is impossible
*/
public abstract Result<UnificationActions, UnificationError> constrainEqualToNamedType(NamedType type);
Result<UnificationActions, UnificationError> constrainEqualToNamedType(NamedType type);
/**
* Computes the necessary constraints (and substitution) to unify this type with a
@ -85,5 +85,5 @@ public abstract class Type {
* @param type the type variable
* @return the unification steps necessary, or an error if that is impossible
*/
public abstract Result<UnificationActions, UnificationError> constrainEqualToVariable(TypeVariable type);
Result<UnificationActions, UnificationError> constrainEqualToVariable(TypeVariable type);
}

View File

@ -8,7 +8,7 @@ import java.util.*;
/**
* Models a type variable
*/
public class TypeVariable extends Type implements Comparable<TypeVariable> {
public class TypeVariable implements Type, Comparable<TypeVariable> {
private final TypeVariableKind kind;
private final int index;

View File

@ -71,7 +71,7 @@ public class Result<T, E> {
* @return the value
* @throws IllegalStateException if this is an error
*/
public T unwrap() throws IllegalStateException {
public T unwrap() {
if (value == null) {
throw new IllegalStateException("tried to unwrap a result, but error = " + error);
}

View File

@ -45,7 +45,7 @@ public class TypeAssumptionField extends HorizontalLayout implements LocaleChang
'\u2085', '\u2086', '\u2087', '\u2088', '\u2089');
private static final char TAU = '\u03C4';
private final TypeAssumptionParser parser = new TypeAssumptionParser();
private final transient TypeAssumptionParser parser = new TypeAssumptionParser();
private final TextField variableInputField;
private final TextField typeInputField;