Skip to content

Commit

Permalink
refactor: return types of Spoon model methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pvojtechovsky committed Oct 8, 2018
1 parent 851840e commit 04a3e02
Show file tree
Hide file tree
Showing 212 changed files with 2,248 additions and 1,579 deletions.
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/code/BinaryOperatorKind.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package spoon.reflect.code;




/**
* This enumeration defines all the kinds of binary operators.
*/
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/spoon/reflect/code/CtAbstractInvocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@
*/
package spoon.reflect.code;

import spoon.reflect.declaration.CtElement;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import java.util.List;
import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.reference.CtExecutableReference;

import static spoon.reflect.path.CtRole.ARGUMENT;
import static spoon.reflect.path.CtRole.EXECUTABLE_REF;




/**
* This code element defines an abstract invocation on a
* {@link spoon.reflect.declaration.CtExecutable}.
Expand All @@ -46,7 +49,7 @@ public interface CtAbstractInvocation<T> extends CtElement {
* Adds an argument expression to the invocation.
*/
@PropertySetter(role = ARGUMENT)
<C extends CtAbstractInvocation<T>> C addArgument(CtExpression<?> argument);
CtAbstractInvocation<T> addArgument(CtExpression<?> argument);

/**
* Removes an argument expression from the invocation.
Expand All @@ -58,7 +61,7 @@ public interface CtAbstractInvocation<T> extends CtElement {
* Sets the invocation's arguments.
*/
@PropertySetter(role = ARGUMENT)
<C extends CtAbstractInvocation<T>> C setArguments(List<CtExpression<?>> arguments);
CtAbstractInvocation<T> setArguments(List<CtExpression<?>> arguments);

/**
* Returns the invoked executable.
Expand All @@ -70,5 +73,5 @@ public interface CtAbstractInvocation<T> extends CtElement {
* Sets the invoked executable.
*/
@PropertySetter(role = EXECUTABLE_REF)
<C extends CtAbstractInvocation<T>> C setExecutable(CtExecutableReference<T> executable);
CtAbstractInvocation<T> setExecutable(CtExecutableReference<T> executable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
*/
package spoon.reflect.code;

import spoon.reflect.reference.CtFieldReference;

import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.reference.CtFieldReference;

import static spoon.reflect.path.CtRole.VARIABLE;




/**
* This code element defines an access to a annotation parameter variable.
*
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/spoon/reflect/code/CtArrayAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
*/
package spoon.reflect.code;


import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.EXPRESSION;




/**
* This code element defines a one-dimensional array access. When
* multi-dimensional, array accesses are applied to other one-dimensional array
Expand All @@ -37,7 +41,7 @@ public interface CtArrayAccess<T, E extends CtExpression<?>> extends CtTargetedE
* Sets the expression that defines the index.
*/
@PropertySetter(role = EXPRESSION)
<C extends CtArrayAccess<T, E>> C setIndexExpression(CtExpression<Integer> expression);
CtArrayAccess<T, E> setIndexExpression(CtExpression<Integer> expression);

/**
* Returns the expression that defines the index.
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/code/CtArrayRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package spoon.reflect.code;




/**
* This code element defines a read access to an array.
*
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/code/CtArrayWrite.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package spoon.reflect.code;




/**
* This code element defines a write access to an array.
*
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/spoon/reflect/code/CtAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
*/
package spoon.reflect.code;


import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.CONDITION;
import static spoon.reflect.path.CtRole.EXPRESSION;





/**
* This code element defines an assert clause.
* Example: <pre>assert 1+1==2</pre>
Expand All @@ -38,7 +42,7 @@ public interface CtAssert<T> extends CtStatement {
* Sets the assert expression.
*/
@PropertySetter(role = CONDITION)
<A extends CtAssert<T>> A setAssertExpression(CtExpression<Boolean> asserted);
CtAssert<T> setAssertExpression(CtExpression<Boolean> asserted);

/**
* Gets the expression of the assertion if defined.
Expand All @@ -50,7 +54,7 @@ public interface CtAssert<T> extends CtStatement {
* Sets the expression of the assertion.
*/
@PropertySetter(role = EXPRESSION)
<A extends CtAssert<T>> A setExpression(CtExpression<T> expression);
CtAssert<T> setExpression(CtExpression<T> expression);

@Override
CtAssert<T> clone();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/spoon/reflect/code/CtAssignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
*/
package spoon.reflect.code;


import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.ASSIGNED;





/**
* This code element defines an assignment.
*
Expand All @@ -47,7 +51,7 @@ public interface CtAssignment<T, A extends T> extends CtStatement, CtExpression<
* Sets the assigned expression (left hand side - LHS).
*/
@PropertySetter(role = ASSIGNED)
<C extends CtAssignment<T, A>> C setAssigned(CtExpression<T> assigned);
CtAssignment<T, A> setAssigned(CtExpression<T> assigned);

@Override
CtAssignment<T, A> clone();
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/spoon/reflect/code/CtBinaryOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
*/
package spoon.reflect.code;


import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.OPERATOR_KIND;
import static spoon.reflect.path.CtRole.LEFT_OPERAND;
import static spoon.reflect.path.CtRole.OPERATOR_KIND;
import static spoon.reflect.path.CtRole.RIGHT_OPERAND;




/**
* This interface defines a binary operator.
*
Expand Down Expand Up @@ -52,19 +56,19 @@ public interface CtBinaryOperator<T> extends CtExpression<T> {
* Sets the left-hand operand.
*/
@PropertySetter(role = LEFT_OPERAND)
<C extends CtBinaryOperator<T>> C setLeftHandOperand(CtExpression<?> expression);
CtBinaryOperator<T> setLeftHandOperand(CtExpression<?> expression);

/**
* Sets the right-hand operand.
*/
@PropertySetter(role = RIGHT_OPERAND)
<C extends CtBinaryOperator<T>> C setRightHandOperand(CtExpression<?> expression);
CtBinaryOperator<T> setRightHandOperand(CtExpression<?> expression);

/**
* Sets the kind of this binary operator.
*/
@PropertySetter(role = OPERATOR_KIND)
<C extends CtBinaryOperator<T>> C setKind(BinaryOperatorKind kind);
CtBinaryOperator<T> setKind(BinaryOperatorKind kind);

/**
* Gets the kind of this binary operator.
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/spoon/reflect/code/CtBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
*/
package spoon.reflect.code;


import spoon.template.TemplateParameter;




/**
* This code element represents a block of code, that is to say a list of
* statements enclosed in curly brackets.
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/spoon/reflect/code/CtBodyHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
*/
package spoon.reflect.code;

import spoon.reflect.declaration.CtElement;

import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;
import spoon.reflect.declaration.CtElement;

import static spoon.reflect.path.CtRole.BODY;




/**
* This abstract code element defines an element, which contains a body
*/
Expand All @@ -38,5 +42,5 @@ public interface CtBodyHolder extends CtElement {
* If body is not a block, it is wrapped in a CtBlock which is semantically equivalent and eases transformation afterwards if required.
*/
@PropertySetter(role = BODY)
<T extends CtBodyHolder> T setBody(CtStatement body);
CtBodyHolder setBody(CtStatement body);
}
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/code/CtBreak.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package spoon.reflect.code;




/**
* This code element defines a break statement.
* Example:
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/code/CtCFlowBreak.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package spoon.reflect.code;




/**
* This abstract code element represents all the statements that break the
* control flow of the program.
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/spoon/reflect/code/CtCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
*/
package spoon.reflect.code;


import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.EXPRESSION;




/**
* This code element defines a case within a switch-case.
*
Expand All @@ -46,7 +50,7 @@ public interface CtCase<S> extends CtStatement, CtStatementList {
* Sets the case expression.
*/
@PropertySetter(role = EXPRESSION)
<T extends CtCase<S>> T setCaseExpression(CtExpression<S> caseExpression);
CtCase<S> setCaseExpression(CtExpression<S> caseExpression);

@Override
CtCase<S> clone();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/spoon/reflect/code/CtCatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
*/
package spoon.reflect.code;


import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.BODY;
import static spoon.reflect.path.CtRole.PARAMETER;





/**
* This code element defines a <code>catch</code> of a <code>try</code>.
*
Expand All @@ -40,7 +44,7 @@ public interface CtCatch extends CtCodeElement, CtBodyHolder {
* Sets the catch's parameter (a throwable).
*/
@PropertySetter(role = PARAMETER)
<T extends CtCatch> T setParameter(CtCatchVariable<? extends Throwable> parameter);
CtCatch setParameter(CtCatchVariable<? extends Throwable> parameter);

/**
* Gets the catch's body.
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/spoon/reflect/code/CtCatchVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
*/
package spoon.reflect.code;


import spoon.reflect.declaration.CtMultiTypedElement;
import spoon.reflect.declaration.CtTypedElement;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;
import spoon.support.UnsettableProperty;




/**
* This code element defines an exception variable in a catch.
*
Expand All @@ -46,7 +49,7 @@ public interface CtCatchVariable<T> extends CtVariable<T>, CtMultiTypedElement,

@Override
@UnsettableProperty
<C extends CtVariable<T>> C setDefaultExpression(CtExpression<T> assignedExpression);
CtCatchVariable<T> setDefaultExpression(CtExpression<T> assignedExpression);

/**
* Returns type reference of the exception variable in a catch.
Expand All @@ -58,5 +61,5 @@ public interface CtCatchVariable<T> extends CtVariable<T>, CtMultiTypedElement,

@Override
@UnsettableProperty
<C extends CtTypedElement> C setType(CtTypeReference<T> type);
CtCatchVariable<T> setType(CtTypeReference<T> type);
}
4 changes: 4 additions & 0 deletions src/main/java/spoon/reflect/code/CtCodeElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
*/
package spoon.reflect.code;


import spoon.reflect.declaration.CtElement;




/**
* This interface is the root interface of the code elements.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/spoon/reflect/code/CtCodeSnippetExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
*/
package spoon.reflect.code;


import spoon.reflect.declaration.CtCodeSnippet;
import spoon.support.compiler.SnippetCompilationError;




/**
* This element is a code snippet that must represent an expression and can thus
* be inserted in the program's model as is. Code snippets should be avoided
Expand Down
Loading

0 comments on commit 04a3e02

Please sign in to comment.