From 6fc73d1a3f5d5e222372b502aa5b93847bb28f21 Mon Sep 17 00:00:00 2001 From: ucrhh Date: Fri, 19 Feb 2021 22:56:25 +0100 Subject: [PATCH 1/2] reformat, sanitize docs --- .../java/edu/kit/typicalc/Application.java | 3 +- .../edu/kit/typicalc/model/Conclusion.java | 10 +++- .../edu/kit/typicalc/model/Constraint.java | 4 ++ .../java/edu/kit/typicalc/model/Model.java | 11 ++-- .../edu/kit/typicalc/model/ModelImpl.java | 6 +-- .../edu/kit/typicalc/model/Substitution.java | 4 ++ .../java/edu/kit/typicalc/model/Tree.java | 10 ++-- .../typicalc/model/TypeInferenceResult.java | 4 +- .../edu/kit/typicalc/model/TypeInferer.java | 2 +- .../kit/typicalc/model/TypeInfererLet.java | 4 +- .../edu/kit/typicalc/model/Unification.java | 3 ++ .../kit/typicalc/model/UnificationStep.java | 9 ++-- .../edu/kit/typicalc/model/package-info.java | 16 +++--- .../typicalc/model/parser/LambdaLexer.java | 6 ++- .../kit/typicalc/model/parser/ParseError.java | 2 +- .../edu/kit/typicalc/model/parser/Token.java | 6 ++- .../typicalc/model/parser/package-info.java | 4 +- .../edu/kit/typicalc/model/step/AbsStep.java | 4 +- .../typicalc/model/step/AbsStepDefault.java | 4 +- .../typicalc/model/step/AbsStepWithLet.java | 4 +- .../edu/kit/typicalc/model/step/AppStep.java | 10 ++-- .../typicalc/model/step/AppStepDefault.java | 8 +-- .../kit/typicalc/model/step/ConstStep.java | 1 + .../typicalc/model/step/ConstStepDefault.java | 2 + .../edu/kit/typicalc/model/step/LetStep.java | 14 +++-- .../typicalc/model/step/LetStepDefault.java | 8 +-- .../kit/typicalc/model/step/StepFactory.java | 27 ++++++---- .../model/step/StepFactoryDefault.java | 25 +++++---- .../model/step/StepFactoryWithLet.java | 23 ++++---- .../kit/typicalc/model/step/StepVisitor.java | 8 +++ .../edu/kit/typicalc/model/step/VarStep.java | 7 +-- .../typicalc/model/step/VarStepDefault.java | 11 ++-- .../typicalc/model/step/VarStepWithLet.java | 12 +++-- .../kit/typicalc/model/step/package-info.java | 6 +-- .../edu/kit/typicalc/model/term/AbsTerm.java | 7 ++- .../edu/kit/typicalc/model/term/AppTerm.java | 7 ++- .../kit/typicalc/model/term/BooleanTerm.java | 2 + .../kit/typicalc/model/term/ConstTerm.java | 3 ++ .../kit/typicalc/model/term/IntegerTerm.java | 2 + .../kit/typicalc/model/term/LambdaTerm.java | 9 +++- .../edu/kit/typicalc/model/term/LetTerm.java | 5 +- .../kit/typicalc/model/term/TermVisitor.java | 9 ++++ .../typicalc/model/term/TermVisitorTree.java | 53 ++++++++++--------- .../edu/kit/typicalc/model/term/VarTerm.java | 3 ++ .../kit/typicalc/model/term/package-info.java | 4 +- .../kit/typicalc/model/type/FunctionType.java | 17 ++++-- .../kit/typicalc/model/type/NamedType.java | 11 +++- .../edu/kit/typicalc/model/type/Type.java | 11 +++- .../typicalc/model/type/TypeAbstraction.java | 13 +++-- .../kit/typicalc/model/type/TypeVariable.java | 15 ++++-- .../kit/typicalc/model/type/TypeVisitor.java | 3 ++ .../model/type/UnificationActions.java | 6 ++- .../typicalc/model/type/UnificationUtil.java | 3 +- .../kit/typicalc/model/type/package-info.java | 2 +- .../edu/kit/typicalc/presenter/Presenter.java | 4 +- .../typicalc/view/TypicalcI18NProvider.java | 1 + .../typicalc/view/content/ControlPanel.java | 2 +- .../view/content/ControlPanelView.java | 8 ++- .../view/content/infocontent/ImageSlide.java | 10 ++-- .../content/infocontent/StartPageView.java | 24 ++++----- .../MathjaxUnification.java | 1 + .../typeinferencecontent/ShareDialog.java | 7 +-- .../TypeInferenceView.java | 15 +++++- .../latexcreator/AssumptionGeneratorUtil.java | 7 ++- .../ConstraintSetIndexFactory.java | 8 +-- .../latexcreator/LatexCreator.java | 10 ++-- .../latexcreator/LatexCreatorConstraints.java | 14 ++--- .../latexcreator/LatexCreatorTerm.java | 10 ++-- .../typicalc/view/main/ErrorNotification.java | 6 +-- .../kit/typicalc/view/main/ExampleDialog.java | 5 +- .../typicalc/view/main/HelpContentField.java | 6 +-- .../view/main/InferenceRuleField.java | 2 +- .../edu/kit/typicalc/view/main/InputBar.java | 18 +++---- .../edu/kit/typicalc/view/main/MainView.java | 19 +++---- .../typicalc/view/main/MathjaxDisplay.java | 1 + .../view/main/TypeAssumptionField.java | 4 +- .../view/main/TypeAssumptionsArea.java | 4 +- .../edu/kit/typicalc/view/main/UpperBar.java | 6 +-- .../kit/typicalc/view/main/package-info.java | 2 +- .../edu/kit/typicalc/model/ModelImplTest.java | 4 +- .../model/step/AbsStepWithLetTest.java | 1 + .../model/step/AppStepDefaultTest.java | 3 ++ .../model/step/ConstStepDefaultTest.java | 3 ++ .../model/step/VarStepDefaultTest.java | 3 ++ .../edu/kit/typicalc/view/ScreenshotIT.java | 31 +++++------ .../view/pageobjects/InputBarElement.java | 6 +-- 86 files changed, 458 insertions(+), 250 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/Application.java b/src/main/java/edu/kit/typicalc/Application.java index 08f5104..e15db43 100644 --- a/src/main/java/edu/kit/typicalc/Application.java +++ b/src/main/java/edu/kit/typicalc/Application.java @@ -14,9 +14,8 @@ import java.util.regex.Pattern; /** * The entry point of the Spring Boot application. - * + *

* Use the * and some desktop browsers. - * */ @SpringBootApplication public class Application extends SpringBootServletInitializer diff --git a/src/main/java/edu/kit/typicalc/model/Conclusion.java b/src/main/java/edu/kit/typicalc/model/Conclusion.java index 5a2e211..072e940 100644 --- a/src/main/java/edu/kit/typicalc/model/Conclusion.java +++ b/src/main/java/edu/kit/typicalc/model/Conclusion.java @@ -22,8 +22,8 @@ public class Conclusion { * Initializes a new Conclusion with the given type assumptions, lambda term and type. * * @param typeAssumptions the type assumptions used in the conclusion - * @param lambdaTerm the lambda term in the conclusion - * @param type the type assigned to the lambda term in the conclusion + * @param lambdaTerm the lambda term in the conclusion + * @param type the type assigned to the lambda term in the conclusion */ public Conclusion(Map typeAssumptions, LambdaTerm lambdaTerm, Type type) { this.typeAssumptions = typeAssumptions; @@ -32,6 +32,8 @@ public class Conclusion { } /** + * Returns the type assumptions used in the conclusion + * * @return the type assumptions used in the conclusion */ public Map getTypeAssumptions() { @@ -39,6 +41,8 @@ public class Conclusion { } /** + * Returns the lambda term in the conclusion + * * @return the lambda term in the conclusion */ public LambdaTerm getLambdaTerm() { @@ -46,6 +50,8 @@ public class Conclusion { } /** + * Returns the type assigned to the lambda term in the conclusion + * * @return the type assigned to the lambda term in the conclusion */ public Type getType() { diff --git a/src/main/java/edu/kit/typicalc/model/Constraint.java b/src/main/java/edu/kit/typicalc/model/Constraint.java index 761bf6f..b4fdd9f 100644 --- a/src/main/java/edu/kit/typicalc/model/Constraint.java +++ b/src/main/java/edu/kit/typicalc/model/Constraint.java @@ -24,6 +24,8 @@ public class Constraint { } /** + * Returns the first type + * * @return the first type */ public Type getFirstType() { @@ -31,6 +33,8 @@ public class Constraint { } /** + * Returns the second type + * * @return the second type */ public Type getSecondType() { diff --git a/src/main/java/edu/kit/typicalc/model/Model.java b/src/main/java/edu/kit/typicalc/model/Model.java index 4f35f16..0e78b45 100644 --- a/src/main/java/edu/kit/typicalc/model/Model.java +++ b/src/main/java/edu/kit/typicalc/model/Model.java @@ -1,10 +1,10 @@ package edu.kit.typicalc.model; -import java.util.Map; - import edu.kit.typicalc.model.parser.ParseError; import edu.kit.typicalc.util.Result; +import java.util.Map; + /** * This interface accepts user input and returns a type inference result. */ @@ -12,10 +12,11 @@ public interface Model { /** * Given the user input, an implementation of this method should compute the type * inference results. - * @param lambdaTerm the lambda term to type-infer - * @param typeAssumptions the type assumptions to use + * + * @param lambdaTerm the lambda term to type-infer + * @param typeAssumptions the type assumptions to use * @return either an error or a TypeInfererInterface on success */ Result getTypeInferer(String lambdaTerm, - Map typeAssumptions); + Map typeAssumptions); } diff --git a/src/main/java/edu/kit/typicalc/model/ModelImpl.java b/src/main/java/edu/kit/typicalc/model/ModelImpl.java index d83ca95..a1fbd28 100644 --- a/src/main/java/edu/kit/typicalc/model/ModelImpl.java +++ b/src/main/java/edu/kit/typicalc/model/ModelImpl.java @@ -16,13 +16,13 @@ import java.util.Map; public class ModelImpl implements Model { /** - *Parses the user input given as the lambdaTerm and typeAssumptions and creates + * Parses the user input given as the lambdaTerm and typeAssumptions and creates * a TypeInferer object. - * @param lambdaTerm the lambda term to type-infer + * + * @param lambdaTerm the lambda term to type-infer * @param typeAssumptions the type assumptions to use * @return A TypeInferer object that has calculated the type Inference for the given Lambda Term * and type Assumptions - * */ @Override public Result getTypeInferer(String lambdaTerm, diff --git a/src/main/java/edu/kit/typicalc/model/Substitution.java b/src/main/java/edu/kit/typicalc/model/Substitution.java index 7865612..25091e8 100644 --- a/src/main/java/edu/kit/typicalc/model/Substitution.java +++ b/src/main/java/edu/kit/typicalc/model/Substitution.java @@ -26,6 +26,8 @@ public class Substitution { } /** + * Returns the type variable + * * @return the type variable */ public TypeVariable getVariable() { @@ -33,6 +35,8 @@ public class Substitution { } /** + * Returns the replacement type + * * @return the replacement type */ public Type getType() { diff --git a/src/main/java/edu/kit/typicalc/model/Tree.java b/src/main/java/edu/kit/typicalc/model/Tree.java index e2ae0ac..5eba039 100644 --- a/src/main/java/edu/kit/typicalc/model/Tree.java +++ b/src/main/java/edu/kit/typicalc/model/Tree.java @@ -28,8 +28,8 @@ public class Tree implements TermVisitorTree { * lambda term considering the given type assumptions. The inference step structure * and constraint list are generated here. * - * @param typeAssumptions the type assumptions to consider when generating the tree - * @param lambdaTerm the lambda term to generate the tree for + * @param typeAssumptions the type assumptions to consider when generating the tree + * @param lambdaTerm the lambda term to generate the tree for */ protected Tree(Map typeAssumptions, LambdaTerm lambdaTerm) { this(typeAssumptions, lambdaTerm, new TypeVariableFactory(TypeVariableKind.TREE), false); @@ -42,10 +42,10 @@ public class Tree implements TermVisitorTree { * variable names, a type variable factory is provided as a parameter. The inference * step structure and constraint list are generated here. * - * @param typeAssumptions the type assumptions to consider when generating the tree - * @param lambdaTerm the lambda term to generate the tree for + * @param typeAssumptions the type assumptions to consider when generating the tree + * @param lambdaTerm the lambda term to generate the tree for * @param typeVariableFactory the type variable factory to use - * @param partOfLetTerm indicates whether the tree is generated for a sub-inference that is part of a let term + * @param partOfLetTerm indicates whether the tree is generated for a sub-inference that is part of a let term */ protected Tree(Map typeAssumptions, LambdaTerm lambdaTerm, TypeVariableFactory typeVariableFactory, boolean partOfLetTerm) { diff --git a/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java b/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java index 14e0bf6..fd6c290 100644 --- a/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java +++ b/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java @@ -25,9 +25,9 @@ public class TypeInferenceResult { * to this given type variable. The mgu and the final type are generated here. * * @param substitutions the substitutions to generate the mgu and the final type - * @param typeVar the type variable belonging to the original lambda term + * @param typeVar the type variable belonging to the original lambda term * @throws IllegalStateException if the given list of substitutions contains two substitutions for the same - * type variable; or if the calculated mgu contains no substitution for the given type variable + * type variable; or if the calculated mgu contains no substitution for the given type variable */ protected TypeInferenceResult(List substitutions, TypeVariable typeVar) { mgu = new ArrayList<>(substitutions); diff --git a/src/main/java/edu/kit/typicalc/model/TypeInferer.java b/src/main/java/edu/kit/typicalc/model/TypeInferer.java index e4fd38d..e132097 100644 --- a/src/main/java/edu/kit/typicalc/model/TypeInferer.java +++ b/src/main/java/edu/kit/typicalc/model/TypeInferer.java @@ -28,7 +28,7 @@ public class TypeInferer implements TypeInfererInterface { * The inference step structure, unification steps, the most general unifier and the * final type are generated and calculated here. * - * @param lambdaTerm the lambda term to generate the tree for + * @param lambdaTerm the lambda term to generate the tree for * @param typeAssumptions the type assumptions to consider when generating the tree */ protected TypeInferer(LambdaTerm lambdaTerm, Map typeAssumptions) { diff --git a/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java b/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java index f743e50..5614144 100644 --- a/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java +++ b/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java @@ -23,8 +23,8 @@ public class TypeInfererLet implements TypeInfererInterface { * * @param lambdaTerm the lambda term to generate the tree for * @param typeAssumptions the type assumptions to consider when generating the tree - * @param typeVarFactory the type variable factory that should be used in this inference to guarantee consistency - * with the outer inference + * @param typeVarFactory the type variable factory that should be used in this inference to guarantee consistency + * with the outer inference */ protected TypeInfererLet(LambdaTerm lambdaTerm, Map typeAssumptions, TypeVariableFactory typeVarFactory) { diff --git a/src/main/java/edu/kit/typicalc/model/Unification.java b/src/main/java/edu/kit/typicalc/model/Unification.java index 19acce7..954e733 100644 --- a/src/main/java/edu/kit/typicalc/model/Unification.java +++ b/src/main/java/edu/kit/typicalc/model/Unification.java @@ -17,6 +17,7 @@ public class Unification { /** * Initializes a new {@link Unification} for the given constraints. * The list of unification steps and the resulting substitutions are generated here. + * * @param constraints constraints to execute the unification for */ protected Unification(Deque constraints) { // TODO: document List->Deque @@ -62,6 +63,8 @@ public class Unification { } /** + * Returns list of the unification steps the unification performs. + * * @return list of the unification steps the unification performs. */ protected List getUnificationSteps() { diff --git a/src/main/java/edu/kit/typicalc/model/UnificationStep.java b/src/main/java/edu/kit/typicalc/model/UnificationStep.java index 977aa2d..998927c 100644 --- a/src/main/java/edu/kit/typicalc/model/UnificationStep.java +++ b/src/main/java/edu/kit/typicalc/model/UnificationStep.java @@ -18,10 +18,11 @@ public class UnificationStep { /** * Initializes a new {@link UnificationStep} with the given lists of constraints and substitutions. - * When detected that this unification step leads to a contradiction or an infinite type, - * it should be passed a {@link UnificationError} instead of a list of substitutions. + * When detected that this unification step leads to a contradiction or an infinite type, + * it should be passed a {@link UnificationError} instead of a list of substitutions. + * * @param substitutions list of substitutions, or an error - * @param constraints the list of all constraints of the unification (in the state resulting from this step) + * @param constraints the list of all constraints of the unification (in the state resulting from this step) */ protected UnificationStep(Result, UnificationError> substitutions, List constraints) { @@ -41,6 +42,8 @@ public class UnificationStep { } /** + * Returns a list of all resulting constraints + * * @return a list of all resulting constraints */ public List getConstraints() { diff --git a/src/main/java/edu/kit/typicalc/model/package-info.java b/src/main/java/edu/kit/typicalc/model/package-info.java index fbbed63..8c6070e 100644 --- a/src/main/java/edu/kit/typicalc/model/package-info.java +++ b/src/main/java/edu/kit/typicalc/model/package-info.java @@ -1,12 +1,12 @@ /** - * The model package contains all classes needed to model the typed lambda calculus and the type inference algorithm. - * To do so, it contains the sub-packages term, type, step and parser. - * The model package itself contains the ModelInterface, functioning as an interface for the presenter - * and the classes executing the type inference algorithm. - * The class TypeInferer combines the three separated parts of the algorithm: - * the building of the tree, execution of the unification and calculation of the most general unifier and final type. - * An instance of TypeInferer, fitting the lambda term from the user input, is passed to the view to obtain the data - * needed for the visualization of the computed steps of the algorithm. + * The model package contains all classes needed to model the typed lambda calculus and the type inference algorithm. + * To do so, it contains the sub-packages term, type, step and parser. + * The model package itself contains the ModelInterface, functioning as an interface for the presenter + * and the classes executing the type inference algorithm. + * The class TypeInferer combines the three separated parts of the algorithm: + * the building of the tree, execution of the unification and calculation of the most general unifier and final type. + * An instance of TypeInferer, fitting the lambda term from the user input, is passed to the view to obtain the data + * needed for the visualization of the computed steps of the algorithm. */ @NonNullFields @NonNullApi diff --git a/src/main/java/edu/kit/typicalc/model/parser/LambdaLexer.java b/src/main/java/edu/kit/typicalc/model/parser/LambdaLexer.java index 3669e72..12f3bff 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/LambdaLexer.java +++ b/src/main/java/edu/kit/typicalc/model/parser/LambdaLexer.java @@ -13,7 +13,7 @@ import java.util.Deque; */ public class LambdaLexer { /** - * The given term as a String + * the given term as a String */ private final String term; /** @@ -24,6 +24,7 @@ public class LambdaLexer { /** * Constructs a lexer that lexes the given term + * * @param term the term to lex */ public LambdaLexer(String term) { @@ -53,6 +54,7 @@ public class LambdaLexer { /** * Returns the next token and advances the lexer position. + * * @return the next token */ public Result nextToken() { @@ -88,7 +90,7 @@ public class LambdaLexer { } else { return new Result<>(null, ParseError.UNEXPECTED_CHARACTER); } - // bunch of single-character tokens + // bunch of single-character tokens case '.': t = new Token(TokenType.DOT, ".", pos); advance(); diff --git a/src/main/java/edu/kit/typicalc/model/parser/ParseError.java b/src/main/java/edu/kit/typicalc/model/parser/ParseError.java index 06f3202..478bf35 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/ParseError.java +++ b/src/main/java/edu/kit/typicalc/model/parser/ParseError.java @@ -9,7 +9,7 @@ package edu.kit.typicalc.model.parser; public enum ParseError { /** - * the lambda term didn't meet the specified syntax + * the lambda term didn't meet the specified syntax */ UNEXPECTED_TOKEN, diff --git a/src/main/java/edu/kit/typicalc/model/parser/Token.java b/src/main/java/edu/kit/typicalc/model/parser/Token.java index 73883c2..f9778c7 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/Token.java +++ b/src/main/java/edu/kit/typicalc/model/parser/Token.java @@ -40,9 +40,10 @@ public class Token { /** * Constructs a token. + * * @param type the token type * @param text text of this token in the source code - * @param pos position this token begins + * @param pos position this token begins */ public Token(TokenType type, String text, int pos) { this.type = type; @@ -52,6 +53,7 @@ public class Token { /** * Returns the token type + * * @return token type */ public TokenType getType() { @@ -60,6 +62,7 @@ public class Token { /** * Returns the text of this token in the source code + * * @return text of this token in the source code */ public String getText() { @@ -68,6 +71,7 @@ public class Token { /** * Returns the position this token is in + * * @return position this token is in */ public int getPos() { diff --git a/src/main/java/edu/kit/typicalc/model/parser/package-info.java b/src/main/java/edu/kit/typicalc/model/parser/package-info.java index f05b2cd..c7f5f78 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/package-info.java +++ b/src/main/java/edu/kit/typicalc/model/parser/package-info.java @@ -1,6 +1,6 @@ /** - * The parser package contains all classes needed to parse the input strings from the user to an abstract form - * consisting of classes provided by the the model, term and type package. + * The parser package contains all classes needed to parse the input strings from the user to an abstract form + * consisting of classes provided by the the model, term and type package. */ @NonNullApi @NonNullFields diff --git a/src/main/java/edu/kit/typicalc/model/step/AbsStep.java b/src/main/java/edu/kit/typicalc/model/step/AbsStep.java index 67c4a63..ee59b27 100644 --- a/src/main/java/edu/kit/typicalc/model/step/AbsStep.java +++ b/src/main/java/edu/kit/typicalc/model/step/AbsStep.java @@ -14,7 +14,8 @@ public abstract class AbsStep extends InferenceStep { /** * Initializes a new AbsStep with the given values. - * @param premise the premise of this step + * + * @param premise the premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint added in this step */ @@ -25,6 +26,7 @@ public abstract class AbsStep extends InferenceStep { /** * Getter for the premise of this step. + * * @return premise the premise of this step */ public InferenceStep getPremise() { diff --git a/src/main/java/edu/kit/typicalc/model/step/AbsStepDefault.java b/src/main/java/edu/kit/typicalc/model/step/AbsStepDefault.java index 31ce9fe..c97be2a 100644 --- a/src/main/java/edu/kit/typicalc/model/step/AbsStepDefault.java +++ b/src/main/java/edu/kit/typicalc/model/step/AbsStepDefault.java @@ -10,7 +10,8 @@ import edu.kit.typicalc.model.Constraint; public class AbsStepDefault extends AbsStep { /** * Initializes a new AbsStepDefault with the given values. - * @param premise the premise of this step + * + * @param premise the premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint added in this step */ @@ -20,6 +21,7 @@ public class AbsStepDefault extends AbsStep { /** * Accepts a visitor. + * * @param stepVisitor – the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/AbsStepWithLet.java b/src/main/java/edu/kit/typicalc/model/step/AbsStepWithLet.java index dd415ce..852ed22 100644 --- a/src/main/java/edu/kit/typicalc/model/step/AbsStepWithLet.java +++ b/src/main/java/edu/kit/typicalc/model/step/AbsStepWithLet.java @@ -10,7 +10,8 @@ import edu.kit.typicalc.model.Constraint; public class AbsStepWithLet extends AbsStep { /** * Initializes a new AbsStepWithLet with the given values. - * @param premise the premise of this step + * + * @param premise the premise of this step * @param conclusion the conclusion of this step * @param constraint constraint that can be derived from this step */ @@ -20,6 +21,7 @@ public class AbsStepWithLet extends AbsStep { /** * Accepts a visitor. + * * @param stepVisitor the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/AppStep.java b/src/main/java/edu/kit/typicalc/model/step/AppStep.java index 8a38259..65441a9 100644 --- a/src/main/java/edu/kit/typicalc/model/step/AppStep.java +++ b/src/main/java/edu/kit/typicalc/model/step/AppStep.java @@ -16,9 +16,10 @@ public abstract class AppStep extends InferenceStep { private final InferenceStep premise2; /** - Initializes a new AbsStepWithLet with the given values. - * @param premise1 the first premise of this step - * @param premise2 the second premise of this step + * Initializes a new AbsStepWithLet with the given values. + * + * @param premise1 the first premise of this step + * @param premise2 the second premise of this step * @param conclusion the conclusion of this step * @param constraint constraint that can be derived from this step */ @@ -30,13 +31,16 @@ public abstract class AppStep extends InferenceStep { /** * Getter for the first premise of this Step. + * * @return premise1 the first premise of this Step. */ public InferenceStep getPremise1() { return premise1; } + /** * Getter for the second premise of this Step. + * * @return premise2 the second premise of this Step. */ public InferenceStep getPremise2() { diff --git a/src/main/java/edu/kit/typicalc/model/step/AppStepDefault.java b/src/main/java/edu/kit/typicalc/model/step/AppStepDefault.java index 4c9cced..61a1df2 100644 --- a/src/main/java/edu/kit/typicalc/model/step/AppStepDefault.java +++ b/src/main/java/edu/kit/typicalc/model/step/AppStepDefault.java @@ -9,9 +9,10 @@ import edu.kit.typicalc.model.Constraint; */ public class AppStepDefault extends AppStep { /** - *Initializes a new AbsStepWithLet with the given values. - * @param premise1 the first premise of this step - * @param premise2 the second premise of this step + * Initializes a new AbsStepWithLet with the given values. + * + * @param premise1 the first premise of this step + * @param premise2 the second premise of this step * @param conclusion the conclusion of this step * @param constraint constraint that can be derived from this step */ @@ -22,6 +23,7 @@ public class AppStepDefault extends AppStep { /** * Accepts a visitor. + * * @param stepVisitor – the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/ConstStep.java b/src/main/java/edu/kit/typicalc/model/step/ConstStep.java index dccf9be..58d03b2 100644 --- a/src/main/java/edu/kit/typicalc/model/step/ConstStep.java +++ b/src/main/java/edu/kit/typicalc/model/step/ConstStep.java @@ -9,6 +9,7 @@ import edu.kit.typicalc.model.Constraint; public abstract class ConstStep extends InferenceStep { /** * Initializes a new ConstStep with the given values. + * * @param conclusion the conclusion of this step * @param constraint the constraint added in this step */ diff --git a/src/main/java/edu/kit/typicalc/model/step/ConstStepDefault.java b/src/main/java/edu/kit/typicalc/model/step/ConstStepDefault.java index 18c2933..baa9535 100644 --- a/src/main/java/edu/kit/typicalc/model/step/ConstStepDefault.java +++ b/src/main/java/edu/kit/typicalc/model/step/ConstStepDefault.java @@ -11,6 +11,7 @@ import edu.kit.typicalc.model.Constraint; public class ConstStepDefault extends ConstStep { /** * Initializes a new ConstStep with the given values. + * * @param conclusion the conclusion of this step * @param constraint the constraint added in this step */ @@ -20,6 +21,7 @@ public class ConstStepDefault extends ConstStep { /** * Accepts a visitor. + * * @param stepVisitor the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/LetStep.java b/src/main/java/edu/kit/typicalc/model/step/LetStep.java index db0dbd9..ddf610f 100644 --- a/src/main/java/edu/kit/typicalc/model/step/LetStep.java +++ b/src/main/java/edu/kit/typicalc/model/step/LetStep.java @@ -8,7 +8,7 @@ import java.util.Objects; /** * Models one step of the inference tree where the let rule is applied. A let step contains an - * additional instance of a type inferer that is responisble for the „sub-inference“ that takes + * additional instance of a type inferer that is responsible for the „sub-inference“ that takes * place when applying the let rule. This type inferer grants access to all the information * needed to visualize this sub-inference. * If the sub-inference fails due to a contradiction or an infinite type forming in its unification, @@ -21,9 +21,10 @@ public abstract class LetStep extends InferenceStep { /** * Initializes a new LetStep with the given values. - * @param conclusion the conclusion of this step - * @param constraint the constraint added in this step - * @param premise the right premise of this step + * + * @param conclusion the conclusion of this step + * @param constraint the constraint added in this step + * @param premise the right premise of this step * @param typeInferer the typeInferer that performs the Type Inference for the premise * that needs its own type Inference. */ @@ -32,9 +33,11 @@ public abstract class LetStep extends InferenceStep { this.premise = premise; this.typeInferer = typeInferer; } + /** - * Returns the premise of the let step that doesn’t have its own sub-inference (the + * Returns the premise of the let step that doesn't have its own sub-inference (the * one usually placed right in the proof tree). + * * @return premise the right premise of this step */ public InferenceStep getPremise() { @@ -43,6 +46,7 @@ public abstract class LetStep extends InferenceStep { /** * Returns the TypeInferer for the premise which needs its own type Inference. + * * @return typeInferer the type inferer of the sub-inference */ public TypeInfererLet getTypeInferer() { diff --git a/src/main/java/edu/kit/typicalc/model/step/LetStepDefault.java b/src/main/java/edu/kit/typicalc/model/step/LetStepDefault.java index 5bfdd23..3e4a16e 100644 --- a/src/main/java/edu/kit/typicalc/model/step/LetStepDefault.java +++ b/src/main/java/edu/kit/typicalc/model/step/LetStepDefault.java @@ -10,9 +10,10 @@ import edu.kit.typicalc.model.TypeInfererLet; public class LetStepDefault extends LetStep { /** * Initializes a new LetStep with the given values. - * @param conclusion the conclusion of this step - * @param constraint the constraint added in this step - * @param premise the right premise of this step + * + * @param conclusion the conclusion of this step + * @param constraint the constraint added in this step + * @param premise the right premise of this step * @param typeInferer the typeInferer that performs the Type Inference for the premise * that needs its own type Inference. */ @@ -23,6 +24,7 @@ public class LetStepDefault extends LetStep { /** * Accepts a visitor. + * * @param stepVisitor the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/StepFactory.java b/src/main/java/edu/kit/typicalc/model/step/StepFactory.java index a9bda9f..1e0776b 100644 --- a/src/main/java/edu/kit/typicalc/model/step/StepFactory.java +++ b/src/main/java/edu/kit/typicalc/model/step/StepFactory.java @@ -12,7 +12,8 @@ import edu.kit.typicalc.model.type.TypeAbstraction; public interface StepFactory { /** * Creates an AbsStep. - * @param premise the premise of this step + * + * @param premise the premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created AbsStep @@ -21,16 +22,19 @@ public interface StepFactory { /** * Creates an AppStep. - * @param premise1 the first premise of this step - * @param premise2 the second premise of this step + * + * @param premise1 the first premise of this step + * @param premise2 the second premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created AppStep */ AppStep createAppStep(InferenceStep premise1, InferenceStep premise2, - Conclusion conclusion, Constraint constraint); + Conclusion conclusion, Constraint constraint); + /** * Creates an ConstStep. + * * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created ConstStep @@ -39,19 +43,22 @@ public interface StepFactory { /** * Creates a VarStep. - * @param typeAbstraction the type abstraction of this step + * + * @param typeAbstraction the type abstraction of this step * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step - * @param conclusion the conclusion of this step - * @param constraint the constraint that can be derived from this step + * @param conclusion the conclusion of this step + * @param constraint the constraint that can be derived from this step * @return the created AbsStep */ VarStep createVarStep(TypeAbstraction typeAbstraction, Type instantiatedTypeAbs, Conclusion conclusion, Constraint constraint); + /** * Creates a LetStep. - * @param conclusion the conclusion of this step - * @param constraint the constraint that can be derived from this step - * @param premise the premise that doesn't need its own type inference + * + * @param conclusion the conclusion of this step + * @param constraint the constraint that can be derived from this step + * @param premise the premise that doesn't need its own type inference * @param typeInferer the typeInferer for the premise that needs its own type inference * @return the created AppStep */ diff --git a/src/main/java/edu/kit/typicalc/model/step/StepFactoryDefault.java b/src/main/java/edu/kit/typicalc/model/step/StepFactoryDefault.java index e3a3dc1..58906fb 100644 --- a/src/main/java/edu/kit/typicalc/model/step/StepFactoryDefault.java +++ b/src/main/java/edu/kit/typicalc/model/step/StepFactoryDefault.java @@ -13,7 +13,8 @@ public class StepFactoryDefault implements StepFactory { /** * Creates an AbsStepDefault. - * @param premise the premise of this step + * + * @param premise the premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created AbsStepDefault @@ -25,20 +26,22 @@ public class StepFactoryDefault implements StepFactory { /** * Creates an AppStepDefault. - * @param premise1 the first premise of this step - * @param premise2 the second premise of this step + * + * @param premise1 the first premise of this step + * @param premise2 the second premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created AppStepDefault */ @Override public AppStepDefault createAppStep(InferenceStep premise1, InferenceStep premise2, - Conclusion conclusion, Constraint constraint) { + Conclusion conclusion, Constraint constraint) { return new AppStepDefault(premise1, premise2, conclusion, constraint); } /** * Creates an ConstStepDefault. + * * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created ConstStepDefault @@ -50,10 +53,11 @@ public class StepFactoryDefault implements StepFactory { /** * Creates a VarStepDefault. - * @param typeAbstraction the type abstraction of this step + * + * @param typeAbstraction the type abstraction of this step * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step - * @param conclusion the conclusion of this step - * @param constraint the constraint that can be derived from this step + * @param conclusion the conclusion of this step + * @param constraint the constraint that can be derived from this step * @return the created AbsStepDefault */ @Override @@ -67,9 +71,10 @@ public class StepFactoryDefault implements StepFactory { * This method should never be called, as a StepFactoryDefault should only be used * for lambda terms without any let polymorphism and therefore should never have * to create a step where the let rule is applied. - * @param conclusion the conclusion of this step - * @param constraint the constraint that can be derived from this step - * @param premise the premise that doesn't need its own type inference + * + * @param conclusion the conclusion of this step + * @param constraint the constraint that can be derived from this step + * @param premise the premise that doesn't need its own type inference * @param typeInferer the typeInferer for the premise that needs its own type inference * @return nothing */ diff --git a/src/main/java/edu/kit/typicalc/model/step/StepFactoryWithLet.java b/src/main/java/edu/kit/typicalc/model/step/StepFactoryWithLet.java index e5e9171..5b26baf 100644 --- a/src/main/java/edu/kit/typicalc/model/step/StepFactoryWithLet.java +++ b/src/main/java/edu/kit/typicalc/model/step/StepFactoryWithLet.java @@ -13,7 +13,8 @@ public class StepFactoryWithLet implements StepFactory { /** * Creates an AbsStepWithLet. - * @param premise the premise of this step + * + * @param premise the premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created AbsStepWithLet @@ -25,8 +26,9 @@ public class StepFactoryWithLet implements StepFactory { /** * Creates an AppStepDefault. - * @param premise1 the first premise of this step - * @param premise2 the second premise of this step + * + * @param premise1 the first premise of this step + * @param premise2 the second premise of this step * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created AppStepDefault @@ -39,6 +41,7 @@ public class StepFactoryWithLet implements StepFactory { /** * Creates an ConstStepDefault. + * * @param conclusion the conclusion of this step * @param constraint the constraint that can be derived from this step * @return the created ConstStepDefault @@ -50,10 +53,11 @@ public class StepFactoryWithLet implements StepFactory { /** * Creates a VarStepWithLet. - * @param typeAbstraction the type abstraction of this step + * + * @param typeAbstraction the type abstraction of this step * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step - * @param conclusion the conclusion of this step - * @param constraint the constraint that can be derived from this step + * @param conclusion the conclusion of this step + * @param constraint the constraint that can be derived from this step * @return the created VarStepWithLet */ @Override @@ -64,9 +68,10 @@ public class StepFactoryWithLet implements StepFactory { /** * Creates a LetStepDefault. - * @param conclusion the conclusion of this step - * @param constraint the constraint that can be derived from this step - * @param premise the premise that doesn't need its own type inference + * + * @param conclusion the conclusion of this step + * @param constraint the constraint that can be derived from this step + * @param premise the premise that doesn't need its own type inference * @param typeInferer the typeInferer for the premise that needs its own type inference * @return the created LetStepDefault */ diff --git a/src/main/java/edu/kit/typicalc/model/step/StepVisitor.java b/src/main/java/edu/kit/typicalc/model/step/StepVisitor.java index a85d646..6753513 100644 --- a/src/main/java/edu/kit/typicalc/model/step/StepVisitor.java +++ b/src/main/java/edu/kit/typicalc/model/step/StepVisitor.java @@ -7,48 +7,56 @@ public interface StepVisitor { /** * Visits an AbsStepDefault. + * * @param absD the AbsStepDefault to visit */ void visit(AbsStepDefault absD); /** * Visits an AbsStepWithLet. + * * @param absL the AbsStepWithLet to visit */ void visit(AbsStepWithLet absL); /** * Visits an AppStepDefault. + * * @param appD the AppStepDefault to visit */ void visit(AppStepDefault appD); /** * ConstStepDefault. + * * @param constD the ConstStepDefault to visit */ void visit(ConstStepDefault constD); /** * Visits a VarStepDefault. + * * @param varD the VarStepDefault to visit */ void visit(VarStepDefault varD); /** * Visits a VarStepWithLet. + * * @param varL the VarStepWithLet to visit */ void visit(VarStepWithLet varL); /** * Visits a LetStepDefault. + * * @param letD the LetStepDefault to visit */ void visit(LetStepDefault letD); /** * Visits an empty step + * * @param empty the empty step to visit */ void visit(EmptyStep empty); diff --git a/src/main/java/edu/kit/typicalc/model/step/VarStep.java b/src/main/java/edu/kit/typicalc/model/step/VarStep.java index 88ede91..b89d3be 100644 --- a/src/main/java/edu/kit/typicalc/model/step/VarStep.java +++ b/src/main/java/edu/kit/typicalc/model/step/VarStep.java @@ -20,9 +20,9 @@ public abstract class VarStep extends InferenceStep { * Initializes a new VarStep with the given values. * * @param typeAbstractionInPremise the type abstraction in the premise of this step - * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step - * @param conclusion the conclusion of this step - * @param constraint the constraint added in this step + * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step + * @param conclusion the conclusion of this step + * @param constraint the constraint added in this step */ protected VarStep(TypeAbstraction typeAbstractionInPremise, Type instantiatedTypeAbs, Conclusion conclusion, Constraint constraint) { @@ -30,6 +30,7 @@ public abstract class VarStep extends InferenceStep { this.typeAbstractionInPremise = typeAbstractionInPremise; this.instantiatedTypeAbs = instantiatedTypeAbs; } + /** * Returns the type abstraction in the premise of the step, that is identified as the * variable’s type. diff --git a/src/main/java/edu/kit/typicalc/model/step/VarStepDefault.java b/src/main/java/edu/kit/typicalc/model/step/VarStepDefault.java index eec0be1..c06e864 100644 --- a/src/main/java/edu/kit/typicalc/model/step/VarStepDefault.java +++ b/src/main/java/edu/kit/typicalc/model/step/VarStepDefault.java @@ -5,14 +5,18 @@ import edu.kit.typicalc.model.Constraint; import edu.kit.typicalc.model.type.Type; import edu.kit.typicalc.model.type.TypeAbstraction; +/** + * Models one step of the inference tree where the variable rule is applied and + * let polymorphism is not used in the entire tree. + */ public class VarStepDefault extends VarStep { /** * Initializes a new VarStep with the given values. * * @param typeAbstractionInPremise the type abstraction in the premise of this step - * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step - * @param conclusion the conclusion of this step - * @param constraint the constraint added in this step + * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step + * @param conclusion the conclusion of this step + * @param constraint the constraint added in this step */ public VarStepDefault(TypeAbstraction typeAbstractionInPremise, Type instantiatedTypeAbs, Conclusion conclusion, Constraint constraint) { @@ -21,6 +25,7 @@ public class VarStepDefault extends VarStep { /** * Accepts a visitor. + * * @param stepVisitor the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/VarStepWithLet.java b/src/main/java/edu/kit/typicalc/model/step/VarStepWithLet.java index 831816c..41f3c72 100644 --- a/src/main/java/edu/kit/typicalc/model/step/VarStepWithLet.java +++ b/src/main/java/edu/kit/typicalc/model/step/VarStepWithLet.java @@ -5,14 +5,19 @@ import edu.kit.typicalc.model.Constraint; import edu.kit.typicalc.model.type.Type; import edu.kit.typicalc.model.type.TypeAbstraction; +/** + * Models one step of the inference tree where the variable rule is applied and at least one + * let rule is applied in the entire tree. It additionally constrains a type that is obtained when + * instantiating the type abstraction in the premise of the step. + */ public class VarStepWithLet extends VarStep { /** * Initializes a new VarStep with the given values. * * @param typeAbstractionInPremise the type abstraction in the premise of this step - * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step - * @param conclusion the conclusion of this step - * @param constraint the constraint added in this step + * @param instantiatedTypeAbs an instantiation of the type abstraction used in this step + * @param conclusion the conclusion of this step + * @param constraint the constraint added in this step */ public VarStepWithLet(TypeAbstraction typeAbstractionInPremise, Type instantiatedTypeAbs, Conclusion conclusion, Constraint constraint) { @@ -21,6 +26,7 @@ public class VarStepWithLet extends VarStep { /** * Accepts a visitor. + * * @param stepVisitor the visitor that wants to visit this object */ @Override diff --git a/src/main/java/edu/kit/typicalc/model/step/package-info.java b/src/main/java/edu/kit/typicalc/model/step/package-info.java index 33d032b..7aea089 100644 --- a/src/main/java/edu/kit/typicalc/model/step/package-info.java +++ b/src/main/java/edu/kit/typicalc/model/step/package-info.java @@ -1,7 +1,7 @@ /** - * The step package models the inference steps that are executed while generating the prof tree. - * To represent the different kinds of typing rules that can be applied, InferenceStep has various subclasses. - * These subclasses can be produced by factories, appropriate to the desired context. + * The step package models the inference steps that are executed while generating the prof tree. + * To represent the different kinds of typing rules that can be applied, InferenceStep has various subclasses. + * These subclasses can be produced by factories, appropriate to the desired context. */ @NonNullFields @NonNullApi diff --git a/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java b/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java index 92123b3..f333519 100644 --- a/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java @@ -19,7 +19,8 @@ public class AbsTerm extends LambdaTerm { /** * Initializes a new abstraction term with the variable bound * by the abstraction and the lambda term of the abstraction. - * @param var the variable bound by the abstraction + * + * @param var the variable bound by the abstraction * @param body the lambda term of the abstraction */ public AbsTerm(VarTerm var, LambdaTerm body) { @@ -28,6 +29,8 @@ public class AbsTerm extends LambdaTerm { } /** + * Returns the variable of this abstraction + * * @return the variable of this abstraction */ public VarTerm getVariable() { @@ -35,6 +38,8 @@ public class AbsTerm extends LambdaTerm { } /** + * Returns the function body of this abstraction + * * @return the function body of this abstraction */ public LambdaTerm getInner() { diff --git a/src/main/java/edu/kit/typicalc/model/term/AppTerm.java b/src/main/java/edu/kit/typicalc/model/term/AppTerm.java index 0850ec0..03f53ca 100644 --- a/src/main/java/edu/kit/typicalc/model/term/AppTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/AppTerm.java @@ -15,7 +15,8 @@ public class AppTerm extends LambdaTerm { /** * Initializes a new application term with one lambda term for the function and one lambda term for the parameter. - * @param left the function + * + * @param left the function * @param right the parameter */ public AppTerm(LambdaTerm left, LambdaTerm right) { @@ -24,6 +25,8 @@ public class AppTerm extends LambdaTerm { } /** + * Returns the function used in this application + * * @return the function used in this application */ public LambdaTerm getFunction() { @@ -31,6 +34,8 @@ public class AppTerm extends LambdaTerm { } /** + * Returns the parameter used in this application + * * @return the parameter used in this application */ public LambdaTerm getParameter() { diff --git a/src/main/java/edu/kit/typicalc/model/term/BooleanTerm.java b/src/main/java/edu/kit/typicalc/model/term/BooleanTerm.java index 5fa1ca7..e3eb860 100644 --- a/src/main/java/edu/kit/typicalc/model/term/BooleanTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/BooleanTerm.java @@ -12,6 +12,7 @@ public class BooleanTerm extends ConstTerm { /** * Initializes a new boolean lambda term with the given value. + * * @param value true or false */ public BooleanTerm(boolean value) { @@ -20,6 +21,7 @@ public class BooleanTerm extends ConstTerm { /** * Returns the value of the boolean constant term. + * * @return the value of the term */ public boolean getValue() { diff --git a/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java b/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java index 8fb0753..1bb35e1 100644 --- a/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java @@ -13,7 +13,10 @@ 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 { + /** + * Returns the named type of the constant + * * @return the named type of the constant */ public abstract NamedType getType(); diff --git a/src/main/java/edu/kit/typicalc/model/term/IntegerTerm.java b/src/main/java/edu/kit/typicalc/model/term/IntegerTerm.java index cd80e2c..f3ee84f 100644 --- a/src/main/java/edu/kit/typicalc/model/term/IntegerTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/IntegerTerm.java @@ -12,6 +12,7 @@ public class IntegerTerm extends ConstTerm { /** * Initializes a new integer lambda term with the given value. + * * @param value an integer */ public IntegerTerm(int value) { @@ -20,6 +21,7 @@ public class IntegerTerm extends ConstTerm { /** * Returns the value of the integer constant term. + * * @return the value of the term */ public int getValue() { diff --git a/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java b/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java index 7e5a17c..fe048b1 100644 --- a/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java @@ -14,27 +14,32 @@ import java.util.Set; */ public abstract class LambdaTerm { /** + * Returns whether the lambda term contains a let expression + * * @return whether the lambda term contains a let expression */ public abstract boolean hasLet(); /** * Returns a set of all free variables occurring in the lambda term. + * * @return all free variables */ public abstract Set getFreeVariables(); /** * Calls exactly one method on the visitor depending on the lambda term type. + * * @param termVisitor a visitor */ public abstract void accept(TermVisitor termVisitor); /** * Uses exactly one method of the visitor and provides the arguments passed. + * * @param termVisitorTree the visitor - * @param assumptions type assumptions - * @param type a type + * @param assumptions type assumptions + * @param type a type * @return the result returned by the visitor */ public abstract InferenceStep accept(TermVisitorTree termVisitorTree, diff --git a/src/main/java/edu/kit/typicalc/model/term/LetTerm.java b/src/main/java/edu/kit/typicalc/model/term/LetTerm.java index 1f971e2..3da544c 100644 --- a/src/main/java/edu/kit/typicalc/model/term/LetTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/LetTerm.java @@ -20,9 +20,10 @@ public class LetTerm extends LambdaTerm { /** * Initializes a new let term with its variable and two lambda terms. - * @param variable the variable of the let term + * + * @param variable the variable of the let term * @param definition the lambda term assigned to the variable - * @param body the lambda term the variable may be used in + * @param body the lambda term the variable may be used in */ public LetTerm(VarTerm variable, LambdaTerm definition, LambdaTerm body) { this.variable = variable; diff --git a/src/main/java/edu/kit/typicalc/model/term/TermVisitor.java b/src/main/java/edu/kit/typicalc/model/term/TermVisitor.java index 63f87cf..8bfb838 100644 --- a/src/main/java/edu/kit/typicalc/model/term/TermVisitor.java +++ b/src/main/java/edu/kit/typicalc/model/term/TermVisitor.java @@ -1,38 +1,47 @@ package edu.kit.typicalc.model.term; +/** + * Represents the visitor in the visitor pattern. + */ public interface TermVisitor { /** * Visit an application term. + * * @param appTerm the term */ void visit(AppTerm appTerm); /** * Visit an abstraction term. + * * @param absTerm the term */ void visit(AbsTerm absTerm); /** * Visit a let expression. + * * @param letTerm the term */ void visit(LetTerm letTerm); /** * Visit a variable. + * * @param varTerm the variable */ void visit(VarTerm varTerm); /** * Visit an integer constant. + * * @param intTerm the integer constant */ void visit(IntegerTerm intTerm); /** * Visit a boolean constant. + * * @param boolTerm the boolean constant */ void visit(BooleanTerm boolTerm); diff --git a/src/main/java/edu/kit/typicalc/model/term/TermVisitorTree.java b/src/main/java/edu/kit/typicalc/model/term/TermVisitorTree.java index 3aa22b8..6f4b2b7 100644 --- a/src/main/java/edu/kit/typicalc/model/term/TermVisitorTree.java +++ b/src/main/java/edu/kit/typicalc/model/term/TermVisitorTree.java @@ -6,18 +6,21 @@ import edu.kit.typicalc.model.type.TypeAbstraction; import java.util.Map; +/** + * Represents the visitor in the visitor pattern. + */ public interface TermVisitorTree { /** * Returns an {@link edu.kit.typicalc.model.step.AppStep} suiting the given application (lambda term) * to type-infer and the type assumptions to consider. * Simultaneously assembles the tree's constraint list. * - * @param appTerm the application (lambda term) to build the inference step structure for, - * i.e. the lambda term in the conclusion of the returned inference step + * @param appTerm the application (lambda term) to build the inference step structure for, + * i.e. the lambda term in the conclusion of the returned inference step * @param typeAssumptions the type assumptions to consider, - * i.e. the type assumptions in the conclusion of the returned inference step - * @param conclusionType the type that the lambda term in the conclusion - * of the returned inference step will be assigned + * i.e. the type assumptions in the conclusion of the returned inference step + * @param conclusionType the type that the lambda term in the conclusion + * of the returned inference step will be assigned * @return an {@link edu.kit.typicalc.model.step.AppStep} */ InferenceStep visit(AppTerm appTerm, Map typeAssumptions, Type conclusionType); @@ -27,12 +30,12 @@ public interface TermVisitorTree { * to type-infer and the type assumptions to consider. * Simultaneously assembles the tree's constraint list. * - * @param absTerm the abstraction (lambda term) to build the inference step structure for, - * i.e. the lambda term in the conclusion of the returned inference step + * @param absTerm the abstraction (lambda term) to build the inference step structure for, + * i.e. the lambda term in the conclusion of the returned inference step * @param typeAssumptions the type assumptions to consider, - * i.e. the type assumptions in the conclusion of the returned inference step - * @param conclusionType the type that the lambda term in the conclusion - * of the returned inference step will be assigned + * i.e. the type assumptions in the conclusion of the returned inference step + * @param conclusionType the type that the lambda term in the conclusion + * of the returned inference step will be assigned * @return an {@link edu.kit.typicalc.model.step.AbsStep} */ InferenceStep visit(AbsTerm absTerm, Map typeAssumptions, Type conclusionType); @@ -42,12 +45,12 @@ public interface TermVisitorTree { * to type-infer and the type assumptions to consider. * Simultaneously assembles the tree's constraint list. * - * @param letTerm the let expression (lambda term) to build the inference step structure for, - * i.e. the lambda term in the conclusion of the returned inference step + * @param letTerm the let expression (lambda term) to build the inference step structure for, + * i.e. the lambda term in the conclusion of the returned inference step * @param typeAssumptions the type assumptions to consider, - * i.e. the type assumptions in the conclusion of the returned inference step - * @param conclusionType the type that the lambda term in the conclusion - * of the returned inference step will be assigned + * i.e. the type assumptions in the conclusion of the returned inference step + * @param conclusionType the type that the lambda term in the conclusion + * of the returned inference step will be assigned * @return an {@link edu.kit.typicalc.model.step.LetStep} */ InferenceStep visit(LetTerm letTerm, Map typeAssumptions, Type conclusionType); @@ -57,12 +60,12 @@ public interface TermVisitorTree { * to type-infer and the type assumptions to consider. * Simultaneously assembles the tree's constraint list. * - * @param constTerm the constant to build the inference step structure for, - * i.e. the lambda term in the conclusion of the returned inference step + * @param constTerm the constant to build the inference step structure for, + * i.e. the lambda term in the conclusion of the returned inference step * @param typeAssumptions the type assumptions to consider, - * i.e. the type assumptions in the conclusion of the returned inference step - * @param conclusionType the type that the lambda term in the conclusion - * of the returned inference step will be assigned + * i.e. the type assumptions in the conclusion of the returned inference step + * @param conclusionType the type that the lambda term in the conclusion + * of the returned inference step will be assigned * @return an {@link edu.kit.typicalc.model.step.ConstStep} */ InferenceStep visit(ConstTerm constTerm, Map typeAssumptions, Type conclusionType); @@ -72,12 +75,12 @@ public interface TermVisitorTree { * to type-infer and the type assumptions to consider. * Simultaneously assembles the tree's constraint list. * - * @param varTerm the variable (lambda term) to build the inference step structure for, - * i.e. the lambda term in the conclusion of the returned inference step + * @param varTerm the variable (lambda term) to build the inference step structure for, + * i.e. the lambda term in the conclusion of the returned inference step * @param typeAssumptions the type assumptions to consider, - * i.e. the type assumptions in the conclusion of the returned inference step - * @param conclusionType the type that the lambda term in the conclusion - * of the returned inference step will be assigned + * i.e. the type assumptions in the conclusion of the returned inference step + * @param conclusionType the type that the lambda term in the conclusion + * of the returned inference step will be assigned * @return an {@link edu.kit.typicalc.model.step.VarStep} */ InferenceStep visit(VarTerm varTerm, Map typeAssumptions, Type conclusionType); diff --git a/src/main/java/edu/kit/typicalc/model/term/VarTerm.java b/src/main/java/edu/kit/typicalc/model/term/VarTerm.java index b301e46..8d1da7a 100644 --- a/src/main/java/edu/kit/typicalc/model/term/VarTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/VarTerm.java @@ -14,6 +14,7 @@ public class VarTerm extends LambdaTerm { /** * Initializes a new variable term with its name. + * * @param name the name of the variable */ public VarTerm(String name) { @@ -22,6 +23,8 @@ public class VarTerm extends LambdaTerm { } /** + * Returns the name of this variable + * * @return the name of this variable */ public String getName() { diff --git a/src/main/java/edu/kit/typicalc/model/term/package-info.java b/src/main/java/edu/kit/typicalc/model/term/package-info.java index cb2d914..df11d67 100644 --- a/src/main/java/edu/kit/typicalc/model/term/package-info.java +++ b/src/main/java/edu/kit/typicalc/model/term/package-info.java @@ -1,6 +1,6 @@ /** - * The term package models the different kinds of lambda terms: - * application, abstraction, variable constant and let-polymorphism. + * The term package models the different kinds of lambda terms: + * application, abstraction, variable constant and let-polymorphism. */ @NonNullFields @NonNullApi diff --git a/src/main/java/edu/kit/typicalc/model/type/FunctionType.java b/src/main/java/edu/kit/typicalc/model/type/FunctionType.java index e418865..bfa8500 100644 --- a/src/main/java/edu/kit/typicalc/model/type/FunctionType.java +++ b/src/main/java/edu/kit/typicalc/model/type/FunctionType.java @@ -14,10 +14,12 @@ public class FunctionType extends Type { private final Type parameter; private final Type output; + /** * Initializes a new FunctionType with the given parameter and output types. + * * @param parameter the type of this function’s parameter - * @param output the type of this function’s output + * @param output the type of this function’s output */ public FunctionType(Type parameter, Type output) { this.parameter = parameter; @@ -26,6 +28,7 @@ public class FunctionType extends Type { /** * Checks whether some type occurs in the parameter or output of this function. + * * @param x the type to look for * @return whether the specified type occurs in this type */ @@ -43,7 +46,8 @@ public class FunctionType extends Type { /** * Substitutes a type variable for a different type. - * @param a the type variable to replace + * + * @param a the type variable to replace * @param b the type to insert * @return a new FunctionType that is created by substituting a and b in the parameter * and output type @@ -55,6 +59,7 @@ public class FunctionType extends Type { /** * Accepts a visitor. + * * @param typeVisitor the visitor that wants to visit this */ @Override @@ -66,7 +71,8 @@ public class FunctionType extends Type { * Computes the necessary constraints (and substitution) to unify this type with * another. This method uses the constrainEqualToFunction method on the other * type. - * @param type the other type + * + * @param type the other type * @return unification steps necessary, or an error if that is impossible */ @Override @@ -77,6 +83,7 @@ public class FunctionType extends Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * function type. + * * @param type the function type * @return unification steps necessary, or an error if that is impossible */ @@ -88,6 +95,7 @@ public class FunctionType extends Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * named type. + * * @param type the named type * @return unification steps necessary, or an error if that is impossible */ @@ -99,6 +107,7 @@ public class FunctionType extends Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * type variable. + * * @param type the type variable * @return the unification steps necessary, or an error if that is impossible */ @@ -109,6 +118,7 @@ public class FunctionType extends Type { /** * Getter for output + * * @return output */ public Type getOutput() { @@ -117,6 +127,7 @@ public class FunctionType extends Type { /** * Getter for parameter + * * @return parameter */ public Type getParameter() { diff --git a/src/main/java/edu/kit/typicalc/model/type/NamedType.java b/src/main/java/edu/kit/typicalc/model/type/NamedType.java index ffcbd5d..e814c1d 100644 --- a/src/main/java/edu/kit/typicalc/model/type/NamedType.java +++ b/src/main/java/edu/kit/typicalc/model/type/NamedType.java @@ -24,6 +24,7 @@ public class NamedType extends Type { /** * Initializes a new NamedType with the given name. + * * @param name the name of this type */ public NamedType(String name) { @@ -32,6 +33,7 @@ public class NamedType extends Type { /** * Returns the name of the named type. + * * @return the name of this type */ public String getName() { @@ -40,6 +42,7 @@ public class NamedType extends Type { /** * Checks whether some type occurs in this type. + * * @param x the type to look for * @return whether the specified type is equal to this type */ @@ -54,6 +57,7 @@ public class NamedType extends Type { /** * Substitutes a type variable for a different type. + * * @param a the type to replace * @param b the type to insert * @return itself, or b if a is equal to this object @@ -65,6 +69,7 @@ public class NamedType extends Type { /** * Accepts a visitor. + * * @param typeVisitor the visitor that wants to visit this */ @Override @@ -76,7 +81,8 @@ public class NamedType extends Type { * Computes the necessary constraints (and substitution) to unify this type with * another. This method uses the constrainEqualToNamedType method on the other * type. - * @param type the other type + * + * @param type the other type * @return unification steps necessary, or an error if that is impossible */ @Override @@ -87,6 +93,7 @@ public class NamedType extends Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * function type. + * * @param type the function type * @return unification steps necessary, or an error if that is impossible */ @@ -98,6 +105,7 @@ public class NamedType extends Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * named type. + * * @param type the named type * @return unification steps necessary, or an error if that is impossible */ @@ -109,6 +117,7 @@ public class NamedType extends Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * type variable. + * * @param type the type variable * @return the unification steps necessary, or an error if that is impossible */ diff --git a/src/main/java/edu/kit/typicalc/model/type/Type.java b/src/main/java/edu/kit/typicalc/model/type/Type.java index 386efc2..f87a578 100644 --- a/src/main/java/edu/kit/typicalc/model/type/Type.java +++ b/src/main/java/edu/kit/typicalc/model/type/Type.java @@ -12,6 +12,7 @@ import java.util.Set; public abstract class 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 */ @@ -19,12 +20,14 @@ public abstract class Type { /** * Returns a set of all free type variables occurring in the type. + * * @return all free type variables */ public abstract Set getFreeTypeVariables(); /** * Substitutes a type Variable for a different type. + * * @param a the type to replace * @param b the type to insert * @return a Type that is created by replacing a with b @@ -33,6 +36,7 @@ public abstract class Type { /** * Applies the given substitution to the type. + * * @param substitution the substitution to apply to the type * @return the substituted type */ @@ -42,6 +46,7 @@ public abstract class Type { /** * Accepts a visitor + * * @param typeVisitor the visitor that wants to visit this */ public abstract void accept(TypeVisitor typeVisitor); @@ -49,7 +54,8 @@ public abstract class Type { /** * Computes the necessary constraints (and substitution) to unify this type with * another type. - * @param type the other type + * + * @param type the other type * @return unification steps necessary, or an error if that is impossible */ public abstract Result constrainEqualTo(Type type); @@ -57,6 +63,7 @@ public abstract class Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * function type. + * * @param type the function type * @return unification steps necessary, or an error if that is impossible */ @@ -65,6 +72,7 @@ public abstract class Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * named type. + * * @param type the named type * @return unification steps necessary, or an error if that is impossible */ @@ -73,6 +81,7 @@ public abstract class Type { /** * Computes the necessary constraints (and substitution) to unify this type with a * type variable. + * * @param type the type variable * @return the unification steps necessary, or an error if that is impossible */ diff --git a/src/main/java/edu/kit/typicalc/model/type/TypeAbstraction.java b/src/main/java/edu/kit/typicalc/model/type/TypeAbstraction.java index 6aecb1d..f2edfd8 100644 --- a/src/main/java/edu/kit/typicalc/model/type/TypeAbstraction.java +++ b/src/main/java/edu/kit/typicalc/model/type/TypeAbstraction.java @@ -13,10 +13,12 @@ public class TypeAbstraction { private final Type type; private final SortedSet quantifiedVariables; + /** * Initializes a new type abstraction with its type and the type variables bound by * the for-all quantifier. - * @param type the type of the type abstraction + * + * @param type the type of the type abstraction * @param quantifiedVariables the type variables bound by the for-all quantifier */ public TypeAbstraction(Type type, Set quantifiedVariables) { @@ -27,6 +29,7 @@ public class TypeAbstraction { /** * Initializes a new type abstraction with its type and no type variables bound by the * for-all quantifier. + * * @param type the type of the type abstraction */ public TypeAbstraction(Type type) { @@ -38,7 +41,7 @@ public class TypeAbstraction { * Initializes a new type abstraction with its type and all type variables quantified * that occur free in the given type, but not free in the given type assumptions * - * @param type the type of the type abstraction + * @param type the type of the type abstraction * @param typeAssumptions the type assumptions to consider when quantifying the type variables */ public TypeAbstraction(Type type, Map typeAssumptions) { @@ -52,7 +55,7 @@ public class TypeAbstraction { * Instantiates the type abstraction with a new type and returns it. The new type * contains new type variables generated by the given type variable factory. * - * @param typeVarFactory the type variable factory used to generate the new type variables + * @param typeVarFactory the type variable factory used to generate the new type variables * @return the new type resulting from the instantiation of the type abstraction */ public Type instantiate(TypeVariableFactory typeVarFactory) { @@ -66,6 +69,7 @@ public class TypeAbstraction { /** * Indicates whether any type variables are quantified in the type abstraction. + * * @return true if one or more type variables are quantified, false otherwise */ public boolean hasQuantifiedVariables() { @@ -75,6 +79,7 @@ public class TypeAbstraction { /** * Returns a list of all type variables that are bound by an for-all quantifier in the * type abstraction. + * * @return a list of all quantified type variables */ public Set getQuantifiedVariables() { @@ -83,6 +88,7 @@ public class TypeAbstraction { /** * Returns a set of all free type variables occurring in the type abstraction. + * * @return all free type variables */ public Set getFreeTypeVariables() { @@ -93,6 +99,7 @@ public class TypeAbstraction { /** * Getter for the inner type of the type abstraction + * * @return the inner type of the type abstraction */ public Type getInnerType() { diff --git a/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java b/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java index e84d60f..dedf1ae 100644 --- a/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java +++ b/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java @@ -16,7 +16,7 @@ public class TypeVariable extends Type implements Comparable { /** * Initializes a new TypeVariable with the given index. * - * @param kind the kind of type variable + * @param kind the kind of type variable * @param index the index of this variable */ public TypeVariable(TypeVariableKind kind, int index) { @@ -26,6 +26,7 @@ public class TypeVariable extends Type implements Comparable { /** * Returns the kind of the type variable. + * * @return the variable's kind */ public TypeVariableKind getKind() { @@ -34,6 +35,7 @@ public class TypeVariable extends Type implements Comparable { /** * Returns the index of the type variable as an integer + * * @return the variable's index */ public int getIndex() { @@ -42,6 +44,7 @@ public class TypeVariable extends Type implements Comparable { /** * Checks whether some type occurs in this type. + * * @param x the type to look for * @return whether the specified type is equal to this type */ @@ -57,6 +60,7 @@ public class TypeVariable extends Type implements Comparable { /** * Substitutes a type variable for a different type. + * * @param a the type to replace * @param b the type to insert * @return itself, or b if a is equal to this object @@ -64,7 +68,7 @@ public class TypeVariable extends Type implements Comparable { @Override public Type substitute(TypeVariable a, Type b) { if (this.equals(a)) { - return b; + return b; } else { return this; } @@ -72,6 +76,7 @@ public class TypeVariable extends Type implements Comparable { /** * Accepts a visitor. + * * @param typeVisitor the visitor that wants to visit this */ public void accept(TypeVisitor typeVisitor) { @@ -82,7 +87,8 @@ public class TypeVariable extends Type implements Comparable { * Computes the necessary constraints (and substitution) to unify this type with * another. This method uses the constrainEqualToVariable method on the other * type. - * @param type the other type + * + * @param type the other type * @return unification steps necessary, or an error if that is impossible */ @Override @@ -93,6 +99,7 @@ public class TypeVariable extends Type implements Comparable { /** * Computes the necessary constraints (and substitution) to unify this type with a * function type. + * * @param type the function type * @return unification steps necessary, or an error if that is impossible */ @@ -104,6 +111,7 @@ public class TypeVariable extends Type implements Comparable { /** * Computes the necessary constraints (and substitution) to unify this type with a * named type. + * * @param type the named type * @return unification steps necessary, or an error if that is impossible */ @@ -115,6 +123,7 @@ public class TypeVariable extends Type implements Comparable { /** * Computes the necessary constraints (and substitution) to unify this type with a * type variable. + * * @param type the type variable * @return the unification steps necessary, or an error if that is impossible */ diff --git a/src/main/java/edu/kit/typicalc/model/type/TypeVisitor.java b/src/main/java/edu/kit/typicalc/model/type/TypeVisitor.java index f09d7dc..c680752 100644 --- a/src/main/java/edu/kit/typicalc/model/type/TypeVisitor.java +++ b/src/main/java/edu/kit/typicalc/model/type/TypeVisitor.java @@ -6,18 +6,21 @@ package edu.kit.typicalc.model.type; public interface TypeVisitor { /** * Visit a named type. + * * @param named the type to be visited */ void visit(NamedType named); /** * Visit a type variable + * * @param variable the variable to be visited */ void visit(TypeVariable variable); /** * Visit a function. + * * @param function the function to be visited */ void visit(FunctionType function); diff --git a/src/main/java/edu/kit/typicalc/model/type/UnificationActions.java b/src/main/java/edu/kit/typicalc/model/type/UnificationActions.java index 9d947a4..c38ac68 100644 --- a/src/main/java/edu/kit/typicalc/model/type/UnificationActions.java +++ b/src/main/java/edu/kit/typicalc/model/type/UnificationActions.java @@ -16,7 +16,8 @@ public class UnificationActions { /** * Initializes this object using the provided constraints and substitution. - * @param constraints added constraints, if any + * + * @param constraints added constraints, if any * @param substitution necessary substitution, if any */ protected UnificationActions(Collection constraints, Optional substitution) { @@ -34,13 +35,16 @@ public class UnificationActions { /** * Getter for constraints + * * @return the constraints stored in this object */ public Collection getConstraints() { return constraints; } + /** * Getter for substitution + * * @return the substitution stored in this object */ public Optional getSubstitution() { diff --git a/src/main/java/edu/kit/typicalc/model/type/UnificationUtil.java b/src/main/java/edu/kit/typicalc/model/type/UnificationUtil.java index bd43915..c528097 100644 --- a/src/main/java/edu/kit/typicalc/model/type/UnificationUtil.java +++ b/src/main/java/edu/kit/typicalc/model/type/UnificationUtil.java @@ -15,7 +15,8 @@ import java.util.Optional; * @see Type */ final class UnificationUtil { - private UnificationUtil() { } + private UnificationUtil() { + } static Result functionFunction(FunctionType a, FunctionType b) { return new Result<>(new UnificationActions(List.of( diff --git a/src/main/java/edu/kit/typicalc/model/type/package-info.java b/src/main/java/edu/kit/typicalc/model/type/package-info.java index 6adceed..bced12f 100644 --- a/src/main/java/edu/kit/typicalc/model/type/package-info.java +++ b/src/main/java/edu/kit/typicalc/model/type/package-info.java @@ -1,5 +1,5 @@ /** - * The type package models all types that can be assigned to lambda terms. + * The type package models all types that can be assigned to lambda terms. */ @NonNullApi @NonNullFields diff --git a/src/main/java/edu/kit/typicalc/presenter/Presenter.java b/src/main/java/edu/kit/typicalc/presenter/Presenter.java index 732cfce..22d6065 100644 --- a/src/main/java/edu/kit/typicalc/presenter/Presenter.java +++ b/src/main/java/edu/kit/typicalc/presenter/Presenter.java @@ -1,6 +1,7 @@ package edu.kit.typicalc.presenter; import java.util.Map; + import edu.kit.typicalc.model.Model; import edu.kit.typicalc.model.TypeInfererInterface; import edu.kit.typicalc.model.parser.ParseError; @@ -18,8 +19,9 @@ public class Presenter implements MainViewListener { /** * Initializes a new presenter object with the provided model and view. + * * @param model the implementation of the Model - * @param view the implementation of the MainView + * @param view the implementation of the MainView */ public Presenter(Model model, MainView view) { this.model = model; diff --git a/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java b/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java index abbaad8..6a3cc2f 100644 --- a/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java +++ b/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; + import org.springframework.stereotype.Component; import com.vaadin.flow.i18n.I18NProvider; diff --git a/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java b/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java index 7bc6f8b..4bbd1de 100644 --- a/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java +++ b/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java @@ -22,7 +22,7 @@ public class ControlPanel extends HorizontalLayout { /** * Sets up buttons with click-listeners that call the corresponding method in the view. * - * @param view the view that reacts to the button clicks + * @param view the view that reacts to the button clicks * @param focusArea the component key shortcuts should work in */ public ControlPanel(ControlPanelView view, Component focusArea) { diff --git a/src/main/java/edu/kit/typicalc/view/content/ControlPanelView.java b/src/main/java/edu/kit/typicalc/view/content/ControlPanelView.java index 33ebb35..dd57de8 100644 --- a/src/main/java/edu/kit/typicalc/view/content/ControlPanelView.java +++ b/src/main/java/edu/kit/typicalc/view/content/ControlPanelView.java @@ -1,10 +1,16 @@ package edu.kit.typicalc.view.content; +/** + * Provides an interface for the ControlPanel to interact with its views. If a view doesn't + * support a certain operation(s), it may provide a dummy implementation and/or disable + * the corresponding button(s). + */ public interface ControlPanelView { /** * Provides user with a way to share contents shown in the view (the URL and LaTeX code). */ - default void shareButton() { } + default void shareButton() { + } /** * Go to the first step. diff --git a/src/main/java/edu/kit/typicalc/view/content/infocontent/ImageSlide.java b/src/main/java/edu/kit/typicalc/view/content/infocontent/ImageSlide.java index b7d7a12..27a919d 100644 --- a/src/main/java/edu/kit/typicalc/view/content/infocontent/ImageSlide.java +++ b/src/main/java/edu/kit/typicalc/view/content/infocontent/ImageSlide.java @@ -17,16 +17,16 @@ import com.vaadin.flow.i18n.LocaleChangeObserver; public class ImageSlide extends Slide implements LocaleChangeObserver { private static final long serialVersionUID = 232255503611054445L; - + private static final String SLIDE_LAYOUT_ID = "slideLayout"; private static final String EXPLANATION_ID = "explanation"; - + private final Span explanation; private final String explanationKey; - + /** * Create a new ImageSlide with the path of the image and a key for the text. - * + * * @param imgPath the path of the image * @param textKey key for the text */ @@ -40,7 +40,7 @@ public class ImageSlide extends Slide implements LocaleChangeObserver { slideLayout.setId(SLIDE_LAYOUT_ID); add(slideLayout); } - + @Override public void localeChange(LocaleChangeEvent event) { explanation.setText(getTranslation(explanationKey)); diff --git a/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java b/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java index 6d6d243..d1244a7 100644 --- a/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java +++ b/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java @@ -29,7 +29,7 @@ import edu.kit.typicalc.view.main.MainViewImpl; public class StartPageView extends VerticalLayout implements ControlPanelView, LocaleChangeObserver { private static final long serialVersionUID = 2502750919087936406L; - + private static final String HEADING_ID = "startPage-Heading"; private static final String H_LINE_ID = "horizontalLine"; private static final String INTRODUCTION_ID = "introduction"; @@ -40,14 +40,14 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L private static final String SLIDE_SHOW_ID = "slideShow"; private static final String DOT = "."; - + private final ControlPanel controlPanel; private final Span introduction; private final Carousel slideShow; private final ProgressBar slideProgress; private final Text linkText; private final Anchor link; - + /** * Fills the view with content. */ @@ -55,10 +55,10 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L controlPanel = new ControlPanel(this, this); controlPanel.setId(CONTROL_PANEL_ID); controlPanel.setEnabledShareButton(false); - + slideShow = createSzenarioCarousel(); slideShow.setId(SLIDE_SHOW_ID); - + H1 heading = new H1(getTranslation("root.typicalc")); heading.setId(HEADING_ID); Hr line1 = new Hr(); @@ -67,16 +67,16 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L line2.setId(H_LINE_ID); introduction = new Span(getTranslation("root.slideExp")); introduction.setId(INTRODUCTION_ID); - + linkText = new Text(getTranslation("root.linkText")); link = new Anchor(getTranslation("root.link"), getTranslation("root.here")); link.setTarget("_blank"); // opens new tab Span linkContainer = new Span(linkText, link, new Text(DOT)); linkContainer.setId(LINK_CONTAINER_ID); - + slideProgress = new ProgressBar(slideShow.getStartPosition(), slideShow.getSlides().length - 1); slideProgress.setId(SLIDE_PROGRESS_ID); - + add(heading, line1, introduction, linkContainer, slideProgress, slideShow, line2, controlPanel); setId(START_PAGE_ID); } @@ -90,11 +90,11 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L Slide slide6 = new ImageSlide(getTranslation("root.image6"), "root.text6"); Slide slide7 = new ImageSlide(getTranslation("root.image7"), "root.text7"); Slide slide8 = new ImageSlide(getTranslation("root.image8"), "root.text8"); - + return new Carousel(slide1, slide2, slide3, slide4, slide5, slide6, slide7, slide8).withoutNavigation() .withoutSwipe(); } - + @Override public void firstStepButton() { slideShow.movePos(0); @@ -116,10 +116,10 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L @Override public void previousStepButton() { slideShow.movePrev(); - slideProgress.setValue((slideProgress.getValue() - 1 + slideShow.getSlides().length) + slideProgress.setValue((slideProgress.getValue() - 1 + slideShow.getSlides().length) % slideShow.getSlides().length); } - + @Override public void localeChange(LocaleChangeEvent event) { introduction.setText(getTranslation("root.slideExp")); diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java index 0d6053f..1c97202 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java @@ -26,6 +26,7 @@ public class MathjaxUnification extends LitTemplate implements MathjaxAdapter { /** * Creates a new HTML element that renders the constraints and unification and * calculates the steps. + * * @param latex the LaTeX-String[] to render with MathJax */ public MathjaxUnification(String[] latex) { diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java index dce263c..7eee3f8 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java @@ -24,10 +24,11 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { /** * Sets up three GUI elements, one for each parameter. The content of each element is equal * to the String that is passed as corresponding parameter. - * @param url a permalink to share with other users + * + * @param url a permalink to share with other users * @param latexPackages the needed LaTeX-packages to use the displayed mathematics - * in other LaTeX documents. Should be in the form „\\usepackage“ - * @param latexCode LaTeX code for users to copy into their own LaTeX document(s) + * in other LaTeX documents. Should be in the form „\\usepackage<package>“ + * @param latexCode LaTeX code for users to copy into their own LaTeX document(s) */ public ShareDialog(String url, String latexPackages, String latexCode) { VerticalLayout layout = new VerticalLayout(); diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java index 3eafc45..9ac60b7 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java @@ -15,6 +15,13 @@ import edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.LatexCrea import java.util.List; import java.util.Locale; +/** + * The main user interface. It provides a way to show the proof tree, the constrains, the + * unification, the most general unifier and the final type of the lambda term to the user. + * Also provides a way for the user to interact with it, e.g. looking at everything step-by-step. + * In order to do this, this class uses {@link LatexCreator} tp create LaTeX-code from the + * {@link TypeInfererInterface} and MathJax to render the LaTeX to the user. + */ @CssImport("./styles/view/type-inference.css") public class TypeInferenceView extends VerticalLayout implements ControlPanelView, ComponentEventListener { @@ -36,6 +43,12 @@ public class TypeInferenceView extends VerticalLayout private final transient LatexCreator lc; private final Div content; + /** + * Initializes the component. When initialization is complete, the first step of the type + * inference algorithm is shown to the user. + * + * @param typeInferer used to create LaTeX code from + */ public TypeInferenceView(TypeInfererInterface typeInferer) { setId(ID); addAttachListener(this); @@ -64,7 +77,7 @@ public class TypeInferenceView extends VerticalLayout @Override public void shareButton() { UI.getCurrent().getPage().executeJs("return decodeURI(window.location.href)").then(url -> - new ShareDialog(url.asString(), lc.getLatexPackages(), lc.getTree()).open() + new ShareDialog(url.asString(), lc.getLatexPackages(), lc.getTree()).open() ); } diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/AssumptionGeneratorUtil.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/AssumptionGeneratorUtil.java index 2160295..16f5de8 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/AssumptionGeneratorUtil.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/AssumptionGeneratorUtil.java @@ -8,8 +8,13 @@ import java.util.Map; import static edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.LatexCreatorConstants.*; import static edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.LatexCreatorConstants.DOT_SIGN; +/** + * Util class for {@link LatexCreator} and {@link LatexCreatorConstraints} to generate LaTeX code from + * a Map representing type assumptions. + */ public final class AssumptionGeneratorUtil { - private AssumptionGeneratorUtil() { } + private AssumptionGeneratorUtil() { + } protected static String typeAssumptionsToLatex(Map typeAssumptions) { if (typeAssumptions.isEmpty()) { diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/ConstraintSetIndexFactory.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/ConstraintSetIndexFactory.java index 16410a6..066d3e8 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/ConstraintSetIndexFactory.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/ConstraintSetIndexFactory.java @@ -29,10 +29,10 @@ public class ConstraintSetIndexFactory { protected String nextConstraintSetIndex() { String index = nextConstraintSetIndex == FIRST_CONSTRAINT_SET_INDEX ? "" - : nextConstraintSetIndex == FIRST_CONSTRAINT_SET_INDEX + 1 - ? "" + UNDERSCORE + CURLY_LEFT + LET + CURLY_RIGHT - : "" + UNDERSCORE + CURLY_LEFT + LET + UNDERSCORE - + CURLY_LEFT + nextConstraintSetIndex + CURLY_RIGHT + CURLY_RIGHT; + : nextConstraintSetIndex == FIRST_CONSTRAINT_SET_INDEX + 1 + ? "" + UNDERSCORE + CURLY_LEFT + LET + CURLY_RIGHT + : "" + UNDERSCORE + CURLY_LEFT + LET + UNDERSCORE + + CURLY_LEFT + nextConstraintSetIndex + CURLY_RIGHT + CURLY_RIGHT; nextConstraintSetIndex++; return index; diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java index 710cfe6..866087f 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java @@ -28,7 +28,7 @@ public class LatexCreator implements StepVisitor { /** * Generate the pieces of LaTeX-code from the type inferer. * - * @param typeInferer theTypeInfererInterface to create the LaTeX-code from + * @param typeInferer theTypeInfererInterface to create the LaTeX-code from * @param translationProvider translation text provider for {@link UnificationError} */ public LatexCreator(TypeInfererInterface typeInferer, Function translationProvider) { @@ -38,8 +38,8 @@ public class LatexCreator implements StepVisitor { /** * Generate the pieces of LaTeX-code from the type inferer. * - * @param typeInferer theTypeInfererInterface to create the LaTeX code from - * @param stepLabels turns step labels on or off + * @param typeInferer theTypeInfererInterface to create the LaTeX code from + * @param stepLabels turns step labels on or off * @param translationProvider translation text provider for {@link UnificationError} */ public LatexCreator(TypeInfererInterface typeInferer, boolean stepLabels, @@ -51,7 +51,7 @@ public class LatexCreator implements StepVisitor { } /** - * Returns the proof tree + * Returns the proof tree. * * @return the LaTeX-code for the proof tree */ @@ -60,7 +60,7 @@ public class LatexCreator implements StepVisitor { } /** - * Returns the LaTeX-code for constraints, unification, MGU and final type + * Returns the LaTeX-code for constraints, unification, MGU and final type. * * @return the LaTeX-code for constraints and unification */ diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java index f077ba2..b77ea77 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java @@ -40,7 +40,7 @@ public class LatexCreatorConstraints implements StepVisitor { * Initializes the LatexCreatorConstraints with the right values calculates the strings * that will be returned in getEverything(). * - * @param typeInferer the source for the generation of the LaTeX code + * @param typeInferer the source for the generation of the LaTeX code * @param translationProvider translation text provider for {@link UnificationError} */ protected LatexCreatorConstraints(TypeInfererInterface typeInferer, @@ -51,12 +51,12 @@ public class LatexCreatorConstraints implements StepVisitor { } private LatexCreatorConstraints(TypeInfererInterface typeInferer, - ConstraintSetIndexFactory constraintSetIndexFactory, - TreeNumberGenerator numberGenerator, - String prefix, - Optional letVariable, - Optional> newTypeAssumption, - Function translationProvider) { + ConstraintSetIndexFactory constraintSetIndexFactory, + TreeNumberGenerator numberGenerator, + String prefix, + Optional letVariable, + Optional> newTypeAssumption, + Function translationProvider) { this.prefix = prefix; this.letVariable = letVariable; this.newTypeAssumption = newTypeAssumption; diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorTerm.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorTerm.java index 453791e..3781e19 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorTerm.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorTerm.java @@ -13,6 +13,7 @@ import static edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.La public class LatexCreatorTerm implements TermVisitor { private final StringBuilder latex = new StringBuilder(); + private enum ParenthesesNeeded { NEVER, SOMETIMES, @@ -31,16 +32,11 @@ public class LatexCreatorTerm implements TermVisitor { } /** + * Returns the generated LaTeX code + * * @return the generated LaTeX code */ public String getLatex() { -// long count = latex.chars().filter(ch -> ch == PAREN_LEFT).count(); -// if (latex.indexOf(String.valueOf(PAREN_LEFT)) == 0 -// && latex.indexOf(String.valueOf(PAREN_RIGHT)) == latex.length() - 1 -// && count == 1) { -// latex.deleteCharAt(latex.length() - 1); -// latex.deleteCharAt(0); -// } return latex.toString(); } diff --git a/src/main/java/edu/kit/typicalc/view/main/ErrorNotification.java b/src/main/java/edu/kit/typicalc/view/main/ErrorNotification.java index 5b52527..65e94a0 100644 --- a/src/main/java/edu/kit/typicalc/view/main/ErrorNotification.java +++ b/src/main/java/edu/kit/typicalc/view/main/ErrorNotification.java @@ -41,21 +41,21 @@ public class ErrorNotification extends Notification { setPosition(Position.MIDDLE); setId(NOTIFICATION_ID); } - + private Details buildErrorMessage(ParseError error) { VerticalLayout additionalInformation = new VerticalLayout(); additionalInformation.setId(ADDITIONAL_INFO_ID); Paragraph summary = new Paragraph(getTranslation("root." + error.toString())); summary.setId(ERROR_SUMMARY_ID); Details errorMessage = new Details(summary, additionalInformation); - + if (error == ParseError.TOO_FEW_TOKENS) { additionalInformation.add(new Span(getTranslation("root.tooFewTokensHelp"))); } else { additionalInformation.add(new Span(getTranslation("root.wrongCharacter") + error.getCause().getText())); additionalInformation.add(new Span(getTranslation("root.position") + error.getCause().getPos())); } - + return errorMessage; } } diff --git a/src/main/java/edu/kit/typicalc/view/main/ExampleDialog.java b/src/main/java/edu/kit/typicalc/view/main/ExampleDialog.java index 79d7c24..d53b970 100644 --- a/src/main/java/edu/kit/typicalc/view/main/ExampleDialog.java +++ b/src/main/java/edu/kit/typicalc/view/main/ExampleDialog.java @@ -12,7 +12,6 @@ import java.util.function.Consumer; /** * Contains all predefined examples as buttons. * Clicking on a button inserts the example string into the input field. - * */ public class ExampleDialog extends Dialog implements LocaleChangeObserver { @@ -35,8 +34,8 @@ public class ExampleDialog extends Dialog implements LocaleChangeObserver { for (String term : examples) { Button button = new Button(term); button.addClickListener(click -> { - callback.accept(term); - this.close(); + callback.accept(term); + this.close(); }); button.setId(term); // needed for integration test layout.add(button); diff --git a/src/main/java/edu/kit/typicalc/view/main/HelpContentField.java b/src/main/java/edu/kit/typicalc/view/main/HelpContentField.java index 0534d55..36185cf 100644 --- a/src/main/java/edu/kit/typicalc/view/main/HelpContentField.java +++ b/src/main/java/edu/kit/typicalc/view/main/HelpContentField.java @@ -23,7 +23,7 @@ public class HelpContentField extends AccordionPanel implements LocaleChangeObse /** * Create a HelpContentField with keys for the strings of the summary and the content of this AccordionPanel. - * + * * @param summaryKey the key for the string of the summary * @param contentKey the key for the string of the content */ @@ -39,9 +39,9 @@ public class HelpContentField extends AccordionPanel implements LocaleChangeObse /** * Create a HelpContentField with a button and keys for the string of the summary and the content of this * AccordionPanel. - * + * * @param summaryKey the key for the string of the summary - * @param button the button + * @param button the button * @param contentKey the key for the string of the content */ protected HelpContentField(String summaryKey, Button button, String contentKey) { diff --git a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java index 8c6b256..4ef8a1b 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java +++ b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java @@ -39,7 +39,7 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb * Initializes an InferenceRuleField with a key to get the name of the inference rule and the LaTeX-code * for its visual representation. * - * @param latex the LaTeX-code + * @param latex the LaTeX-code * @param nameKey the key to get the name of the inference rule */ protected InferenceRuleField(String latex, String nameKey) { diff --git a/src/main/java/edu/kit/typicalc/view/main/InputBar.java b/src/main/java/edu/kit/typicalc/view/main/InputBar.java index 8549d47..62a355c 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java @@ -58,19 +58,19 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { inputField.setId(INPUT_FIELD_ID); inputField.setClearButtonVisible(true); inputField.setMaxLength(MAX_INPUT_LENGTH); - + // attach a listener that replaces \ with λ // JavaScript is used because Vaadin does not have APIs for selectionStart/selectionEnd UI.getCurrent().getPage().executeJs( "document.getElementById('" + INPUT_FIELD_ID + "').addEventListener('keyup', e => {" - + "var area = e.target.shadowRoot.querySelector('input');" - + "if (area.value.indexOf('\\\\') >= 0) {" - + " var start = area.selectionStart;" - + " var end = area.selectionEnd;" - + " area.value = area.value.replace('\\\\', 'λ');" - + " area.selectionStart = start;" - + " area.selectionEnd = end;" - + "}});"); + + "var area = e.target.shadowRoot.querySelector('input');" + + "if (area.value.indexOf('\\\\') >= 0) {" + + " var start = area.selectionStart;" + + " var end = area.selectionEnd;" + + " area.value = area.value.replace('\\\\', 'λ');" + + " area.selectionStart = start;" + + " area.selectionEnd = end;" + + "}});"); Button lambdaButton = new Button(getTranslation("root.lambda")); lambdaButton.setId(LAMBDA_BUTTON_ID); UI.getCurrent().getPage().executeJs("window.lambdaButtonListener($0, $1);", LAMBDA_BUTTON_ID, INPUT_FIELD_ID); diff --git a/src/main/java/edu/kit/typicalc/view/main/MainView.java b/src/main/java/edu/kit/typicalc/view/main/MainView.java index fd21d12..9111e15 100644 --- a/src/main/java/edu/kit/typicalc/view/main/MainView.java +++ b/src/main/java/edu/kit/typicalc/view/main/MainView.java @@ -1,9 +1,10 @@ package edu.kit.typicalc.view.main; -import java.util.Map; import edu.kit.typicalc.model.TypeInfererInterface; import edu.kit.typicalc.model.parser.ParseError; +import java.util.Map; + /** * Provides an interface for the presenter to interact with the view. The interaction consists of * either passing a TypeInfererInterface or a ParseError to the view. @@ -13,27 +14,27 @@ public interface MainView { /** * Starts the creation of the visual representation of the provided typeInferer. * After the process is finished, the first step of the type inference tree is displayed. - * + * * @param typeInferer the result of the computation of the type inference algorithm */ void setTypeInferenceView(TypeInfererInterface typeInferer); - + /** * Displays the provided error indicating syntactically invalid input. - * + * * @param error the error which is displayed to indicate invalid input */ void displayError(ParseError error); - + /** - * Provides an interface for the view to interact with the model. + * Provides an interface for the view to interact with the model. */ interface MainViewListener { - + /** * Provides the user input to the model and provide the result to the main view. - * - * @param lambdaTerm the lambda term to type-infer + * + * @param lambdaTerm the lambda term to type-infer * @param typeAssumptions type assumptions to use during the calculation */ void typeInferLambdaString(String lambdaTerm, Map typeAssumptions); diff --git a/src/main/java/edu/kit/typicalc/view/main/MathjaxDisplay.java b/src/main/java/edu/kit/typicalc/view/main/MathjaxDisplay.java index 2d54dd4..7ed73e3 100644 --- a/src/main/java/edu/kit/typicalc/view/main/MathjaxDisplay.java +++ b/src/main/java/edu/kit/typicalc/view/main/MathjaxDisplay.java @@ -18,6 +18,7 @@ public class MathjaxDisplay extends LitTemplate implements MathjaxAdapter { @Id("tc-content") private Div content; + /** * Creates a new HTML element that renders the LaTeX code. * diff --git a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java index b726960..6e999d7 100644 --- a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java +++ b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java @@ -36,8 +36,8 @@ public class TypeAssumptionField extends HorizontalLayout implements LocaleChang * type assumption from the {@link TypeAssumptionsArea}. * * @param deleteSelf deletes this object from the TypeAssumptionsArea - * @param variable variable of the type assumption - * @param type type of the type assumption + * @param variable variable of the type assumption + * @param type type of the type assumption */ protected TypeAssumptionField(Consumer deleteSelf, String variable, String type) { this(deleteSelf); diff --git a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java index c86b616..a17b133 100644 --- a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java +++ b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java @@ -69,7 +69,7 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver assumptionContainer = new VerticalLayout(); assumptionContainer.setId(ASS_CONTAINER_ID); - + initializeWithAssumptions(types); layout.add(heading, buttons, assumptionContainer); add(layout); @@ -82,7 +82,7 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver protected TypeAssumptionsArea() { this(new HashMap<>()); } - + private void initializeWithAssumptions(Map types) { for (Map.Entry param : types.entrySet()) { TypeAssumptionField assumption = new TypeAssumptionField(value -> { diff --git a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java index 0c46478..e94223c 100644 --- a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java @@ -40,8 +40,8 @@ public class UpperBar extends HorizontalLayout { /** * Initializes a new UpperBar with the provided mainViewListener. * - * @param presenter the listener used to communicate with the model - * @param setContent function to set the content of the application + * @param presenter the listener used to communicate with the model + * @param setContent function to set the content of the application * @param setTermInURL function to set the term into the URL */ protected UpperBar(MainViewListener presenter, Consumer setContent, @@ -79,7 +79,7 @@ public class UpperBar extends HorizontalLayout { * Calls the inferTerm method in {@link InputBar} with the provided * string as the argument. * - * @param term the provided string + * @param term the provided string * @param typeAssumptions type assumptions to use */ protected void inferTerm(String term, Map typeAssumptions) { diff --git a/src/main/java/edu/kit/typicalc/view/main/package-info.java b/src/main/java/edu/kit/typicalc/view/main/package-info.java index 13247e1..8a8696c 100644 --- a/src/main/java/edu/kit/typicalc/view/main/package-info.java +++ b/src/main/java/edu/kit/typicalc/view/main/package-info.java @@ -1,4 +1,4 @@ -/** +/** * This package contains classes for building the constantly displayed parts of the UI. This includes classes * which provide methods to pass the user input to the {@link edu.kit.typicalc.presenter.Presenter}. */ diff --git a/src/test/java/edu/kit/typicalc/model/ModelImplTest.java b/src/test/java/edu/kit/typicalc/model/ModelImplTest.java index e8e5eea..2595cae 100644 --- a/src/test/java/edu/kit/typicalc/model/ModelImplTest.java +++ b/src/test/java/edu/kit/typicalc/model/ModelImplTest.java @@ -58,9 +58,9 @@ class ModelImplTest { new Conclusion(Map.of( x, new TypeAbstraction(NamedType.INT), y, new TypeAbstraction(a2)), - x, a3), + x, a3), new Constraint(a3, NamedType.INT) - ), + ), new Conclusion(Map.of(x, new TypeAbstraction(NamedType.INT)), term, a1), new Constraint(a1, new FunctionType(a2, a3)) ), typeInference.getFirstInferenceStep() diff --git a/src/test/java/edu/kit/typicalc/model/step/AbsStepWithLetTest.java b/src/test/java/edu/kit/typicalc/model/step/AbsStepWithLetTest.java index a74e0e7..fe5a463 100644 --- a/src/test/java/edu/kit/typicalc/model/step/AbsStepWithLetTest.java +++ b/src/test/java/edu/kit/typicalc/model/step/AbsStepWithLetTest.java @@ -35,6 +35,7 @@ class AbsStepWithLetTest { constraint = new Constraint(type1, type2); premise = new ConstStepDefault(conclusion, constraint); } + @Test void equalsTest() { AbsStepWithLet step1 = new AbsStepWithLet(premise, conclusion, constraint); diff --git a/src/test/java/edu/kit/typicalc/model/step/AppStepDefaultTest.java b/src/test/java/edu/kit/typicalc/model/step/AppStepDefaultTest.java index 84b19b8..15bc06c 100644 --- a/src/test/java/edu/kit/typicalc/model/step/AppStepDefaultTest.java +++ b/src/test/java/edu/kit/typicalc/model/step/AppStepDefaultTest.java @@ -22,6 +22,7 @@ class AppStepDefaultTest { static Constraint constraint = null; static NamedType namedType = null; static TypeAbstraction typeAbstraction = null; + @BeforeAll static void setUp() { Map map = new LinkedHashMap<>(); @@ -37,6 +38,7 @@ class AppStepDefaultTest { premise1 = new ConstStepDefault(conclusion, constraint); premise2 = new ConstStepDefault(conclusion, constraint); } + @Test void equalsTest() { AppStepDefault step1 = new AppStepDefault(premise1, premise2, conclusion, constraint); @@ -54,6 +56,7 @@ class AppStepDefaultTest { assertNotEquals(step1, step5); } + @Test void hashCodeTest() { AppStepDefault step1 = new AppStepDefault(premise1, premise2, conclusion, constraint); diff --git a/src/test/java/edu/kit/typicalc/model/step/ConstStepDefaultTest.java b/src/test/java/edu/kit/typicalc/model/step/ConstStepDefaultTest.java index ca18f89..921772e 100644 --- a/src/test/java/edu/kit/typicalc/model/step/ConstStepDefaultTest.java +++ b/src/test/java/edu/kit/typicalc/model/step/ConstStepDefaultTest.java @@ -20,6 +20,7 @@ class ConstStepDefaultTest { static Constraint constraint = null; static NamedType namedType = null; static TypeAbstraction typeAbstraction = null; + @BeforeAll static void setUp() { Map map = new LinkedHashMap<>(); @@ -33,6 +34,7 @@ class ConstStepDefaultTest { NamedType type2 = new NamedType("b"); constraint = new Constraint(type1, type2); } + @Test void equalsTest() { ConstStepDefault step1 = new ConstStepDefault(conclusion, constraint); @@ -45,6 +47,7 @@ class ConstStepDefaultTest { assertNotEquals(step1, step3); } + @Test void hashCodeTest() { ConstStepDefault step1 = new ConstStepDefault(conclusion, constraint); diff --git a/src/test/java/edu/kit/typicalc/model/step/VarStepDefaultTest.java b/src/test/java/edu/kit/typicalc/model/step/VarStepDefaultTest.java index 0125a9c..c172cc3 100644 --- a/src/test/java/edu/kit/typicalc/model/step/VarStepDefaultTest.java +++ b/src/test/java/edu/kit/typicalc/model/step/VarStepDefaultTest.java @@ -21,6 +21,7 @@ class VarStepDefaultTest { static Constraint constraint = null; static NamedType namedType = null; static TypeAbstraction typeAbstraction = null; + @BeforeAll static void setUp() { Map map = new LinkedHashMap<>(); @@ -34,6 +35,7 @@ class VarStepDefaultTest { NamedType type2 = new NamedType("b"); constraint = new Constraint(type1, type2); } + @Test void equalsTest() { VarStepDefault step1 = new VarStepDefault(typeAbstraction, namedType, conclusion, constraint); @@ -51,6 +53,7 @@ class VarStepDefaultTest { assertNotEquals(step1, step5); } + @Test void hashCodeTest() { VarStepDefault step1 = new VarStepDefault(typeAbstraction, namedType, conclusion, constraint); diff --git a/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java b/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java index a8956a4..d2430e8 100644 --- a/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java +++ b/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java @@ -1,18 +1,16 @@ package edu.kit.typicalc.view; -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; +import com.vaadin.testbench.Parameters; +import com.vaadin.testbench.commands.TestBenchCommandExecutor; +import edu.kit.typicalc.view.pageobjects.InputBarElement; +import org.junit.Test; +import org.openqa.selenium.HasCapabilities; import java.io.File; import java.io.IOException; -import org.junit.Test; -import org.openqa.selenium.HasCapabilities; - -import com.vaadin.testbench.Parameters; -import com.vaadin.testbench.commands.TestBenchCommandExecutor; - -import edu.kit.typicalc.view.pageobjects.InputBarElement; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This example contains usage examples of screenshot comparison feature. @@ -21,7 +19,7 @@ import edu.kit.typicalc.view.pageobjects.InputBarElement; public class ScreenshotIT extends AbstractIT { private static final String IDENTITY_TERM = "λx.x"; - + /** * We'll want to perform some additional setup functions, so we override the * setUp() method. @@ -56,25 +54,25 @@ public class ScreenshotIT extends AbstractIT { + " for error images", testBench().compareScreen("initialView")); } - + @Test public void basicExecution() throws Exception { //TODO take screenshot and add to proper folder InputBarElement inputBar = $(InputBarElement.class).first(); inputBar.setCurrentValue(IDENTITY_TERM); - + assertEquals(IDENTITY_TERM, inputBar.getCurrentValue()); - + inputBar.typeInfer(); TestBenchCommandExecutor executer = getCommandExecutor(); executer.waitForVaadin(); - + assertTrue("Screenshot comparison for 'identityView' failed, see " + Parameters.getScreenshotErrorDirectory() + " for error images", testBench().compareScreen("identityView")); } - + /** * Generates a reference screenshot if no reference exists. *

@@ -82,8 +80,7 @@ public class ScreenshotIT extends AbstractIT { * perform this task manually after verifying that the screenshots look * correct. * - * @param referenceId - * the id of the reference image + * @param referenceId the id of the reference image * @throws IOException */ private void generateReferenceIfNotFound(String referenceId) diff --git a/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java b/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java index 8aa13b3..c0df7e1 100644 --- a/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java +++ b/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java @@ -11,15 +11,15 @@ public class InputBarElement extends HorizontalLayoutElement { public void typeInfer() { $(ButtonElement.class).id("inferButton").click(); } - + public void setCurrentValue(String value) { $(TextFieldElement.class).id("inputField").setValue(value); } - + public String getCurrentValue() { return $(TextFieldElement.class).id("inputField").getValue(); } - + public void openExampleDialog() { $(ButtonElement.class).id("exampleButton").click(); } From 28aee51c7f0fd888b5d93d58dc36cf85a6e2938f Mon Sep 17 00:00:00 2001 From: ucrhh Date: Fri, 19 Feb 2021 23:21:24 +0100 Subject: [PATCH 2/2] fix pipeline --- src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java b/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java index fd6c290..31850a8 100644 --- a/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java +++ b/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java @@ -27,7 +27,8 @@ public class TypeInferenceResult { * @param substitutions the substitutions to generate the mgu and the final type * @param typeVar the type variable belonging to the original lambda term * @throws IllegalStateException if the given list of substitutions contains two substitutions for the same - * type variable; or if the calculated mgu contains no substitution for the given type variable + * type variable; or if the calculated mgu contains no substitution for the given + * type variable */ protected TypeInferenceResult(List substitutions, TypeVariable typeVar) { mgu = new ArrayList<>(substitutions);