Skip to content

Commit

Permalink
Added method to provide the wrapped node of a JavaParserConstructorDe…
Browse files Browse the repository at this point in the history
…claration
  • Loading branch information
mlangkabel committed Mar 13, 2017
1 parent 320c07e commit e56a45a
Showing 1 changed file with 16 additions and 7 deletions.
Expand Up @@ -28,13 +28,13 @@
public class JavaParserConstructorDeclaration implements ConstructorDeclaration {

private ClassDeclaration classDeclaration;
private com.github.javaparser.ast.body.ConstructorDeclaration wrapped;
private com.github.javaparser.ast.body.ConstructorDeclaration wrappedNode;
private TypeSolver typeSolver;

public JavaParserConstructorDeclaration(ClassDeclaration classDeclaration, com.github.javaparser.ast.body.ConstructorDeclaration wrapped,
public JavaParserConstructorDeclaration(ClassDeclaration classDeclaration, com.github.javaparser.ast.body.ConstructorDeclaration wrappedNode,
TypeSolver typeSolver) {
this.classDeclaration = classDeclaration;
this.wrapped = wrapped;
this.wrappedNode = wrappedNode;
this.typeSolver = typeSolver;
}

Expand All @@ -45,29 +45,38 @@ public ClassDeclaration declaringType() {

@Override
public int getNumberOfParams() {
return this.wrapped.getParameters().size();
return this.wrappedNode.getParameters().size();
}

@Override
public ParameterDeclaration getParam(int i) {
if (i < 0 || i >= getNumberOfParams()) {
throw new IllegalArgumentException(String.format("No param with index %d. Number of params: %d", i, getNumberOfParams()));
}
return new JavaParserParameterDeclaration(wrapped.getParameters().get(i), typeSolver);
return new JavaParserParameterDeclaration(wrappedNode.getParameters().get(i), typeSolver);
}

@Override
public String getName() {
return this.classDeclaration.getName();
}

/**
* Returns the JavaParser node associated with this JavaParserConstructorDeclaration.
*
* @return A visitable JavaParser node wrapped by this object.
*/
public com.github.javaparser.ast.body.ConstructorDeclaration getWrappedNode() {
return wrappedNode;
}

@Override
public AccessLevel accessLevel() {
return Helper.toAccessLevel(wrapped.getModifiers());
return Helper.toAccessLevel(wrappedNode.getModifiers());
}

@Override
public List<TypeParameterDeclaration> getTypeParameters() {
return this.wrapped.getTypeParameters().stream().map((astTp) -> new JavaParserTypeParameter(astTp, typeSolver)).collect(Collectors.toList());
return this.wrappedNode.getTypeParameters().stream().map((astTp) -> new JavaParserTypeParameter(astTp, typeSolver)).collect(Collectors.toList());
}
}

0 comments on commit e56a45a

Please sign in to comment.