-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ROASTER-1: Java Statement Fluent Model #27
Open
sotty
wants to merge
1
commit into
forge:master
Choose a base branch
from
sotty:stats_exprs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
api/src/main/java/org/jboss/forge/roaster/model/Block.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model; | ||
|
||
import org.jboss.forge.roaster.Origin; | ||
import org.jboss.forge.roaster.model.source.BlockHolder; | ||
|
||
/** | ||
* Represent a block, a sequence of statements possibly including other blocks | ||
*/ | ||
public interface Block<O extends JavaType<O>, | ||
P extends BlockHolder<O>> | ||
extends Origin<P>, | ||
BlockHolder<O> { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
api/src/main/java/org/jboss/forge/roaster/model/ExpressionHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model; | ||
|
||
public interface ExpressionHolder<O extends JavaType<O>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Javadoc is missing |
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
package org.jboss.forge.roaster.model; | ||
|
||
import org.jboss.forge.roaster.Roaster; | ||
import org.jboss.forge.roaster.model.source.JavaClassSource; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused import |
||
|
||
/** | ||
* Represents a Java {@code class} type. See {@link Roaster} for various options in generating {@link JavaClass} | ||
|
@@ -32,5 +33,4 @@ public interface JavaClass<O extends JavaClass<O>> extends | |
* @return <code>true</code> if this {@link JavaClass} represents a local class. | ||
*/ | ||
public boolean isLocalClass(); | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
api/src/main/java/org/jboss/forge/roaster/model/expressions/AccessBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
/** | ||
* Abstract factory interface that supports the construction of accessor expressions, in source format | ||
* The expression returns an object with accessible fields, accessors and methods | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface AccessBuilder<O extends JavaSource<O>, | ||
P extends ExpressionHolder<O>, | ||
E extends NonPrimitiveExpression<O,P,E>> | ||
{ | ||
|
||
/** | ||
* Returns a field access expression | ||
* Can be invoked on a parent expression | ||
* @param field The name of the field | ||
* @return a field accessor | ||
*/ | ||
public Field<O,E> field(String field); | ||
|
||
/** | ||
* Returns a getter expression | ||
* Can be invoked on a parent expression | ||
* @param field The name of the field | ||
* @param klass The name of the type of the field | ||
* @return a getter method invocation expression | ||
*/ | ||
public Getter<O,E> getter(String field, String klass); | ||
|
||
/** | ||
* Returns a getter expression | ||
* Can be invoked on a parent expression | ||
* @param field The name of the field | ||
* @param klass The type of the field | ||
* @return a getter method invocation expression | ||
*/ | ||
public Getter<O,E> getter(String field, Class klass); | ||
|
||
/** | ||
* Returns a setter expression | ||
* Can be invoked on a parent expression | ||
* @param field The name of the field | ||
* @param klass The name of the type of the field | ||
* @param value The expression returning the value to be set | ||
* @return a setter method invocation expression | ||
*/ | ||
public Setter<O,E> setter(String field, String klass, ExpressionSource<?,?,?> value); | ||
|
||
/** | ||
* Returns a setter expression | ||
* Can be invoked on a parent expression | ||
* @param field The name of the field | ||
* @param klass The type of the field | ||
* @param value The expression returning the value to be set | ||
* @return a setter method invocation expression | ||
*/ | ||
public Setter<O,E> setter(String field, Class klass, ExpressionSource<?,?,?> value); | ||
|
||
/** | ||
* Returns a method invocation expression | ||
* Can be invoked on a parent expression | ||
* @param method The name of the method | ||
* @return a method invocation expression | ||
*/ | ||
public MethodCallExpression<O,E> invoke(String method); | ||
|
||
/** | ||
* Returns an array indexing expression | ||
* Can be invoked on a parent expression | ||
* @param index The expression returning the index used for accessing the array | ||
* @return an array indexing expression | ||
*/ | ||
public ArrayIndexer<O,E> itemAt(ExpressionSource<?,?,?> index); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
api/src/main/java/org/jboss/forge/roaster/model/expressions/Accessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
/** | ||
* Abstract interface that represents accessors (getters, fields, etc..) in source format | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface Accessor<O extends JavaSource<O>, | ||
P extends ExpressionHolder<O>, | ||
E extends NonPrimitiveExpression<O,P,E>> | ||
extends Argument<O,P,E>, | ||
AccessBuilder<O,P,E> | ||
{ | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
api/src/main/java/org/jboss/forge/roaster/model/expressions/Argument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
/** | ||
* Abstract marker interface that represents operation or method arguments in source format | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface Argument<O extends JavaSource<O>, | ||
P extends ExpressionHolder<O>, | ||
E extends ExpressionSource<O,P,E>> | ||
extends ExpressionSource<O,P,E> | ||
{ | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
api/src/main/java/org/jboss/forge/roaster/model/expressions/ArgumentHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Abstract marker interface that represents expressions requiring arguments | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface ArgumentHolder<O extends JavaSource<O>, | ||
P extends ExpressionHolder<O>, | ||
E extends NonPrimitiveExpression<O,P,?>> | ||
extends ExpressionHolder<O> | ||
{ | ||
|
||
/** | ||
* Adds an argument to the expression | ||
* @param arg The argument to be added | ||
* @return The expression itself | ||
*/ | ||
public E addArgument(Argument<?,?,?> arg); | ||
|
||
/** | ||
* Returns the current list of arguments | ||
* @return An immutable list containing the arguments | ||
*/ | ||
public List<Argument<O,E,?>> getArguments(); | ||
} |
57 changes: 57 additions & 0 deletions
57
api/src/main/java/org/jboss/forge/roaster/model/expressions/ArrayConstructorExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Represent an array constructor expression in source format | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface ArrayConstructorExpression<O extends JavaSource<O>, | ||
P extends ExpressionHolder<O>> | ||
extends Argument<O,P,ArrayConstructorExpression<O,P>>, | ||
NonPrimitiveExpression<O,P,ArrayConstructorExpression<O,P>> | ||
{ | ||
|
||
/** | ||
* Adds a dimension to the array, allocating <code>dim</code> slots | ||
* @param dim the number of elements in the new array dimension | ||
* @return The <code>ArrayConstructorExpression/code> itself | ||
*/ | ||
public ArrayConstructorExpression<O,P> addDimension(ExpressionSource<?,?,?> dim); | ||
|
||
/** | ||
* Initializes the array using an <code>ArrayInit</code> expressoin | ||
* @param array the initial value for the array variable | ||
* @return The <code>ArrayConstructorExpression/code> itself | ||
*/ | ||
public ArrayConstructorExpression<O,P> init(ArrayInit<?,?> array); | ||
|
||
/** | ||
* Returns the array initialization expression, or null if none has been set | ||
* @return An <code>ArrayInit</code> expression | ||
*/ | ||
public ArrayInit<O,ArrayConstructorExpression<O,P>> getInit(); | ||
|
||
/** | ||
* Returns the expressions defining the number of slots for each array dimension | ||
* @return An immutable list containing the expressions initializing each dimension | ||
*/ | ||
public List<ExpressionSource<O,ArrayConstructorExpression<O,P>,?>> getDimensions(); | ||
|
||
/** | ||
* Returns the number of dimensions of the array being constructed | ||
* @return the number of dimensions for this array | ||
*/ | ||
public int getDimension(); | ||
} |
37 changes: 37 additions & 0 deletions
37
api/src/main/java/org/jboss/forge/roaster/model/expressions/ArrayIndexer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
/** | ||
* Represent an array indexing expression in source format | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface ArrayIndexer<O extends JavaSource<O>, P extends ExpressionHolder<O>> | ||
extends OrdinalArgument<O,P,ArrayIndexer<O,P>>, | ||
NonPrimitiveExpression<O,P,ArrayIndexer<O,P>>, | ||
InvocationTargetHolder<O,P,ArrayIndexer<O,P>> | ||
{ | ||
|
||
/** | ||
* Returns the expression returning the index to be accessed | ||
* @return The expression returning the index used by this <code>ArrayIndexer</code> | ||
*/ | ||
public ExpressionSource<O,ArrayIndexer<O,P>,?> getIndex(); | ||
|
||
/** | ||
* Sets the expression returning the index to be used for accessing the array | ||
* @param index An expression returning an integer, used to access the array | ||
* @return The <code>ArrayIndexer</code> itself | ||
*/ | ||
public ArrayIndexer<O,P> setIndex(ExpressionSource<?,?,?> index); | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
api/src/main/java/org/jboss/forge/roaster/model/expressions/ArrayInit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.expressions; | ||
|
||
|
||
import org.jboss.forge.roaster.model.ExpressionHolder; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Represent an array constructor expression in source format | ||
* | ||
* @author <a href="[email protected]">Davide Sottara</a> | ||
*/ | ||
public interface ArrayInit<O extends JavaSource<O>, P extends ExpressionHolder<O>> | ||
extends ExpressionSource<O,P,ArrayInit<O,P>>, | ||
NonPrimitiveExpression<O,P,ArrayInit<O,P>> | ||
{ | ||
|
||
/** | ||
* Adds a sub-array literal to this array constructing expression | ||
* @param subRow The sub-array | ||
* @return The <code>ArrayInit</code> itself | ||
*/ | ||
public ArrayInit<O,P> addElement(ArrayInit<?,?> subRow); | ||
|
||
/** | ||
* Adds an element to this array constructing expression | ||
* @param subElement The expression returning the element to be addeed to the array | ||
* @return The <code>ArrayInit</code> itself | ||
*/ | ||
public ArrayInit<O,P> addElement(ExpressionSource<?,?,?> subElement); | ||
|
||
/** | ||
* Returns the current elements used to initialize the array | ||
* @return An immutable list containing the element expressions | ||
*/ | ||
public List<ExpressionSource<O,ArrayInit<O,P>,?>> getElements(); | ||
|
||
/** | ||
* Counts and returns the number of elements in this array | ||
* @return | ||
*/ | ||
public int size(); | ||
|
||
/** | ||
* Returns the number of dimensions in the array, as inferred by the init expressions | ||
* Example : { {1}, {2}, {3} } size() is 3, but getDimension() is 2 | ||
* @return the dimension | ||
*/ | ||
public int getDimension(); | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
On Sat, Jul 25, 2015 at 11:48 PM, George Gastaldi [email protected]
wrote: