Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(role): CtThrows uses EXPRESSION now. Rolls back usage of THROWN #1624

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/spoon/reflect/code/CtThrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import spoon.reflect.annotations.PropertySetter;
import spoon.template.TemplateParameter;

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

/**
* This code element defines a <code>throw</code> statement.
Expand All @@ -35,13 +35,13 @@ public interface CtThrow extends CtCFlowBreak, TemplateParameter<Void> {
/**
* Returns the thrown expression (must be a throwable).
*/
@PropertyGetter(role = THROWN)
@PropertyGetter(role = EXPRESSION)
CtExpression<? extends Throwable> getThrownExpression();

/**
* Sets the thrown expression (must be a throwable).
*/
@PropertySetter(role = THROWN)
@PropertySetter(role = EXPRESSION)
<T extends CtThrow> T setThrownExpression(CtExpression<? extends Throwable> thrownExpression);

@Override
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/spoon/reflect/declaration/CtExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.Set;

import static spoon.reflect.path.CtRole.PARAMETER;
import static spoon.reflect.path.CtRole.THROWN_TYPE;
import static spoon.reflect.path.CtRole.THROWN;

/**
* This element represents an executable element such as a method, a
Expand Down Expand Up @@ -88,13 +88,13 @@ public interface CtExecutable<R> extends CtNamedElement, CtTypedElement<R>, CtBo
* Returns the exceptions and other throwables listed in this method or
* constructor's <tt>throws</tt> clause.
*/
@PropertyGetter(role = THROWN_TYPE)
@PropertyGetter(role = THROWN)
Set<CtTypeReference<? extends Throwable>> getThrownTypes();

/**
* Sets the thrown types.
*/
@PropertySetter(role = THROWN_TYPE)
@PropertySetter(role = THROWN)
<T extends CtExecutable<R>> T setThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes);

/**
Expand All @@ -103,7 +103,7 @@ public interface CtExecutable<R> extends CtNamedElement, CtTypedElement<R>, CtBo
* @param throwType
* @return <tt>true</tt> if this element changed as a result of the call
*/
@PropertySetter(role = THROWN_TYPE)
@PropertySetter(role = THROWN)
<T extends CtExecutable<R>> T addThrownType(CtTypeReference<? extends Throwable> throwType);

/**
Expand All @@ -112,7 +112,7 @@ public interface CtExecutable<R> extends CtNamedElement, CtTypedElement<R>, CtBo
* @param throwType
* @return <tt>true</tt> if this element changed as a result of the call
*/
@PropertySetter(role = THROWN_TYPE)
@PropertySetter(role = THROWN)
boolean removeThrownType(CtTypeReference<? extends Throwable> throwType);

/**
Expand Down
1 change: 0 additions & 1 deletion src/main/java/spoon/reflect/path/CtRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public enum CtRole {
VARIABLE,
FINALIZER,
THROWN,
THROWN_TYPE,
ASSIGNMENT,
ASSIGNED,
MODIFIER,
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/spoon/support/reflect/code/CtLambdaImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static spoon.reflect.path.CtRole.EXPRESSION;
import static spoon.reflect.path.CtRole.NAME;
import static spoon.reflect.path.CtRole.PARAMETER;
import static spoon.reflect.path.CtRole.THROWN_TYPE;
import static spoon.reflect.path.CtRole.THROWN;

public class CtLambdaImpl<T> extends CtExpressionImpl<T> implements CtLambda<T> {
@MetamodelPropertyField(role = CtRole.NAME)
Expand All @@ -58,7 +58,7 @@ public class CtLambdaImpl<T> extends CtExpressionImpl<T> implements CtLambda<T>
CtBlock<?> body;
@MetamodelPropertyField(role = CtRole.PARAMETER)
List<CtParameter<?>> parameters = emptyList();
@MetamodelPropertyField(role = CtRole.THROWN_TYPE)
@MetamodelPropertyField(role = THROWN)
Set<CtTypeReference<? extends Throwable>> thrownTypes = emptySet();

@Override
Expand Down Expand Up @@ -198,7 +198,7 @@ public <C extends CtExecutable<T>> C setThrownTypes(Set<CtTypeReference<? extend
if (this.thrownTypes == CtElementImpl.<CtTypeReference<? extends Throwable>>emptySet()) {
this.thrownTypes = new QualifiedNameBasedSortedSet<>();
}
getFactory().getEnvironment().getModelChangeListener().onSetDeleteAll(this, THROWN_TYPE, this.thrownTypes, new HashSet<>(this.thrownTypes));
getFactory().getEnvironment().getModelChangeListener().onSetDeleteAll(this, THROWN, this.thrownTypes, new HashSet<>(this.thrownTypes));
this.thrownTypes.clear();
for (CtTypeReference<? extends Throwable> thrownType : thrownTypes) {
addThrownType(thrownType);
Expand All @@ -215,7 +215,7 @@ public <C extends CtExecutable<T>> C addThrownType(CtTypeReference<? extends Thr
thrownTypes = new QualifiedNameBasedSortedSet<>();
}
throwType.setParent(this);
getFactory().getEnvironment().getModelChangeListener().onSetAdd(this, THROWN_TYPE, this.thrownTypes, throwType);
getFactory().getEnvironment().getModelChangeListener().onSetAdd(this, THROWN, this.thrownTypes, throwType);
thrownTypes.add(throwType);
return (C) this;
}
Expand All @@ -225,7 +225,7 @@ public boolean removeThrownType(CtTypeReference<? extends Throwable> throwType)
if (thrownTypes == CtElementImpl.<CtTypeReference<? extends Throwable>>emptySet()) {
return false;
}
getFactory().getEnvironment().getModelChangeListener().onSetDelete(this, THROWN_TYPE, thrownTypes, throwType);
getFactory().getEnvironment().getModelChangeListener().onSetDelete(this, THROWN, thrownTypes, throwType);
return thrownTypes.remove(throwType);
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/spoon/support/reflect/code/CtThrowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtThrow;
import spoon.reflect.declaration.CtType;
import spoon.reflect.path.CtRole;
import spoon.reflect.visitor.CtVisitor;

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

public class CtThrowImpl extends CtStatementImpl implements CtThrow {
private static final long serialVersionUID = 1L;

@MetamodelPropertyField(role = CtRole.THROWN)
@MetamodelPropertyField(role = EXPRESSION)
CtExpression<? extends Throwable> throwExpression;

@Override
Expand All @@ -47,7 +46,7 @@ public <T extends CtThrow> T setThrownExpression(CtExpression<? extends Throwabl
if (expression != null) {
expression.setParent(this);
}
getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, THROWN, expression, this.throwExpression);
getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, EXPRESSION, expression, this.throwExpression);
this.throwExpression = expression;
return (T) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import static spoon.reflect.ModelElementContainerDefaultCapacities.PARAMETERS_CONTAINER_DEFAULT_CAPACITY;
import static spoon.reflect.path.CtRole.BODY;
import static spoon.reflect.path.CtRole.PARAMETER;
import static spoon.reflect.path.CtRole.THROWN_TYPE;
import static spoon.reflect.path.CtRole.THROWN;


/**
Expand All @@ -53,7 +53,7 @@ public abstract class CtExecutableImpl<R> extends CtNamedElementImpl implements
@MetamodelPropertyField(role = PARAMETER)
List<CtParameter<?>> parameters = emptyList();

@MetamodelPropertyField(role = THROWN_TYPE)
@MetamodelPropertyField(role = THROWN)
Set<CtTypeReference<? extends Throwable>> thrownTypes = emptySet();

public CtExecutableImpl() {
Expand Down Expand Up @@ -149,7 +149,7 @@ public <T extends CtExecutable<R>> T setThrownTypes(Set<CtTypeReference<? extend
if (this.thrownTypes == CtElementImpl.<CtTypeReference<? extends Throwable>>emptySet()) {
this.thrownTypes = new QualifiedNameBasedSortedSet<>();
}
getFactory().getEnvironment().getModelChangeListener().onSetDeleteAll(this, THROWN_TYPE, this.thrownTypes, new HashSet<Object>(this.thrownTypes));
getFactory().getEnvironment().getModelChangeListener().onSetDeleteAll(this, THROWN, this.thrownTypes, new HashSet<Object>(this.thrownTypes));
this.thrownTypes.clear();
for (CtTypeReference<? extends Throwable> thrownType : thrownTypes) {
addThrownType(thrownType);
Expand All @@ -166,7 +166,7 @@ public <T extends CtExecutable<R>> T addThrownType(CtTypeReference<? extends Thr
thrownTypes = new QualifiedNameBasedSortedSet<>();
}
throwType.setParent(this);
getFactory().getEnvironment().getModelChangeListener().onSetAdd(this, THROWN_TYPE, this.thrownTypes, throwType);
getFactory().getEnvironment().getModelChangeListener().onSetAdd(this, THROWN, this.thrownTypes, throwType);
thrownTypes.add(throwType);
return (T) this;
}
Expand All @@ -176,7 +176,7 @@ public boolean removeThrownType(CtTypeReference<? extends Throwable> throwType)
if (thrownTypes == CtElementImpl.<CtTypeReference<? extends Throwable>>emptySet()) {
return false;
}
getFactory().getEnvironment().getModelChangeListener().onSetDelete(this, THROWN_TYPE, thrownTypes, throwType);
getFactory().getEnvironment().getModelChangeListener().onSetDelete(this, THROWN, thrownTypes, throwType);
return thrownTypes.remove(throwType);
}

Expand Down