Skip to content

Commit

Permalink
More or less done with naming
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed Nov 29, 2016
1 parent 1f77123 commit ded70c8
Show file tree
Hide file tree
Showing 37 changed files with 269 additions and 273 deletions.
Expand Up @@ -41,7 +41,7 @@ public enum AccessSpecifier {
this.codeRepresenation = codeRepresentation;
}

public String getCodeRepresenation(){
public String asString(){
return this.codeRepresenation;
}
}
Expand Up @@ -15,7 +15,9 @@
/**
* In, for example, <code>int[] a[];</code> there are two ArrayBracketPair objects,
* one for the [] after int, one for the [] after a.
* @deprecated will be removed in 3.0
*/
@Deprecated
public class ArrayBracketPair extends Node implements NodeWithAnnotations<ArrayBracketPair> {
private NodeList<AnnotationExpr> annotations = new NodeList<>();

Expand Down
Expand Up @@ -60,7 +60,7 @@
*/
public final class CompilationUnit extends Node {

private PackageDeclaration pakage;
private PackageDeclaration packageDeclaration;

private NodeList<ImportDeclaration> imports;

Expand All @@ -70,14 +70,14 @@ public CompilationUnit() {
this(null, null, new NodeList<>(), new NodeList<>());
}

public CompilationUnit(PackageDeclaration pakage, NodeList<ImportDeclaration> imports, NodeList<TypeDeclaration<?>> types) {
this(null, pakage, imports, types);
public CompilationUnit(PackageDeclaration packageDeclaration, NodeList<ImportDeclaration> imports, NodeList<TypeDeclaration<?>> types) {
this(null, packageDeclaration, imports, types);
}

public CompilationUnit(Range range, PackageDeclaration pakage, NodeList<ImportDeclaration> imports,
public CompilationUnit(Range range, PackageDeclaration packageDeclaration, NodeList<ImportDeclaration> imports,
NodeList<TypeDeclaration<?>> types) {
super(range);
setPackage(pakage);
setPackage(packageDeclaration);
setImports(imports);
setTypes(types);
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public ImportDeclaration getImport(int i) {
* @return the package declaration or <code>null</code>
*/
public Optional<PackageDeclaration> getPackage() {
return Optional.ofNullable(pakage);
return Optional.ofNullable(packageDeclaration);
}

/**
Expand Down Expand Up @@ -174,13 +174,13 @@ public CompilationUnit setImports(NodeList<ImportDeclaration> imports) {
* Sets or clear the package declarations of this compilation unit.
*
* @param pakage
* the pakage declaration to set or <code>null</code> to default
* the packageDeclaration declaration to set or <code>null</code> to default
* package
*/
public CompilationUnit setPackage(PackageDeclaration pakage) {
notifyPropertyChange(ObservableProperty.PACKAGE, this.pakage, pakage);
this.pakage = pakage;
setAsParentNodeOf(this.pakage);
notifyPropertyChange(ObservableProperty.PACKAGE_DECLARATION, this.packageDeclaration, pakage);
this.packageDeclaration = pakage;
setAsParentNodeOf(this.packageDeclaration);
return this;
}

Expand Down
Expand Up @@ -15,17 +15,17 @@ public enum Modifier {
NATIVE,
STRICTFP;

String asString;
final String codeRepresentation;

Modifier() {
this.asString = name().toLowerCase();
this.codeRepresentation = name().toLowerCase();
}

/**
* @return the keyword represented by this modifier.
*/
public String asString() {
return asString;
return codeRepresentation;
}

public EnumSet<Modifier> toEnumSet() {
Expand Down
Expand Up @@ -101,7 +101,7 @@ public enum ObserverRegistrationMode {

private Node parentNode;

private List<Node> childrenNodes = new LinkedList<>();
private List<Node> childNodes = new LinkedList<>();
private List<Comment> orphanComments = new LinkedList<>();

private IdentityHashMap<DataKey<?>, Object> data = null;
Expand Down Expand Up @@ -244,7 +244,7 @@ public Optional<Node> getParentNode() {
* @return all nodes that have this node as their parent.
*/
public List<Node> getChildNodes() {
return unmodifiableList(childrenNodes);
return unmodifiableList(childNodes);
}

public <N extends Node> boolean containsWithin(N other) {
Expand Down Expand Up @@ -308,12 +308,12 @@ public Node setParentNode(Node parentNode) {

// remove from old parent, if any
if (this.parentNode != null) {
this.parentNode.childrenNodes.remove(this);
this.parentNode.childNodes.remove(this);
}
this.parentNode = parentNode;
// add to new parent, if any
if (this.parentNode != null) {
this.parentNode.childrenNodes.add(this);
this.parentNode.childNodes.add(this);
}
return this;
}
Expand Down
Expand Up @@ -204,7 +204,7 @@ public String getDeclarationAsString(boolean includingModifiers, boolean includi
StringBuilder sb = new StringBuilder();
if (includingModifiers) {
AccessSpecifier accessSpecifier = Modifier.getAccessSpecifier(getModifiers());
sb.append(accessSpecifier.getCodeRepresenation());
sb.append(accessSpecifier.asString());
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
}
sb.append(getName());
Expand Down
Expand Up @@ -346,7 +346,7 @@ public String getDeclarationAsString(boolean includingModifiers, boolean includi
StringBuilder sb = new StringBuilder();
if (includingModifiers) {
AccessSpecifier accessSpecifier = Modifier.getAccessSpecifier(getModifiers());
sb.append(accessSpecifier.getCodeRepresenation());
sb.append(accessSpecifier.asString());
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
if (getModifiers().contains(Modifier.STATIC)) {
sb.append("static ");
Expand Down
Expand Up @@ -190,7 +190,7 @@ public Parameter setName(SimpleName name) {
identifier.setName(name);
} else {
VariableDeclaratorId newId = new VariableDeclaratorId(name);
notifyPropertyChange(ObservableProperty.ID, this.identifier, newId);
notifyPropertyChange(ObservableProperty.IDENTIFIER, this.identifier, newId);
identifier = newId;
}
return this;
Expand Down
Expand Up @@ -105,7 +105,7 @@ public Optional<Expression> getInitializer() {
}

public VariableDeclarator setIdentifier(VariableDeclaratorId identifier) {
notifyPropertyChange(ObservableProperty.ID, this.identifier, identifier);
notifyPropertyChange(ObservableProperty.IDENTIFIER, this.identifier, identifier);
this.identifier = assertNotNull(identifier);
setAsParentNodeOf(this.identifier);
return this;
Expand All @@ -118,7 +118,7 @@ public VariableDeclarator setIdentifier(VariableDeclaratorId identifier) {
* @return this, the VariableDeclarator
*/
public VariableDeclarator setInitializer(Expression initializer) {
notifyPropertyChange(ObservableProperty.INIT, this.initializer, initializer);
notifyPropertyChange(ObservableProperty.INITIALIZER, this.initializer, initializer);
this.initializer = initializer;
setAsParentNodeOf(this.initializer);
return this;
Expand All @@ -132,7 +132,7 @@ public VariableDeclarator setInitializer(Expression initializer) {
*/
public VariableDeclarator setInit(String init) {
NameExpr newInit = new NameExpr(assertNotNull(init));
notifyPropertyChange(ObservableProperty.INIT, this.initializer, newInit);
notifyPropertyChange(ObservableProperty.INITIALIZER, this.initializer, newInit);
this.initializer = newInit;
setAsParentNodeOf(this.initializer);
return this;
Expand Down
Expand Up @@ -80,7 +80,7 @@ public final String getIdentifier() {
}

public Name setIdentifier(final String identifier) {
notifyPropertyChange(ObservableProperty.ID, this.identifier, identifier);
notifyPropertyChange(ObservableProperty.IDENTIFIER, this.identifier, identifier);
this.identifier = assertNotNull(identifier);
return this;
}
Expand Down
Expand Up @@ -47,7 +47,7 @@ public final String getIdentifier() {

@Override
public SimpleName setIdentifier(final String identifier) {
notifyPropertyChange(ObservableProperty.ID, this.identifier, identifier);
notifyPropertyChange(ObservableProperty.IDENTIFIER, this.identifier, identifier);
this.identifier = assertNotNull(identifier);
return this;
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ default String getId() {
return getIdentifier();
}

default N setId(String id) {
return setIdentifier(id);
default N setId(String identifier) {
return setIdentifier(identifier);
}
}
Expand Up @@ -9,24 +9,24 @@
import com.github.javaparser.ast.stmt.Statement;

public interface NodeWithStatements<N extends Node> {
NodeList<Statement> getStmts();
NodeList<Statement> getStatements();

default Statement getStmt(int i) {
return getStmts().get(i);
default Statement getStatement(int i) {
return getStatements().get(i);
}

N setStmts(final NodeList<Statement> stmts);
N setStatements(final NodeList<Statement> statements);

@SuppressWarnings("unchecked")
default N addStatement(Statement statement) {
getStmts().add(statement);
getStatements().add(statement);
statement.setParentNode((Node) this);
return (N) this;
}

@SuppressWarnings("unchecked")
default N addStatement(int index, final Statement statement) {
getStmts().add(index, statement);
getStatements().add(index, statement);
statement.setParentNode((Node) this);
return (N) this;
}
Expand All @@ -39,9 +39,6 @@ default N addStatement(Expression expr) {

/**
* It will use {@link JavaParser#parseStatement(String)} inside, so it should end with a semi column
*
* @param statement
* @return
*/
default N addStatement(String statement) {
return addStatement(JavaParser.parseStatement(statement));
Expand All @@ -54,13 +51,13 @@ default N addStatement(int index, final Expression expr) {
}

default <A extends Statement> A addAndGetStatement(A statement) {
getStmts().add(statement);
getStatements().add(statement);
statement.setParentNode((Node) this);
return statement;
}

default Statement addAndGetStatement(int index, final Statement statement) {
getStmts().add(index, statement);
getStatements().add(index, statement);
statement.setParentNode((Node) this);
return statement;
}
Expand All @@ -76,7 +73,7 @@ default ExpressionStmt addAndGetStatement(String statement) {
}

default boolean isEmpty() {
return getStmts().isEmpty();
return getStatements().isEmpty();
}

@SuppressWarnings("unchecked")
Expand All @@ -88,6 +85,6 @@ default N copyStatements(NodeList<Statement> nodeList) {
}

default N copyStatements(NodeWithStatements<?> other) {
return copyStatements(other.getStmts());
return copyStatements(other.getStatements());
}
}
Expand Up @@ -6,12 +6,14 @@
public enum ObservableProperty {
ANNOTATIONS,
ANONYMOUS_CLASS_BODY,
@Deprecated
ARRAY_BRACKET_PAIRS_AFTER_ID,
@Deprecated
ARRAY_BRACKET_PAIRS_AFTER_TYPE,
ARGUMENTS,
BLOCK,
BODY,
CATCHS,
CATCH_CLAUSES,
CATCH_BLOCK,
CHECK,
CLASS_BODY,
Expand All @@ -25,6 +27,7 @@ public enum ObservableProperty {
DEFAULT_VALUE,
DIMENSION,
ELEMENTS,
@Deprecated
ELEMENT_TYPE,
ELSE_EXPR,
ELSE_STMT,
Expand All @@ -33,12 +36,10 @@ public enum ObservableProperty {
EXTENDED_TYPES,
FIELD,
FINALLY_BLOCK,
ID,
IDENTIFIER,
IMPLEMENTED_TYPES,
IMPORTS,
INDEX,
INIT,
INITIALIZER,
INNER,
IS_INTERFACE,
Expand All @@ -50,12 +51,12 @@ public enum ObservableProperty {
MEMBERS,
MEMBER_VALUE,
MODIFIERS,
MSG,
MESSAGE,
NAME,
OPERATOR,
PACKAGE,
PACKAGE_DECLARATION,
PAIRS,
PARAM,
PARAMETER,
PARAMETERS,
PARAMETERS_ENCLOSED,
QUALIFIER,
Expand All @@ -66,8 +67,8 @@ public enum ObservableProperty {
SELECTOR,
STATIC,
STATIC_MEMBER,
STMT,
STMTS,
STATEMENT,
STATEMENTS,
SUPER,
TARGET,
THEN_EXPR,
Expand Down
Expand Up @@ -39,7 +39,7 @@ public final class AssertStmt extends Statement {

private Expression check;

private Expression msg;
private Expression message;

public AssertStmt() {
this(null, new BooleanLiteralExpr(), null);
Expand All @@ -49,14 +49,14 @@ public AssertStmt(final Expression check) {
this(null, check, null);
}

public AssertStmt(final Expression check, final Expression msg) {
this(null, check, msg);
public AssertStmt(final Expression check, final Expression message) {
this(null, check, message);
}

public AssertStmt(final Range range, final Expression check, final Expression msg) {
public AssertStmt(final Range range, final Expression check, final Expression message) {
super(range);
setCheck(check);
setMessage(msg);
setMessage(message);
}

@Override
Expand All @@ -74,7 +74,7 @@ public Expression getCheck() {
}

public Optional<Expression> getMessage() {
return Optional.ofNullable(msg);
return Optional.ofNullable(message);
}

public AssertStmt setCheck(final Expression check) {
Expand All @@ -91,9 +91,9 @@ public AssertStmt setCheck(final Expression check) {
* @return this, the AssertStmt
*/
public AssertStmt setMessage(final Expression msg) {
notifyPropertyChange(ObservableProperty.MSG, this.msg, msg);
this.msg = msg;
setAsParentNodeOf(this.msg);
notifyPropertyChange(ObservableProperty.MESSAGE, this.message, msg);
this.message = msg;
setAsParentNodeOf(this.message);
return this;
}
}

0 comments on commit ded70c8

Please sign in to comment.