diff --git a/doc/code_elements.md b/doc/code_elements.md
old mode 100755
new mode 100644
index 7cf5fec1be7..8c7fadd8cbb
--- a/doc/code_elements.md
+++ b/doc/code_elements.md
@@ -19,4 +19,399 @@ interface `CtInvocation` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-
inheriting from both interfaces `CtStatement` and `CtExpression`.
The generic type of `CtExpression` is used to add static type-checking when transforming programs.
-![Code part of the Spoon Java 8 metamodel]({{ "/images/code-elements.png" | prepend: site.baseurl }})
\ No newline at end of file
+![Code part of the Spoon Java 8 metamodel]({{ "/images/code-elements.png" | prepend: site.baseurl }})
+
+### CtArrayRead
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtArrayRead.html)
+```java
+
+ int[] array = new int[10];
+ System.out.println(
+ array[0] // <-- array read
+ );
+
+```
+### CtArrayWrite
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtArrayWrite.html)
+```java
+
+ Object[] array = new Object[10];
+ // array write
+ array[0] = "new value";
+
+```
+### CtAssert
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtAssert.html)
+```java
+assert 1+1==2
+```
+### CtAssignment
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtAssignment.html)
+```java
+
+ int x;
+ x = 4; // <-- an assignment
+
+```
+### CtBinaryOperator
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtBinaryOperator.html)
+```java
+
+ // 3+4 is the binary expression
+ int x = 3 + 4;
+
+```
+### CtBlock
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtBlock.html)
+```java
+
+ { // <-- block start
+ System.out.println("foo");
+ }
+
+```
+### CtBreak
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtBreak.html)
+```java
+
+ for(int i=0; i<10; i++) {
+ if (i>3) {
+ break; // <-- break statement
+ }
+ }
+
+```
+### CtCase
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtCase.html)
+```java
+
+int x = 0;
+switch(x) {
+ case 1: // <-- case statement
+ System.out.println("foo");
+}
+```
+### CtConditional
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtConditional.html)
+```java
+
+ System.out.println(
+ 1==0 ? "foo" : "bar" // <-- ternary conditional
+ );
+
+```
+### CtConstructorCall
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtConstructorCall.html)
+```java
+
+ new Object();
+
+```
+### CtContinue
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtContinue.html)
+```java
+
+ for(int i=0; i<10; i++) {
+ if (i>3) {
+ continue; // <-- continue statement
+ }
+ }
+
+```
+### CtDo
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtDo.html)
+```java
+
+ int x = 0;
+ do {
+ x=x+1;
+ } while (x<10);
+
+```
+### CtExecutableReferenceExpression
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtExecutableReferenceExpression.html)
+```java
+
+ java.util.function.Supplier p =
+ Object::new;
+
+```
+### CtFieldRead
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtFieldRead.html)
+```java
+
+ class Foo { int field; }
+ Foo x = new Foo();
+ System.out.println(x.field);
+
+```
+### CtFieldWrite
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtFieldWrite.html)
+```java
+
+ class Foo { int field; }
+ Foo x = new Foo();
+ x.field = 0;
+
+```
+### CtFor
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtFor.html)
+```java
+
+ // a for statement
+ for(int i=0; i<10; i++) {
+ System.out.println("foo");
+ }
+
+```
+### CtForEach
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtForEach.html)
+```java
+
+ java.util.List l = new java.util.ArrayList();
+ for(Object o : l) { // <-- foreach loop
+ System.out.println(o);
+ }
+
+```
+### CtIf
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtIf.html)
+```java
+
+ if (1==0) {
+ System.out.println("foo");
+ } else {
+ System.out.println("bar");
+ }
+
+```
+### CtInvocation
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtInvocation.html)
+```java
+
+ // invocation of method println
+ // the target is "System.out"
+ System.out.println("foo");
+
+```
+### CtLambda
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtLambda.html)
+```java
+
+ java.util.List l = new java.util.ArrayList();
+ l.stream().map(
+ x -> { return x.toString(); } // a lambda
+ );
+
+```
+### CtLiteral
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtLiteral.html)
+```java
+
+ int x = 4; // 4 is a literal
+
+```
+### CtLocalVariable
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtLocalVariable.html)
+```java
+
+ // defines a local variable x
+ int x = 0;
+
+```
+### CtNewArray
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtNewArray.html)
+```java
+
+ // inline creation of array content
+ int[] x = new int[] { 0, 1, 42}
+
+```
+### CtNewClass
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtNewClass.html)
+```java
+
+ // an anonymous class creation
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ System.out.println("foo");
+ }
+ };
+
+```
+### CtOperatorAssignment
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtOperatorAssignment.html)
+```java
+
+ int x = 0;
+ x *= 3; // <-- a CtOperatorAssignment
+
+```
+### CtReturn
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtReturn.html)
+```java
+
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ return; // <-- CtReturn statement
+ }
+ };
+
+```
+### CtSuperAccess
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtSuperAccess.html)
+```java
+
+ class Foo { int foo() { return 42;}};
+ class Bar extends Foo {
+ int foo() {
+ return super.foo(); // <-- access to super
+ }
+ };
+
+```
+### CtSwitch
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtSwitch.html)
+```java
+
+int x = 0;
+switch(x) { // <-- switch statement
+ case 1:
+ System.out.println("foo");
+}
+```
+### CtSynchronized
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtSynchronized.html)
+```java
+
+ java.util.List l = new java.util.ArrayList();
+ synchronized(l) {
+ System.out.println("foo");
+ }
+
+```
+### CtThisAccess
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtThisAccess.html)
+```java
+
+ class Foo {
+ int value = 42;
+ int foo() {
+ return this.value; // <-- access to this
+ }
+ };
+
+
+```
+### CtThrow
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtThrow.html)
+```java
+
+ throw new RuntimeException("oops")
+
+```
+### CtTry
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtTry.html)
+```java
+
+ try {
+ System.out.println("foo");
+ } catch (Exception ignore) {}
+
+```
+### CtTryWithResource
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtTryWithResource.html)
+```java
+
+ // br is the resource
+ try (java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("/foo"))) {
+ br.readLine();
+ }
+
+```
+### CtTypeAccess
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtTypeAccess.html)
+```java
+
+ // access to static field
+ java.io.PrintStream ps = System.out;
+
+
+ // call to static method
+ Class.forName("Foo")
+
+
+ // method reference
+ java.util.function.Supplier p =
+ Object::new;
+
+
+ // instanceof test
+ boolean x = new Object() instanceof Integer // Integer is represented as an access to type Integer
+
+
+ // fake field "class"
+ Class x = Number.class
+
+```
+### CtUnaryOperator
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtUnaryOperator.html)
+```java
+
+ int x=3;
+ --x; // <-- unary --
+
+```
+### CtVariableRead
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtVariableRead.html)
+```java
+
+ String variable = "";
+ System.out.println(
+ variable // <-- a variable read
+ );
+
+```
+### CtVariableWrite
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtVariableWrite.html)
+```java
+
+ String variable = "";
+ variable = "new value"; // variable write
+
+
+ String variable = "";
+ variable += "";
+
+```
+### CtWhile
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtWhile.html)
+```java
+
+ int x = 0;
+ while (x!=10) {
+ x=x+1;
+ };
+
+```
+### CtAnnotation
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/declaration/CtAnnotation.html)
+```java
+
+ // statement annotated by annotation @SuppressWarnings
+ @SuppressWarnings("unchecked")
+ java.util.List> x = new java.util.ArrayList<>()
+
+```
+### CtClass
+[(javadoc)](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/declaration/CtClass.html)
+```java
+
+ // a class definition
+ class Foo {
+ int x;
+ }
+
+```
diff --git a/doc/code_elements_header.md b/doc/code_elements_header.md
new file mode 100755
index 00000000000..7cf5fec1be7
--- /dev/null
+++ b/doc/code_elements_header.md
@@ -0,0 +1,22 @@
+---
+title: Code elements
+tags: [meta-model]
+keywords: code, elements, ast, meta, model
+last_updated: October 1, 2015
+---
+
+Figure at the end of this page shows the meta model for Java executable code.
+There are two main kinds of code elements.
+First, statements `CtStatement` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtStatement.html))
+are untyped top-level instructions that can be used directly in a block of code.
+Second, expressions `CtExpression` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtExpression.html))
+are used inside the statements. For instance, a `CtLoop` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtLoop.html))
+(which is a statement) points to `CtExpression` which expresses its boolean condition.
+
+Some code elements such as invocations and assignments are both statements
+and expressions (multiple inheritance links). Concretely, this is translated as an
+interface `CtInvocation` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtInvocation.html))
+inheriting from both interfaces `CtStatement` and `CtExpression`.
+The generic type of `CtExpression` is used to add static type-checking when transforming programs.
+
+![Code part of the Spoon Java 8 metamodel]({{ "/images/code-elements.png" | prepend: site.baseurl }})
\ No newline at end of file
diff --git a/src/main/java/spoon/reflect/code/CtArrayRead.java b/src/main/java/spoon/reflect/code/CtArrayRead.java
index efc02287d17..149785e525d 100644
--- a/src/main/java/spoon/reflect/code/CtArrayRead.java
+++ b/src/main/java/spoon/reflect/code/CtArrayRead.java
@@ -20,7 +20,12 @@
* This code element defines an read access to an array.
*
* In Java, it is a usage of a array outside an assignment. For example,
- * System.out.println(array[0]);
+ *
+ * int[] array = new int[10]; + * System.out.println( + * array[0] // <-- array read + * ); + ** * If you process this element, keep in mind that you will process array[0]++ too. * diff --git a/src/main/java/spoon/reflect/code/CtArrayWrite.java b/src/main/java/spoon/reflect/code/CtArrayWrite.java index 8b1ebf5974e..5748553c6c0 100644 --- a/src/main/java/spoon/reflect/code/CtArrayWrite.java +++ b/src/main/java/spoon/reflect/code/CtArrayWrite.java @@ -23,8 +23,9 @@ * * For example: *
+ * Object[] array = new Object[10]; + * // array write * array[0] = "new value"; - * array[0] += ""; ** * If you process this element, keep in mind that you won't process array[0]++. diff --git a/src/main/java/spoon/reflect/code/CtAssert.java b/src/main/java/spoon/reflect/code/CtAssert.java index 918a05f4df8..63b9b52664e 100644 --- a/src/main/java/spoon/reflect/code/CtAssert.java +++ b/src/main/java/spoon/reflect/code/CtAssert.java @@ -17,7 +17,8 @@ package spoon.reflect.code; /** - * This code element defines an
assert
clause.
+ * This code element defines an assert clause.
+ * Example: assert 1+1==2*/ public interface CtAssert
+ * int x; + * x = 4; // <-- an assignment + ** @param
+ * // 3+4 is the binary expression + * int x = 3 + 4; + ** @param
+ * { // <-- block start + * System.out.println("foo"); + * } + *+ * + * When the context calls for a return * value, the block should contain a return statement as a lastly reachable - * statement. The returned type if any is given by
R
.
+ * statement. The returned type if any is given by R.
*/
public interface CtBlockbreak
statement.
+ * This code element defines a break statement.
+ * Example:
+ * + * for(int i=0; i<10; i++) { + * if (i>3) { + * break; // <-- break statement + * } + * } + **/ public interface CtBreak extends CtCFlowBreak { /** diff --git a/src/main/java/spoon/reflect/code/CtCase.java b/src/main/java/spoon/reflect/code/CtCase.java index 2727858b782..4fad6e7a561 100644 --- a/src/main/java/spoon/reflect/code/CtCase.java +++ b/src/main/java/spoon/reflect/code/CtCase.java @@ -17,7 +17,14 @@ package spoon.reflect.code; /** - * This code element defines a
case
within a switch
.
+ * This code element defines a case within a switch-case.
+ *
+ * Example: + * int x = 0; + * switch(x) { + * case 1: // <-- case statement + * System.out.println("foo"); + * }* * @param
+ * int x = 0;
+ * // a comment
+ *
*/
public interface CtComment extends CtStatement {
enum CommentType {
diff --git a/src/main/java/spoon/reflect/code/CtConditional.java b/src/main/java/spoon/reflect/code/CtConditional.java
index bb7faeb5a69..f3484bba0b1 100644
--- a/src/main/java/spoon/reflect/code/CtConditional.java
+++ b/src/main/java/spoon/reflect/code/CtConditional.java
@@ -17,7 +17,14 @@
package spoon.reflect.code;
/**
- * This code element defines conditional expressions using the ?.
+ * This code element defines conditional expressions using the ? (ternary expressions).
+ *
+ * Example:
+ * + * System.out.println( + * 1==0 ? "foo" : "bar" // <-- ternary conditional + * ); + **/ public interface CtConditional
+ * new Object(); + ** @param
continue
statement.
+ * This code element defines the continue statement.
+ * Example:
+ * + * for(int i=0; i<10; i++) { + * if (i>3) { + * continue; // <-- continue statement + * } + * } + **/ public interface CtContinue extends CtCFlowBreak { /** diff --git a/src/main/java/spoon/reflect/code/CtDo.java b/src/main/java/spoon/reflect/code/CtDo.java index 80d08e1d57e..ca4d7edaadd 100644 --- a/src/main/java/spoon/reflect/code/CtDo.java +++ b/src/main/java/spoon/reflect/code/CtDo.java @@ -18,6 +18,15 @@ /** * This code element defines a
do
loop.
+ *
+ * Example:
+ * + * int x = 0; + * do { + * x=x+1; + * } while (x<10); + *+ * */ public interface CtDo extends CtLoop { /** diff --git a/src/main/java/spoon/reflect/code/CtExecutableReferenceExpression.java b/src/main/java/spoon/reflect/code/CtExecutableReferenceExpression.java index 12a9a5faa06..c69241ab689 100644 --- a/src/main/java/spoon/reflect/code/CtExecutableReferenceExpression.java +++ b/src/main/java/spoon/reflect/code/CtExecutableReferenceExpression.java @@ -21,7 +21,11 @@ /** * This abstract code element defines an expression which represents an executable reference. * - * In Java, it is generally of the form:
Type::method
.
+ * * Example:
+ * + * java.util.function.Supplier p = + * Object::new; + ** * @param
System.out.println(this.field);
+ * + * class Foo { int field; } + * Foo x = new Foo(); + * System.out.println(x.field); + ** * If you process this element, keep in mind that you will process field++ too. * diff --git a/src/main/java/spoon/reflect/code/CtFieldWrite.java b/src/main/java/spoon/reflect/code/CtFieldWrite.java index 2b51db4d81e..3a8bdb652b5 100644 --- a/src/main/java/spoon/reflect/code/CtFieldWrite.java +++ b/src/main/java/spoon/reflect/code/CtFieldWrite.java @@ -23,8 +23,9 @@ * * For example: *
- * this.field = "new value"; - * this.field += ""; + * class Foo { int field; } + * Foo x = new Foo(); + * x.field = 0; ** * If you process this element, keep in mind that you won't process field++. diff --git a/src/main/java/spoon/reflect/code/CtFor.java b/src/main/java/spoon/reflect/code/CtFor.java index 2086f30966f..daa0711d3b1 100644 --- a/src/main/java/spoon/reflect/code/CtFor.java +++ b/src/main/java/spoon/reflect/code/CtFor.java @@ -19,7 +19,14 @@ import java.util.List; /** - * This code element defines a
for
loop.
+ * This code element defines a for loop.
+ * Example:
+ * + * // a for statement + * for(int i=0; i<10; i++) { + * System.out.println("foo"); + * } + **/ public interface CtFor extends CtLoop { diff --git a/src/main/java/spoon/reflect/code/CtForEach.java b/src/main/java/spoon/reflect/code/CtForEach.java index 8ea010b48b5..1c43ba597f3 100644 --- a/src/main/java/spoon/reflect/code/CtForEach.java +++ b/src/main/java/spoon/reflect/code/CtForEach.java @@ -17,8 +17,14 @@ package spoon.reflect.code; /** - * This code element defines a
foreach
loop (enhanced
- * for
).
+ * This code element defines a foreach statement.
+ * Example:
+ * + * java.util.List l = new java.util.ArrayList(); + * for(Object o : l) { // <-- foreach loop + * System.out.println(o); + * } + **/ public interface CtForEach extends CtLoop { /** diff --git a/src/main/java/spoon/reflect/code/CtIf.java b/src/main/java/spoon/reflect/code/CtIf.java index c5d70106b99..c3f66e25e2b 100644 --- a/src/main/java/spoon/reflect/code/CtIf.java +++ b/src/main/java/spoon/reflect/code/CtIf.java @@ -20,6 +20,14 @@ /** * This code element represents an
if
statement.
+ * Example:
+ * + * if (1==0) { + * System.out.println("foo"); + * } else { + * System.out.println("bar"); + * } + **/ public interface CtIf extends CtStatement, TemplateParameter
+ * // invocation of method println + * // the target is "System.out" + * System.out.println("foo"); + *+ * * @param
+ * java.util.List l = new java.util.ArrayList(); + * l.stream().map( + * x -> { return x.toString(); } // a lambda + * ); + *+ * *
+ * int x = 4; // 4 is a literal + *+ * A null literal, as in s = null", is represented by a CtLiteral whose value is null. * * @param
+ * // defines a local variable x + * int x = 0; + *+ * * @param
+ * // inline creation of array content + * int[] x = new int[] { 0, 1, 42} + ** @param
+ * // an anonymous class creation + * Runnable r = new Runnable() { + * @Override + * public void run() { + * System.out.println("foo"); + * } + * }; + ** @param
+ * int x = 0; + * x *= 3; // <-- a CtOperatorAssignment + *+ * */ public interface CtOperatorAssignment
return
statement.
+ *
+ * Example:
+ * + * Runnable r = new Runnable() { + * @Override + * public void run() { + * return; // <-- CtReturn statement + * } + * }; + *+ */ public interface CtReturn
+ * class Foo { int foo() { return 42;}}; + * class Bar extends Foo { + * int foo() { + * return super.foo(); // <-- access to super + * } + * }; + *+ * + * The target is used when one writes `SuperClass.super.foo()`. + * * @param
switch
statement.
+ * This code element defines a switch statement.
*
+ * Example: + * int x = 0; + * switch(x) { // <-- switch statement + * case 1: + * System.out.println("foo"); + * }+ * @param
synchronized
statement.
+ *
+ * Example:
+ * + * java.util.List l = new java.util.ArrayList(); + * synchronized(l) { + * System.out.println("foo"); + * } + **/ public interface CtSynchronized extends CtStatement { /** diff --git a/src/main/java/spoon/reflect/code/CtThisAccess.java b/src/main/java/spoon/reflect/code/CtThisAccess.java index 6d378a2431c..34203b86b06 100644 --- a/src/main/java/spoon/reflect/code/CtThisAccess.java +++ b/src/main/java/spoon/reflect/code/CtThisAccess.java @@ -19,6 +19,16 @@ /** * This code element defines an access to this. * + * Example: + *
+ * class Foo { + * int value = 42; + * int foo() { + * return this.value; // <-- access to this + * } + * }; + + ** @param
throw
statement.
+ *
+ * Example:
+ * + * throw new RuntimeException("oops") + **/ public interface CtThrow extends CtCFlowBreak, TemplateParameter
try
statement.
+ *
+ * Example:
+ * + * try { + * System.out.println("foo"); + * } catch (Exception ignore) {} + **/ public interface CtTry extends CtStatement, TemplateParameter
try
with resource statement.
+ *
+ * Example:
+ * + * // br is the resource + * try (java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("/foo"))) { + * br.readLine(); + * } + **/ public interface CtTryWithResource extends CtTry { diff --git a/src/main/java/spoon/reflect/code/CtTypeAccess.java b/src/main/java/spoon/reflect/code/CtTypeAccess.java index 2f8a0cfe51f..d0c1998ea68 100644 --- a/src/main/java/spoon/reflect/code/CtTypeAccess.java +++ b/src/main/java/spoon/reflect/code/CtTypeAccess.java @@ -22,11 +22,25 @@ * This code element represents a type reference usable as an expression. * It is used in particular for static accesses, Java 8 method references, instanceof binary expressions and ".class". *
- * Type.staticField - * Type.staticMethod() - * Type::method - * t instanceof Type - * Type.class + * // access to static field + * java.io.PrintStream ps = System.out; + *+ *
+ * // call to static method + * Class.forName("Foo") + *+ *
+ * // method reference + * java.util.function.Supplier p = + * Object::new; + *+ *
+ * // instanceof test + * boolean x = new Object() instanceof Integer // Integer is represented as an access to type Integer + *+ *
+ * // fake field "class" + * Class x = Number.class ** * @param diff --git a/src/main/java/spoon/reflect/code/CtUnaryOperator.java b/src/main/java/spoon/reflect/code/CtUnaryOperator.java index ab9370a4704..731f4bee66c 100644 --- a/src/main/java/spoon/reflect/code/CtUnaryOperator.java +++ b/src/main/java/spoon/reflect/code/CtUnaryOperator.java @@ -17,8 +17,12 @@ package spoon.reflect.code; /** - * This code element represents a unary operator. For example : - *
!(true)
, -4
+ * This code element represents a unary operator.
+ * For example :
+ * + * int x=3; + * --x; // <-- unary -- + ** * @param
System.out.println(variable);
+ * + * String variable = ""; + * System.out.println( + * variable // <-- a variable read + * ); + ** * @param
- * variable = "new value"; + * String variable = ""; + * variable = "new value"; // variable write + *+ *
+ * String variable = ""; * variable += ""; ** diff --git a/src/main/java/spoon/reflect/code/CtWhile.java b/src/main/java/spoon/reflect/code/CtWhile.java index 9e7c6197a9c..2074230e7fe 100644 --- a/src/main/java/spoon/reflect/code/CtWhile.java +++ b/src/main/java/spoon/reflect/code/CtWhile.java @@ -18,6 +18,15 @@ /** * This code element defines a
while
loop.
+ *
+ * Example:
+ * + * int x = 0; + * while (x!=10) { + * x=x+1; + * }; + *+ * */ public interface CtWhile extends CtLoop { /** diff --git a/src/main/java/spoon/reflect/declaration/CtAnnotation.java b/src/main/java/spoon/reflect/declaration/CtAnnotation.java index 1ce95e40306..663becdad43 100644 --- a/src/main/java/spoon/reflect/declaration/CtAnnotation.java +++ b/src/main/java/spoon/reflect/declaration/CtAnnotation.java @@ -26,8 +26,13 @@ import java.util.Map; /** - * This element defines an annotation, declared on a given annotated element. + * This element represents an annotation on an element. * + *
+ * // statement annotated by annotation @SuppressWarnings + * @SuppressWarnings("unchecked") + * java.util.List> x = new java.util.ArrayList<>() + ** @param * type of represented annotation */ diff --git a/src/main/java/spoon/reflect/declaration/CtClass.java b/src/main/java/spoon/reflect/declaration/CtClass.java index 38c0e88ce28..0f5fec7e007 100644 --- a/src/main/java/spoon/reflect/declaration/CtClass.java +++ b/src/main/java/spoon/reflect/declaration/CtClass.java @@ -24,6 +24,12 @@ /** * This element represents a class declaration. * + *
+ * // a class definition + * class Foo { + * int x; + * } + ** @author Renaud Pawlak */ public interface CtClass
+ * enum Boolean { TRUE, FALSE } + *+ */ public interface CtEnum