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; this.codeRepresenation = codeRepresentation;
} }


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


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


private PackageDeclaration pakage; private PackageDeclaration packageDeclaration;


private NodeList<ImportDeclaration> imports; private NodeList<ImportDeclaration> imports;


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


public CompilationUnit(PackageDeclaration pakage, NodeList<ImportDeclaration> imports, NodeList<TypeDeclaration<?>> types) { public CompilationUnit(PackageDeclaration packageDeclaration, NodeList<ImportDeclaration> imports, NodeList<TypeDeclaration<?>> types) {
this(null, pakage, imports, 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) { NodeList<TypeDeclaration<?>> types) {
super(range); super(range);
setPackage(pakage); setPackage(packageDeclaration);
setImports(imports); setImports(imports);
setTypes(types); setTypes(types);
} }
Expand Down Expand Up @@ -129,7 +129,7 @@ public ImportDeclaration getImport(int i) {
* @return the package declaration or <code>null</code> * @return the package declaration or <code>null</code>
*/ */
public Optional<PackageDeclaration> getPackage() { 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. * Sets or clear the package declarations of this compilation unit.
* *
* @param pakage * @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 * package
*/ */
public CompilationUnit setPackage(PackageDeclaration pakage) { public CompilationUnit setPackage(PackageDeclaration pakage) {
notifyPropertyChange(ObservableProperty.PACKAGE, this.pakage, pakage); notifyPropertyChange(ObservableProperty.PACKAGE_DECLARATION, this.packageDeclaration, pakage);
this.pakage = pakage; this.packageDeclaration = pakage;
setAsParentNodeOf(this.pakage); setAsParentNodeOf(this.packageDeclaration);
return this; return this;
} }


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


String asString; final String codeRepresentation;


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


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


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


private Node parentNode; private Node parentNode;


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


private IdentityHashMap<DataKey<?>, Object> data = null; 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. * @return all nodes that have this node as their parent.
*/ */
public List<Node> getChildNodes() { public List<Node> getChildNodes() {
return unmodifiableList(childrenNodes); return unmodifiableList(childNodes);
} }


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


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


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


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


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


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


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


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


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


@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default N addStatement(int index, final Statement statement) { default N addStatement(int index, final Statement statement) {
getStmts().add(index, statement); getStatements().add(index, statement);
statement.setParentNode((Node) this); statement.setParentNode((Node) this);
return (N) 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 * It will use {@link JavaParser#parseStatement(String)} inside, so it should end with a semi column
*
* @param statement
* @return
*/ */
default N addStatement(String statement) { default N addStatement(String statement) {
return addStatement(JavaParser.parseStatement(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) { default <A extends Statement> A addAndGetStatement(A statement) {
getStmts().add(statement); getStatements().add(statement);
statement.setParentNode((Node) this); statement.setParentNode((Node) this);
return statement; return statement;
} }


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


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


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


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


private Expression check; private Expression check;


private Expression msg; private Expression message;


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


public AssertStmt(final Expression check, final Expression msg) { public AssertStmt(final Expression check, final Expression message) {
this(null, check, msg); 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); super(range);
setCheck(check); setCheck(check);
setMessage(msg); setMessage(message);
} }


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


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


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

0 comments on commit ded70c8

Please sign in to comment.