Skip to content

Commit

Permalink
"typename" fits the purpose better than "classname" - it is also used…
Browse files Browse the repository at this point in the history
… in the JLS
  • Loading branch information
matozoid committed May 1, 2019
1 parent fe2b93b commit dbbd907
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 88 deletions.
Expand Up @@ -17,7 +17,7 @@ void justSuper() {
void singleScopeSuper() {
Expression expr = parseExpression("A.super");

Name className = expr.asSuperExpr().getClassName().get();
Name className = expr.asSuperExpr().getTypeName().get();

assertEquals("A", className.asString());
}
Expand All @@ -26,7 +26,7 @@ void singleScopeSuper() {
void multiScopeSuper() {
Expression expr = parseExpression("a.B.super");

Name className = expr.asSuperExpr().getClassName().get();
Name className = expr.asSuperExpr().getTypeName().get();

assertEquals("a.B", className.asString());
}
Expand Down
Expand Up @@ -18,7 +18,7 @@ void justThis() {
void singleScopeThis() {
Expression expr = parseExpression("A.this");

Name className = expr.asThisExpr().getClassName().get();
Name className = expr.asThisExpr().getTypeName().get();

assertEquals("A", className.asString());
}
Expand All @@ -27,7 +27,7 @@ void singleScopeThis() {
void multiScopeThis() {
Expression expr = parseExpression("a.B.this");

Name className = expr.asThisExpr().getClassName().get();
Name className = expr.asThisExpr().getTypeName().get();

assertEquals("a.B", className.asString());
}
Expand Down
Expand Up @@ -37,11 +37,9 @@
/**
* An occurrence of the "super" keyword. <br/>
* <code>World.super.greet()</code> is a MethodCallExpr of method name greet,
* and scope "World.super" which is a SuperExpr with classExpr "World". <br/>
* and scope "World.super" which is a SuperExpr with typeName "World". <br/>
* <code>super.name</code> is a FieldAccessExpr of field greet, and a SuperExpr as its scope.
* This SuperExpr has no classExpr.
* <br>If classExpr is a single identifier (a.this) then it is of type NameExpr.
* If classExpr has multiple identifiers (a.b.c.this) then it is of type FieldAccessExpr.
* This SuperExpr has no typeName.
*
* @author Julio Vilmar Gesser
* @see com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt
Expand All @@ -50,24 +48,24 @@
public class SuperExpr extends Expression {

@OptionalProperty
private Name className;
private Name typeName;

public SuperExpr() {
this(null, null);
}

@AllFieldsConstructor
public SuperExpr(final Name className) {
this(null, className);
public SuperExpr(final Name typeName) {
this(null, typeName);
}

/**
* This constructor is used by the parser and is considered private.
*/
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
public SuperExpr(TokenRange tokenRange, Name className) {
public SuperExpr(TokenRange tokenRange, Name typeName) {
super(tokenRange);
setClassName(className);
setTypeName(typeName);
customInitialization();
}

Expand All @@ -84,20 +82,20 @@ public <A> void accept(final VoidVisitor<A> v, final A arg) {
}

@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public Optional<Name> getClassName() {
return Optional.ofNullable(className);
public Optional<Name> getTypeName() {
return Optional.ofNullable(typeName);
}

@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public SuperExpr setClassName(final Name className) {
if (className == this.className) {
public SuperExpr setTypeName(final Name typeName) {
if (typeName == this.typeName) {
return (SuperExpr) this;
}
notifyPropertyChange(ObservableProperty.CLASS_NAME, this.className, className);
if (this.className != null)
this.className.setParentNode(null);
this.className = className;
setAsParentNodeOf(className);
notifyPropertyChange(ObservableProperty.CLASS_NAME, this.typeName, typeName);
if (this.typeName != null)
this.typeName.setParentNode(null);
this.typeName = typeName;
setAsParentNodeOf(typeName);
return this;
}

Expand All @@ -106,8 +104,8 @@ public SuperExpr setClassName(final Name className) {
public boolean remove(Node node) {
if (node == null)
return false;
if (className != null) {
if (node == className) {
if (typeName != null) {
if (node == typeName) {
removeClassName();
return true;
}
Expand Down Expand Up @@ -152,17 +150,17 @@ public Optional<SuperExpr> toSuperExpr() {

@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
public SuperExpr removeClassName() {
return setClassName((Name) null);
return setTypeName((Name) null);
}

@Override
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
public boolean replace(Node node, Node replacementNode) {
if (node == null)
return false;
if (className != null) {
if (node == className) {
setClassName((Name) replacementNode);
if (typeName != null) {
if (node == typeName) {
setTypeName((Name) replacementNode);
return true;
}
}
Expand Down
Expand Up @@ -39,11 +39,9 @@
/**
* An occurrence of the "this" keyword. <br/>
* <code>World.this.greet()</code> is a MethodCallExpr of method name greet,
* and scope "World.this" which is a ThisExpr with classExpr "World". <br/>
* and scope "World.this" which is a ThisExpr with typeName "World". <br/>
* <code>this.name</code> is a FieldAccessExpr of field greet, and a ThisExpr as its scope.
* This ThisExpr has no classExpr.
* <br>If classExpr is a single identifier (a.this) then it is of type NameExpr.
* If classExpr has multiple identifiers (a.b.c.this) then it is of type FieldAccessExpr.
* This ThisExpr has no typeName.
*
* @author Julio Vilmar Gesser
* @see com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt
Expand All @@ -52,24 +50,24 @@
public class ThisExpr extends Expression implements Resolvable<ResolvedTypeDeclaration> {

@OptionalProperty
private Name className;
private Name typeName;

public ThisExpr() {
this(null, null);
}

@AllFieldsConstructor
public ThisExpr(final Name className) {
this(null, className);
public ThisExpr(final Name typeName) {
this(null, typeName);
}

/**
* This constructor is used by the parser and is considered private.
*/
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
public ThisExpr(TokenRange tokenRange, Name className) {
public ThisExpr(TokenRange tokenRange, Name typeName) {
super(tokenRange);
setClassName(className);
setTypeName(typeName);
customInitialization();
}

Expand All @@ -86,20 +84,20 @@ public <A> void accept(final VoidVisitor<A> v, final A arg) {
}

@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public Optional<Name> getClassName() {
return Optional.ofNullable(className);
public Optional<Name> getTypeName() {
return Optional.ofNullable(typeName);
}

@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public ThisExpr setClassName(final Name className) {
if (className == this.className) {
public ThisExpr setTypeName(final Name typeName) {
if (typeName == this.typeName) {
return (ThisExpr) this;
}
notifyPropertyChange(ObservableProperty.CLASS_NAME, this.className, className);
if (this.className != null)
this.className.setParentNode(null);
this.className = className;
setAsParentNodeOf(className);
notifyPropertyChange(ObservableProperty.CLASS_NAME, this.typeName, typeName);
if (this.typeName != null)
this.typeName.setParentNode(null);
this.typeName = typeName;
setAsParentNodeOf(typeName);
return this;
}

Expand All @@ -108,8 +106,8 @@ public ThisExpr setClassName(final Name className) {
public boolean remove(Node node) {
if (node == null)
return false;
if (className != null) {
if (node == className) {
if (typeName != null) {
if (node == typeName) {
removeClassName();
return true;
}
Expand All @@ -119,7 +117,7 @@ public boolean remove(Node node) {

@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
public ThisExpr removeClassName() {
return setClassName((Name) null);
return setTypeName((Name) null);
}

@Override
Expand All @@ -139,9 +137,9 @@ public ThisExprMetaModel getMetaModel() {
public boolean replace(Node node, Node replacementNode) {
if (node == null)
return false;
if (className != null) {
if (node == className) {
setClassName((Name) replacementNode);
if (typeName != null) {
if (node == typeName) {
setTypeName((Name) replacementNode);
return true;
}
}
Expand Down
Expand Up @@ -598,7 +598,7 @@ public Visitable visit(final SimpleName n, final Object arg) {

@Override
public Visitable visit(final ThisExpr n, final Object arg) {
Name className = cloneNode(n.getClassName(), arg);
Name className = cloneNode(n.getTypeName(), arg);
Comment comment = cloneNode(n.getComment(), arg);
ThisExpr r = new ThisExpr(n.getTokenRange().orElse(null), className);
r.setComment(comment);
Expand All @@ -608,7 +608,7 @@ public Visitable visit(final ThisExpr n, final Object arg) {

@Override
public Visitable visit(final SuperExpr n, final Object arg) {
Name className = cloneNode(n.getClassName(), arg);
Name className = cloneNode(n.getTypeName(), arg);
Comment comment = cloneNode(n.getComment(), arg);
SuperExpr r = new SuperExpr(n.getTokenRange().orElse(null), className);
r.setComment(comment);
Expand Down
Expand Up @@ -792,7 +792,7 @@ public Boolean visit(final SimpleName n, final Visitable arg) {
@Override
public Boolean visit(final ThisExpr n, final Visitable arg) {
final ThisExpr n2 = (ThisExpr) arg;
if (!nodeEquals(n.getClassName(), n2.getClassName()))
if (!nodeEquals(n.getTypeName(), n2.getTypeName()))
return false;
if (!nodeEquals(n.getComment(), n2.getComment()))
return false;
Expand All @@ -802,7 +802,7 @@ public Boolean visit(final ThisExpr n, final Visitable arg) {
@Override
public Boolean visit(final SuperExpr n, final Visitable arg) {
final SuperExpr n2 = (SuperExpr) arg;
if (!nodeEquals(n.getClassName(), n2.getClassName()))
if (!nodeEquals(n.getTypeName(), n2.getTypeName()))
return false;
if (!nodeEquals(n.getComment(), n2.getComment()))
return false;
Expand Down
Expand Up @@ -1471,8 +1471,8 @@ public List<R> visit(final StringLiteralExpr n, final A arg) {
public List<R> visit(final SuperExpr n, final A arg) {
List<R> result = new ArrayList<>();
List<R> tmp;
if (n.getClassName().isPresent()) {
tmp = n.getClassName().get().accept(this, arg);
if (n.getTypeName().isPresent()) {
tmp = n.getTypeName().get().accept(this, arg);
if (tmp != null)
result.addAll(tmp);
}
Expand Down Expand Up @@ -1550,8 +1550,8 @@ public List<R> visit(final SynchronizedStmt n, final A arg) {
public List<R> visit(final ThisExpr n, final A arg) {
List<R> result = new ArrayList<>();
List<R> tmp;
if (n.getClassName().isPresent()) {
tmp = n.getClassName().get().accept(this, arg);
if (n.getTypeName().isPresent()) {
tmp = n.getTypeName().get().accept(this, arg);
if (tmp != null)
result.addAll(tmp);
}
Expand Down
Expand Up @@ -1392,8 +1392,8 @@ public R visit(final StringLiteralExpr n, final A arg) {
@Override
public R visit(final SuperExpr n, final A arg) {
R result;
if (n.getClassName().isPresent()) {
result = n.getClassName().get().accept(this, arg);
if (n.getTypeName().isPresent()) {
result = n.getTypeName().get().accept(this, arg);
if (result != null)
return result;
}
Expand Down Expand Up @@ -1471,8 +1471,8 @@ public R visit(final SynchronizedStmt n, final A arg) {
@Override
public R visit(final ThisExpr n, final A arg) {
R result;
if (n.getClassName().isPresent()) {
result = n.getClassName().get().accept(this, arg);
if (n.getTypeName().isPresent()) {
result = n.getTypeName().get().accept(this, arg);
if (result != null)
return result;
}
Expand Down
Expand Up @@ -315,7 +315,7 @@ public Integer visit(final StringLiteralExpr n, final Void arg) {
}

public Integer visit(final SuperExpr n, final Void arg) {
return (n.getClassName().isPresent() ? n.getClassName().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0);
return (n.getTypeName().isPresent() ? n.getTypeName().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0);
}

public Integer visit(final SwitchEntry n, final Void arg) {
Expand All @@ -331,7 +331,7 @@ public Integer visit(final SynchronizedStmt n, final Void arg) {
}

public Integer visit(final ThisExpr n, final Void arg) {
return (n.getClassName().isPresent() ? n.getClassName().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0);
return (n.getTypeName().isPresent() ? n.getTypeName().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0);
}

public Integer visit(final ThrowStmt n, final Void arg) {
Expand Down
Expand Up @@ -830,9 +830,9 @@ public Visitable visit(final StringLiteralExpr n, final A arg) {

@Override
public Visitable visit(final SuperExpr n, final A arg) {
Name className = n.getClassName().map(s -> (Name) s.accept(this, arg)).orElse(null);
Name className = n.getTypeName().map(s -> (Name) s.accept(this, arg)).orElse(null);
Comment comment = n.getComment().map(s -> (Comment) s.accept(this, arg)).orElse(null);
n.setClassName(className);
n.setTypeName(className);
n.setComment(comment);
return n;
}
Expand Down Expand Up @@ -876,9 +876,9 @@ public Visitable visit(final SynchronizedStmt n, final A arg) {

@Override
public Visitable visit(final ThisExpr n, final A arg) {
Name className = n.getClassName().map(s -> (Name) s.accept(this, arg)).orElse(null);
Name className = n.getTypeName().map(s -> (Name) s.accept(this, arg)).orElse(null);
Comment comment = n.getComment().map(s -> (Comment) s.accept(this, arg)).orElse(null);
n.setClassName(className);
n.setTypeName(className);
n.setComment(comment);
return n;
}
Expand Down
Expand Up @@ -643,15 +643,15 @@ public Boolean visit(final SimpleName n, final Visitable arg) {
@Override
public Boolean visit(final ThisExpr n, final Visitable arg) {
final ThisExpr n2 = (ThisExpr) arg;
if (!nodeEquals(n.getClassName(), n2.getClassName()))
if (!nodeEquals(n.getTypeName(), n2.getTypeName()))
return false;
return true;
}

@Override
public Boolean visit(final SuperExpr n, final Visitable arg) {
final SuperExpr n2 = (SuperExpr) arg;
if (!nodeEquals(n.getClassName(), n2.getClassName()))
if (!nodeEquals(n.getTypeName(), n2.getTypeName()))
return false;
return true;
}
Expand Down

0 comments on commit dbbd907

Please sign in to comment.