mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Fixed some SonarLint complaints in Model
This commit is contained in:
parent
92296a8373
commit
232a5e21af
@ -20,7 +20,7 @@ public class Unification {
|
|||||||
*
|
*
|
||||||
* @param constraints constraints to execute the unification for
|
* @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<>();
|
steps = new ArrayList<>();
|
||||||
List<Substitution> substitutions = new ArrayList<>();
|
List<Substitution> substitutions = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Representation of an abstraction term with its two sub-lambda terms.
|
* 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 VarTerm var;
|
||||||
private final LambdaTerm body;
|
private final LambdaTerm body;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import java.util.*;
|
|||||||
/**
|
/**
|
||||||
* Representation of an application term consisting of a function and the parameter passed to it.
|
* 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 left;
|
||||||
private final LambdaTerm right;
|
private final LambdaTerm right;
|
||||||
|
|
||||||
|
@ -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.
|
* 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
|
* Returns the named type of the constant
|
||||||
|
@ -12,27 +12,27 @@ import java.util.Set;
|
|||||||
* Depending on the subclass used, a lambda term may contain several other lambda terms
|
* Depending on the subclass used, a lambda term may contain several other lambda terms
|
||||||
* and thus form a tree-like structure of 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
|
* Returns whether the lambda term contains a let expression
|
||||||
*
|
*
|
||||||
* @return 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.
|
* Returns a set of all free variables occurring in the lambda term.
|
||||||
*
|
*
|
||||||
* @return all free variables
|
* @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.
|
* Calls exactly one method on the visitor depending on the lambda term type.
|
||||||
*
|
*
|
||||||
* @param termVisitor a visitor
|
* @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.
|
* Uses exactly one method of the visitor and provides the arguments passed.
|
||||||
@ -42,6 +42,6 @@ public abstract class LambdaTerm {
|
|||||||
* @param type a type
|
* @param type a type
|
||||||
* @return the result returned by the visitor
|
* @return the result returned by the visitor
|
||||||
*/
|
*/
|
||||||
public abstract InferenceStep accept(TermVisitorTree termVisitorTree,
|
InferenceStep accept(TermVisitorTree termVisitorTree,
|
||||||
Map<VarTerm, TypeAbstraction> assumptions, Type type);
|
Map<VarTerm, TypeAbstraction> assumptions, Type type);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import java.util.Set;
|
|||||||
* Representation of a let term with its variable, the lambda term assigned
|
* Representation of a let term with its variable, the lambda term assigned
|
||||||
* to this variable and the lambda term the variable is used in.
|
* 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 VarTerm variable;
|
||||||
private final LambdaTerm definition;
|
private final LambdaTerm definition;
|
||||||
private final LambdaTerm body;
|
private final LambdaTerm body;
|
||||||
|
@ -9,7 +9,7 @@ import java.util.*;
|
|||||||
/**
|
/**
|
||||||
* Representation of a variable term with its name.
|
* Representation of a variable term with its name.
|
||||||
*/
|
*/
|
||||||
public class VarTerm extends LambdaTerm {
|
public class VarTerm implements LambdaTerm {
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Models the type of an abstraction/function.
|
* Models the type of an abstraction/function.
|
||||||
*/
|
*/
|
||||||
public class FunctionType extends Type {
|
public class FunctionType implements Type {
|
||||||
|
|
||||||
private final Type parameter;
|
private final Type parameter;
|
||||||
private final Type output;
|
private final Type output;
|
||||||
|
@ -10,7 +10,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Models a simple named type.
|
* Models a simple named type.
|
||||||
*/
|
*/
|
||||||
public class NamedType extends Type {
|
public class NamedType implements Type {
|
||||||
/**
|
/**
|
||||||
* boolean type
|
* boolean type
|
||||||
*/
|
*/
|
||||||
|
@ -9,21 +9,21 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Models the type of a lambda term.
|
* Models the type of a lambda term.
|
||||||
*/
|
*/
|
||||||
public abstract class Type {
|
public interface Type {
|
||||||
/**
|
/**
|
||||||
* Checks whether some type occurs in this type.
|
* Checks whether some type occurs in this type.
|
||||||
*
|
*
|
||||||
* @param x the type to look for
|
* @param x the type to look for
|
||||||
* @return whether the specified type occurs in this type
|
* @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.
|
* Returns a set of all free type variables occurring in the type.
|
||||||
*
|
*
|
||||||
* @return all free type variables
|
* @return all free type variables
|
||||||
*/
|
*/
|
||||||
public abstract Set<TypeVariable> getFreeTypeVariables();
|
Set<TypeVariable> getFreeTypeVariables();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Substitutes a type Variable for a different type.
|
* Substitutes a type Variable for a different type.
|
||||||
@ -32,7 +32,7 @@ public abstract class Type {
|
|||||||
* @param b the type to insert
|
* @param b the type to insert
|
||||||
* @return a Type that is created by replacing a with b
|
* @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.
|
* Applies the given substitution to the type.
|
||||||
@ -40,7 +40,7 @@ public abstract class Type {
|
|||||||
* @param substitution the substitution to apply to the type
|
* @param substitution the substitution to apply to the type
|
||||||
* @return the substituted type
|
* @return the substituted type
|
||||||
*/
|
*/
|
||||||
public Type substitute(Substitution substitution) {
|
default Type substitute(Substitution substitution) {
|
||||||
return substitute(substitution.getVariable(), substitution.getType());
|
return substitute(substitution.getVariable(), substitution.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public abstract class Type {
|
|||||||
*
|
*
|
||||||
* @param typeVisitor the visitor that wants to visit this
|
* @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
|
* Computes the necessary constraints (and substitution) to unify this type with
|
||||||
@ -58,7 +58,7 @@ public abstract class Type {
|
|||||||
* @param type the other type
|
* @param type the other type
|
||||||
* @return unification steps necessary, or an error if that is impossible
|
* @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
|
* 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
|
* @param type the function type
|
||||||
* @return unification steps necessary, or an error if that is impossible
|
* @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
|
* 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
|
* @param type the named type
|
||||||
* @return unification steps necessary, or an error if that is impossible
|
* @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
|
* 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
|
* @param type the type variable
|
||||||
* @return the unification steps necessary, or an error if that is impossible
|
* @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);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import java.util.*;
|
|||||||
/**
|
/**
|
||||||
* Models a type variable
|
* 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 TypeVariableKind kind;
|
||||||
private final int index;
|
private final int index;
|
||||||
|
@ -71,7 +71,7 @@ public class Result<T, E> {
|
|||||||
* @return the value
|
* @return the value
|
||||||
* @throws IllegalStateException if this is an error
|
* @throws IllegalStateException if this is an error
|
||||||
*/
|
*/
|
||||||
public T unwrap() throws IllegalStateException {
|
public T unwrap() {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new IllegalStateException("tried to unwrap a result, but error = " + error);
|
throw new IllegalStateException("tried to unwrap a result, but error = " + error);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class TypeAssumptionField extends HorizontalLayout implements LocaleChang
|
|||||||
'\u2085', '\u2086', '\u2087', '\u2088', '\u2089');
|
'\u2085', '\u2086', '\u2087', '\u2088', '\u2089');
|
||||||
private static final char TAU = '\u03C4';
|
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 variableInputField;
|
||||||
private final TextField typeInputField;
|
private final TextField typeInputField;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user