Skip to content

Commit

Permalink
Feedback from github
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed Nov 28, 2016
1 parent 93fcc9c commit e394062
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 145 deletions.
Expand Up @@ -50,8 +50,8 @@ public final class ConstructorDeclaration extends BodyDeclaration<ConstructorDec
NodeWithDeclaration, NodeWithDeclaration,
NodeWithSimpleName<ConstructorDeclaration>, NodeWithSimpleName<ConstructorDeclaration>,
NodeWithModifiers<ConstructorDeclaration>, NodeWithModifiers<ConstructorDeclaration>,
NodeWithParameters<ConstructorDeclaration>, NodeWithParameters<ConstructorDeclaration>,
NodeWithThrowable<ConstructorDeclaration>, NodeWithThrownExceptions<ConstructorDeclaration>,
NodeWithBlockStmt<ConstructorDeclaration>, NodeWithBlockStmt<ConstructorDeclaration>,
NodeWithTypeParameters<ConstructorDeclaration> { NodeWithTypeParameters<ConstructorDeclaration> {


Expand All @@ -63,7 +63,7 @@ public final class ConstructorDeclaration extends BodyDeclaration<ConstructorDec


private NodeList<Parameter> parameters; private NodeList<Parameter> parameters;


private NodeList<ReferenceType<?>> thrownTypes; private NodeList<ReferenceType<?>> thrownExceptions;


private BlockStmt body; private BlockStmt body;


Expand Down Expand Up @@ -91,27 +91,27 @@ public ConstructorDeclaration(EnumSet<Modifier> modifiers, String name) {


public ConstructorDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, public ConstructorDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations,
NodeList<TypeParameter> typeParameters, NodeList<TypeParameter> typeParameters,
SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType<?>> thrownTypes, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType<?>> thrownExceptions,
BlockStmt block) { BlockStmt block) {
this(null, this(null,
modifiers, modifiers,
annotations, annotations,
typeParameters, typeParameters,
name, name,
parameters, parameters,
thrownTypes, thrownExceptions,
block); block);
} }


public ConstructorDeclaration(Range range, EnumSet<Modifier> modifiers, public ConstructorDeclaration(Range range, EnumSet<Modifier> modifiers,
NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name,
NodeList<Parameter> parameters, NodeList<ReferenceType<?>> thrownTypes, BlockStmt block) { NodeList<Parameter> parameters, NodeList<ReferenceType<?>> thrownExceptions, BlockStmt block) {
super(range, annotations); super(range, annotations);
setModifiers(modifiers); setModifiers(modifiers);
setTypeParameters(typeParameters); setTypeParameters(typeParameters);
setName(name); setName(name);
setParameters(parameters); setParameters(parameters);
setThrownTypes(thrownTypes); setThrownExceptions(thrownExceptions);
setBody(block); setBody(block);
} }


Expand Down Expand Up @@ -147,8 +147,8 @@ public NodeList<Parameter> getParameters() {
} }


@Override @Override
public NodeList<ReferenceType<?>> getThrownTypes() { public NodeList<ReferenceType<?>> getThrownExceptions() {
return thrownTypes; return thrownExceptions;
} }


public NodeList<TypeParameter> getTypeParameters() { public NodeList<TypeParameter> getTypeParameters() {
Expand Down Expand Up @@ -178,10 +178,10 @@ public ConstructorDeclaration setParameters(NodeList<Parameter> parameters) {
} }


@Override @Override
public ConstructorDeclaration setThrownTypes(NodeList<ReferenceType<?>> thrownTypes) { public ConstructorDeclaration setThrownExceptions(NodeList<ReferenceType<?>> thrownExceptions) {
notifyPropertyChange(ObservableProperty.THROWN_TYPES, this.thrownTypes, thrownTypes); notifyPropertyChange(ObservableProperty.THROWN_TYPES, this.thrownExceptions, thrownExceptions);
this.thrownTypes = assertNotNull(thrownTypes); this.thrownExceptions = assertNotNull(thrownExceptions);
setAsParentNodeOf(this.thrownTypes); setAsParentNodeOf(this.thrownExceptions);
return this; return this;
} }


Expand Down Expand Up @@ -225,7 +225,7 @@ public String getDeclarationAsString(boolean includingModifiers, boolean includi
sb.append(")"); sb.append(")");
if (includingThrows) { if (includingThrows) {
boolean firstThrow = true; boolean firstThrow = true;
for (ReferenceType thr : getThrownTypes()) { for (ReferenceType thr : getThrownExceptions()) {
if (firstThrow) { if (firstThrow) {
firstThrow = false; firstThrow = false;
sb.append(" throws "); sb.append(" throws ");
Expand Down Expand Up @@ -273,7 +273,7 @@ public List<NodeList<?>> getNodeLists() {
List<NodeList<?>> res = new LinkedList<>(super.getNodeLists()); List<NodeList<?>> res = new LinkedList<>(super.getNodeLists());
res.add(typeParameters); res.add(typeParameters);
res.add(parameters); res.add(parameters);
res.add(thrownTypes); res.add(thrownExceptions);
return res; return res;
} }
} }
Expand Up @@ -60,7 +60,7 @@ public final class MethodDeclaration extends BodyDeclaration<MethodDeclaration>
NodeWithElementType<MethodDeclaration>, NodeWithElementType<MethodDeclaration>,
NodeWithModifiers<MethodDeclaration>, NodeWithModifiers<MethodDeclaration>,
NodeWithParameters<MethodDeclaration>, NodeWithParameters<MethodDeclaration>,
NodeWithThrowable<MethodDeclaration>, NodeWithThrownExceptions<MethodDeclaration>,
NodeWithOptionalBlockStmt<MethodDeclaration>, NodeWithOptionalBlockStmt<MethodDeclaration>,
NodeWithTypeParameters<MethodDeclaration> { NodeWithTypeParameters<MethodDeclaration> {


Expand All @@ -74,7 +74,7 @@ public final class MethodDeclaration extends BodyDeclaration<MethodDeclaration>


private NodeList<Parameter> parameters; private NodeList<Parameter> parameters;


private NodeList<ReferenceType<?>> thrownTypes; private NodeList<ReferenceType<?>> thrownExceptions;


private BlockStmt body; private BlockStmt body;


Expand Down Expand Up @@ -139,7 +139,7 @@ public MethodDeclaration(final EnumSet<Modifier> modifiers,
final boolean isDefault, final boolean isDefault,
final NodeList<Parameter> parameters, final NodeList<Parameter> parameters,
final NodeList<ArrayBracketPair> arrayBracketPairsAfterParameterList, final NodeList<ArrayBracketPair> arrayBracketPairsAfterParameterList,
final NodeList<ReferenceType<?>> thrownTypes, final NodeList<ReferenceType<?>> thrownExceptions,
final BlockStmt body) { final BlockStmt body) {
this(null, this(null,
modifiers, modifiers,
Expand All @@ -151,7 +151,7 @@ public MethodDeclaration(final EnumSet<Modifier> modifiers,
isDefault, isDefault,
parameters, parameters,
arrayBracketPairsAfterParameterList, arrayBracketPairsAfterParameterList,
thrownTypes, thrownExceptions,
body); body);
} }


Expand All @@ -165,7 +165,7 @@ public MethodDeclaration(Range range,
final boolean isDefault, final boolean isDefault,
final NodeList<Parameter> parameters, final NodeList<Parameter> parameters,
final NodeList<ArrayBracketPair> arrayBracketPairsAfterParameterList, final NodeList<ArrayBracketPair> arrayBracketPairsAfterParameterList,
final NodeList<ReferenceType<?>> thrownTypes, final NodeList<ReferenceType<?>> thrownExceptions,
final BlockStmt body) { final BlockStmt body) {
super(range, annotations); super(range, annotations);
setModifiers(modifiers); setModifiers(modifiers);
Expand All @@ -175,7 +175,7 @@ public MethodDeclaration(Range range,
setParameters(parameters); setParameters(parameters);
setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType); setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType);
setArrayBracketPairsAfterParameterList(arrayBracketPairsAfterParameterList); setArrayBracketPairsAfterParameterList(arrayBracketPairsAfterParameterList);
setThrownTypes(thrownTypes); setThrownExceptions(thrownExceptions);
setBody(body); setBody(body);
setDefault(isDefault); setDefault(isDefault);
} }
Expand Down Expand Up @@ -217,8 +217,8 @@ public NodeList<Parameter> getParameters() {
} }


@Override @Override
public NodeList<ReferenceType<?>> getThrownTypes() { public NodeList<ReferenceType<?>> getThrownExceptions() {
return thrownTypes; return thrownExceptions;
} }


@Override @Override
Expand Down Expand Up @@ -276,10 +276,10 @@ public MethodDeclaration setParameters(final NodeList<Parameter> parameters) {
} }


@Override @Override
public MethodDeclaration setThrownTypes(final NodeList<ReferenceType<?>> thrownTypes) { public MethodDeclaration setThrownExceptions(final NodeList<ReferenceType<?>> thrownExceptions) {
notifyPropertyChange(ObservableProperty.THROWN_TYPES, this.thrownTypes, thrownTypes); notifyPropertyChange(ObservableProperty.THROWN_TYPES, this.thrownExceptions, thrownExceptions);
this.thrownTypes = assertNotNull(thrownTypes); this.thrownExceptions = assertNotNull(thrownExceptions);
setAsParentNodeOf(this.thrownTypes); setAsParentNodeOf(this.thrownExceptions);
return this; return this;
} }


Expand Down Expand Up @@ -384,7 +384,7 @@ public String getDeclarationAsString(boolean includingModifiers, boolean includi
sb.append(")"); sb.append(")");
if (includingThrows) { if (includingThrows) {
boolean firstThrow = true; boolean firstThrow = true;
for (ReferenceType<?> thr : getThrownTypes()) { for (ReferenceType<?> thr : getThrownExceptions()) {
if (firstThrow) { if (firstThrow) {
firstThrow = false; firstThrow = false;
sb.append(" throws "); sb.append(" throws ");
Expand Down Expand Up @@ -438,7 +438,7 @@ public List<NodeList<?>> getNodeLists() {
List<NodeList<?>> res = new LinkedList<>(super.getNodeLists()); List<NodeList<?>> res = new LinkedList<>(super.getNodeLists());
res.add(typeParameters); res.add(typeParameters);
res.add(parameters); res.add(parameters);
res.add(thrownTypes); res.add(thrownExceptions);
res.add(arrayBracketPairsAfterType); res.add(arrayBracketPairsAfterType);
res.add(arrayBracketPairsAfterParameterList); res.add(arrayBracketPairsAfterParameterList);
return res; return res;
Expand Down
Expand Up @@ -177,7 +177,7 @@ public NodeList<AnnotationExpr> getAnnotations() {
public VariableDeclaratorId getIdentifier() { public VariableDeclaratorId getIdentifier() {
return identifier; return identifier;
} }

@Override @Override
public SimpleName getName() { public SimpleName getName() {
return getIdentifier().getName(); return getIdentifier().getName();
Expand Down
Expand Up @@ -41,20 +41,20 @@ public final class CastExpr extends Expression implements


private Type<?> type; private Type<?> type;


private Expression expr; private Expression expression;


public CastExpr() { public CastExpr() {
this(null, new ClassOrInterfaceType(), new NameExpr()); this(null, new ClassOrInterfaceType(), new NameExpr());
} }


public CastExpr(Type<?> type, Expression expr) { public CastExpr(Type<?> type, Expression expression) {
this(null, type, expr); this(null, type, expression);
} }


public CastExpr(Range range, Type<?> type, Expression expr) { public CastExpr(Range range, Type<?> type, Expression expression) {
super(range); super(range);
setType(type); setType(type);
setExpression(expr); setExpression(expression);
} }


@Override @Override
Expand All @@ -69,7 +69,7 @@ public <A> void accept(VoidVisitor<A> v, A arg) {


@Override @Override
public Expression getExpression() { public Expression getExpression() {
return expr; return expression;
} }


@Override @Override
Expand All @@ -79,9 +79,9 @@ public Type<?> getType() {


@Override @Override
public CastExpr setExpression(Expression expr) { public CastExpr setExpression(Expression expr) {
notifyPropertyChange(ObservableProperty.EXPRESSION, this.expr, expr); notifyPropertyChange(ObservableProperty.EXPRESSION, this.expression, expr);
this.expr = assertNotNull(expr); this.expression = assertNotNull(expr);
setAsParentNodeOf(this.expr); setAsParentNodeOf(this.expression);
return this; return this;
} }


Expand Down
@@ -1,64 +1,64 @@
package com.github.javaparser.ast.nodeTypes; package com.github.javaparser.ast.nodeTypes;


import com.github.javaparser.ast.Node; import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.type.ClassOrInterfaceType; import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.type.ReferenceType; import com.github.javaparser.ast.type.ReferenceType;


public interface NodeWithThrowable<N extends Node> { public interface NodeWithThrownExceptions<N extends Node> {
N setThrownTypes(NodeList<ReferenceType<?>> thrownTypes); N setThrownExceptions(NodeList<ReferenceType<?>> thrownExceptions);


NodeList<ReferenceType<?>> getThrownTypes(); NodeList<ReferenceType<?>> getThrownExceptions();


default ReferenceType getThrownType(int i) { default ReferenceType getThrownException(int i) {
return getThrownTypes().get(i); return getThrownExceptions().get(i);
} }


/** /**
* Adds this type to the throws clause * Adds this type to the throws clause
* *
* @param throwType the exception type * @param throwType the exception type
* @return this * @return this
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default N addThrownType(ReferenceType<?> throwType) { default N addThrownException(ReferenceType<?> throwType) {
getThrownTypes().add(throwType); getThrownExceptions().add(throwType);
throwType.setParentNode((Node) this); throwType.setParentNode((Node) this);
return (N) this; return (N) this;
} }


/** /**
* Adds this class to the throws clause * Adds this class to the throws clause
* *
* @param clazz the exception class * @param clazz the exception class
* @return this * @return this
*/ */
default N addThrownType(Class<? extends Throwable> clazz) { default N addThrownException(Class<? extends Throwable> clazz) {
((Node) this).tryAddImportToParentCompilationUnit(clazz); ((Node) this).tryAddImportToParentCompilationUnit(clazz);
return addThrownType(new ClassOrInterfaceType(clazz.getSimpleName())); return addThrownException(new ClassOrInterfaceType(clazz.getSimpleName()));
} }


/** /**
* Check whether this elements throws this exception class. * Check whether this elements throws this exception class.
* Note that this is simply a text compare of the simple name of the class, * Note that this is simply a text compare of the simple name of the class,
* no actual type resolution takes place. * no actual type resolution takes place.
* *
* @param clazz the class of the exception * @param clazz the class of the exception
* @return true if found in throws clause, false if not * @return true if found in throws clause, false if not
*/ */
default boolean isThrown(Class<? extends Throwable> clazz) { default boolean isThrown(Class<? extends Throwable> clazz) {
return isThrown(clazz.getSimpleName()); return isThrown(clazz.getSimpleName());
} }


/** /**
* Check whether this elements throws this exception class * Check whether this elements throws this exception class
* Note that this is simply a text compare, * Note that this is simply a text compare,
* no actual type resolution takes place. * no actual type resolution takes place.
* *
* @param throwableName the class of the exception * @param throwableName the class of the exception
* @return true if found in throws clause, false if not * @return true if found in throws clause, false if not
*/ */
default boolean isThrown(String throwableName) { default boolean isThrown(String throwableName) {
return getThrownTypes().stream().anyMatch(t -> t.toString().equals(throwableName)); return getThrownExceptions().stream().anyMatch(t -> t.toString().equals(throwableName));
} }
} }

0 comments on commit e394062

Please sign in to comment.