Skip to content

Commit 517d98c

Browse files
committed
ROASTER-1: Java Statement Fluent Model
Update Copyright Conflicts: api/src/main/java/org/jboss/forge/roaster/model/source/MethodSource.java impl/src/main/java/org/jboss/forge/roaster/model/impl/AnnotationImpl.java impl/src/main/java/org/jboss/forge/roaster/model/impl/MethodImpl.java Conflicts: impl/src/main/java/org/jboss/forge/roaster/model/impl/MethodImpl.java
1 parent ef908ef commit 517d98c

177 files changed

Lines changed: 13808 additions & 23 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model;
9+
10+
import org.jboss.forge.roaster.Origin;
11+
import org.jboss.forge.roaster.model.source.BlockHolder;
12+
13+
/**
14+
* Represent a block, a sequence of statements possibly including other blocks
15+
*/
16+
public interface Block<O extends JavaType<O>,
17+
P extends BlockHolder<O>>
18+
extends Origin<P>,
19+
BlockHolder<O> {
20+
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model;
9+
10+
public interface ExpressionHolder<O extends JavaType<O>> {
11+
12+
}

api/src/main/java/org/jboss/forge/roaster/model/JavaClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.jboss.forge.roaster.model;
99

1010
import org.jboss.forge.roaster.Roaster;
11+
import org.jboss.forge.roaster.model.source.JavaClassSource;
1112

1213
/**
1314
* 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
3233
* @return <code>true</code> if this {@link JavaClass} represents a local class.
3334
*/
3435
public boolean isLocalClass();
35-
3636
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
11+
import org.jboss.forge.roaster.model.ExpressionHolder;
12+
import org.jboss.forge.roaster.model.source.JavaSource;
13+
14+
/**
15+
* Abstract factory interface that supports the construction of accessor expressions, in source format
16+
* The expression returns an object with accessible fields, accessors and methods
17+
*
18+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
19+
*/
20+
public interface AccessBuilder<O extends JavaSource<O>,
21+
P extends ExpressionHolder<O>,
22+
E extends NonPrimitiveExpression<O,P,E>>
23+
{
24+
25+
/**
26+
* Returns a field access expression
27+
* Can be invoked on a parent expression
28+
* @param field The name of the field
29+
* @return a field accessor
30+
*/
31+
public Field<O,E> field(String field);
32+
33+
/**
34+
* Returns a getter expression
35+
* Can be invoked on a parent expression
36+
* @param field The name of the field
37+
* @param klass The name of the type of the field
38+
* @return a getter method invocation expression
39+
*/
40+
public Getter<O,E> getter(String field, String klass);
41+
42+
/**
43+
* Returns a getter expression
44+
* Can be invoked on a parent expression
45+
* @param field The name of the field
46+
* @param klass The type of the field
47+
* @return a getter method invocation expression
48+
*/
49+
public Getter<O,E> getter(String field, Class klass);
50+
51+
/**
52+
* Returns a setter expression
53+
* Can be invoked on a parent expression
54+
* @param field The name of the field
55+
* @param klass The name of the type of the field
56+
* @param value The expression returning the value to be set
57+
* @return a setter method invocation expression
58+
*/
59+
public Setter<O,E> setter(String field, String klass, ExpressionSource<?,?,?> value);
60+
61+
/**
62+
* Returns a setter expression
63+
* Can be invoked on a parent expression
64+
* @param field The name of the field
65+
* @param klass The type of the field
66+
* @param value The expression returning the value to be set
67+
* @return a setter method invocation expression
68+
*/
69+
public Setter<O,E> setter(String field, Class klass, ExpressionSource<?,?,?> value);
70+
71+
/**
72+
* Returns a method invocation expression
73+
* Can be invoked on a parent expression
74+
* @param method The name of the method
75+
* @return a method invocation expression
76+
*/
77+
public MethodCallExpression<O,E> invoke(String method);
78+
79+
/**
80+
* Returns an array indexing expression
81+
* Can be invoked on a parent expression
82+
* @param index The expression returning the index used for accessing the array
83+
* @return an array indexing expression
84+
*/
85+
public ArrayIndexer<O,E> itemAt(ExpressionSource<?,?,?> index);
86+
87+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
import org.jboss.forge.roaster.model.ExpressionHolder;
11+
import org.jboss.forge.roaster.model.source.JavaSource;
12+
13+
/**
14+
* Abstract interface that represents accessors (getters, fields, etc..) in source format
15+
*
16+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
17+
*/
18+
public interface Accessor<O extends JavaSource<O>,
19+
P extends ExpressionHolder<O>,
20+
E extends NonPrimitiveExpression<O,P,E>>
21+
extends Argument<O,P,E>,
22+
AccessBuilder<O,P,E>
23+
{
24+
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
11+
import org.jboss.forge.roaster.model.ExpressionHolder;
12+
import org.jboss.forge.roaster.model.source.JavaSource;
13+
14+
/**
15+
* Abstract marker interface that represents operation or method arguments in source format
16+
*
17+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
18+
*/
19+
public interface Argument<O extends JavaSource<O>,
20+
P extends ExpressionHolder<O>,
21+
E extends ExpressionSource<O,P,E>>
22+
extends ExpressionSource<O,P,E>
23+
{
24+
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
import org.jboss.forge.roaster.model.ExpressionHolder;
11+
import org.jboss.forge.roaster.model.source.JavaSource;
12+
13+
import java.util.List;
14+
15+
/**
16+
* Abstract marker interface that represents expressions requiring arguments
17+
*
18+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
19+
*/
20+
public interface ArgumentHolder<O extends JavaSource<O>,
21+
P extends ExpressionHolder<O>,
22+
E extends NonPrimitiveExpression<O,P,?>>
23+
extends ExpressionHolder<O>
24+
{
25+
26+
/**
27+
* Adds an argument to the expression
28+
* @param arg The argument to be added
29+
* @return The expression itself
30+
*/
31+
public E addArgument(Argument<?,?,?> arg);
32+
33+
/**
34+
* Returns the current list of arguments
35+
* @return An immutable list containing the arguments
36+
*/
37+
public List<Argument<O,E,?>> getArguments();
38+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
import org.jboss.forge.roaster.model.ExpressionHolder;
11+
import org.jboss.forge.roaster.model.source.JavaSource;
12+
13+
import java.util.List;
14+
15+
/**
16+
* Represent an array constructor expression in source format
17+
*
18+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
19+
*/
20+
public interface ArrayConstructorExpression<O extends JavaSource<O>,
21+
P extends ExpressionHolder<O>>
22+
extends Argument<O,P,ArrayConstructorExpression<O,P>>,
23+
NonPrimitiveExpression<O,P,ArrayConstructorExpression<O,P>>
24+
{
25+
26+
/**
27+
* Adds a dimension to the array, allocating <code>dim</code> slots
28+
* @param dim the number of elements in the new array dimension
29+
* @return The <code>ArrayConstructorExpression/code> itself
30+
*/
31+
public ArrayConstructorExpression<O,P> addDimension(ExpressionSource<?,?,?> dim);
32+
33+
/**
34+
* Initializes the array using an <code>ArrayInit</code> expressoin
35+
* @param array the initial value for the array variable
36+
* @return The <code>ArrayConstructorExpression/code> itself
37+
*/
38+
public ArrayConstructorExpression<O,P> init(ArrayInit<?,?> array);
39+
40+
/**
41+
* Returns the array initialization expression, or null if none has been set
42+
* @return An <code>ArrayInit</code> expression
43+
*/
44+
public ArrayInit<O,ArrayConstructorExpression<O,P>> getInit();
45+
46+
/**
47+
* Returns the expressions defining the number of slots for each array dimension
48+
* @return An immutable list containing the expressions initializing each dimension
49+
*/
50+
public List<ExpressionSource<O,ArrayConstructorExpression<O,P>,?>> getDimensions();
51+
52+
/**
53+
* Returns the number of dimensions of the array being constructed
54+
* @return the number of dimensions for this array
55+
*/
56+
public int getDimension();
57+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
import org.jboss.forge.roaster.model.ExpressionHolder;
11+
import org.jboss.forge.roaster.model.source.JavaSource;
12+
13+
/**
14+
* Represent an array indexing expression in source format
15+
*
16+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
17+
*/
18+
public interface ArrayIndexer<O extends JavaSource<O>, P extends ExpressionHolder<O>>
19+
extends OrdinalArgument<O,P,ArrayIndexer<O,P>>,
20+
NonPrimitiveExpression<O,P,ArrayIndexer<O,P>>,
21+
InvocationTargetHolder<O,P,ArrayIndexer<O,P>>
22+
{
23+
24+
/**
25+
* Returns the expression returning the index to be accessed
26+
* @return The expression returning the index used by this <code>ArrayIndexer</code>
27+
*/
28+
public ExpressionSource<O,ArrayIndexer<O,P>,?> getIndex();
29+
30+
/**
31+
* Sets the expression returning the index to be used for accessing the array
32+
* @param index An expression returning an integer, used to access the array
33+
* @return The <code>ArrayIndexer</code> itself
34+
*/
35+
public ArrayIndexer<O,P> setIndex(ExpressionSource<?,?,?> index);
36+
37+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Eclipse Public License version 1.0, available at
5+
* http://www.eclipse.org/legal/epl-v10.html
6+
*/
7+
8+
package org.jboss.forge.roaster.model.expressions;
9+
10+
11+
import org.jboss.forge.roaster.model.ExpressionHolder;
12+
import org.jboss.forge.roaster.model.source.JavaSource;
13+
14+
import java.util.List;
15+
16+
/**
17+
* Represent an array constructor expression in source format
18+
*
19+
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
20+
*/
21+
public interface ArrayInit<O extends JavaSource<O>, P extends ExpressionHolder<O>>
22+
extends ExpressionSource<O,P,ArrayInit<O,P>>,
23+
NonPrimitiveExpression<O,P,ArrayInit<O,P>>
24+
{
25+
26+
/**
27+
* Adds a sub-array literal to this array constructing expression
28+
* @param subRow The sub-array
29+
* @return The <code>ArrayInit</code> itself
30+
*/
31+
public ArrayInit<O,P> addElement(ArrayInit<?,?> subRow);
32+
33+
/**
34+
* Adds an element to this array constructing expression
35+
* @param subElement The expression returning the element to be addeed to the array
36+
* @return The <code>ArrayInit</code> itself
37+
*/
38+
public ArrayInit<O,P> addElement(ExpressionSource<?,?,?> subElement);
39+
40+
/**
41+
* Returns the current elements used to initialize the array
42+
* @return An immutable list containing the element expressions
43+
*/
44+
public List<ExpressionSource<O,ArrayInit<O,P>,?>> getElements();
45+
46+
/**
47+
* Counts and returns the number of elements in this array
48+
* @return
49+
*/
50+
public int size();
51+
52+
/**
53+
* Returns the number of dimensions in the array, as inferred by the init expressions
54+
* Example : { {1}, {2}, {3} } size() is 3, but getDimension() is 2
55+
* @return the dimension
56+
*/
57+
public int getDimension();
58+
59+
}

0 commit comments

Comments
 (0)