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 extends CtStatement { /** diff --git a/src/main/java/spoon/reflect/code/CtAssignment.java b/src/main/java/spoon/reflect/code/CtAssignment.java index 6c8b660fe83..f1522e22306 100644 --- a/src/main/java/spoon/reflect/code/CtAssignment.java +++ b/src/main/java/spoon/reflect/code/CtAssignment.java @@ -19,6 +19,11 @@ /** * This code element defines an assignment. * + * Example: + *
+ *     int x;
+ *     x = 4; // <-- an assignment
+ * 
* @param * type of assigned expression * @param diff --git a/src/main/java/spoon/reflect/code/CtBinaryOperator.java b/src/main/java/spoon/reflect/code/CtBinaryOperator.java index 0d6d7c7aaa6..804ea22791e 100644 --- a/src/main/java/spoon/reflect/code/CtBinaryOperator.java +++ b/src/main/java/spoon/reflect/code/CtBinaryOperator.java @@ -19,6 +19,11 @@ /** * This interface defines a binary operator. * + * Example: + *
+ *     // 3+4 is the binary expression
+ *     int x = 3 + 4;
+ * 
* @param * Type of this expression */ diff --git a/src/main/java/spoon/reflect/code/CtBlock.java b/src/main/java/spoon/reflect/code/CtBlock.java index 752f812168e..7f3686cb6fc 100644 --- a/src/main/java/spoon/reflect/code/CtBlock.java +++ b/src/main/java/spoon/reflect/code/CtBlock.java @@ -21,9 +21,17 @@ /** * This code element represents a block of code, that is to say a list of - * statements enclosed in curly brackets. When the context calls for a return + * statements enclosed in curly brackets. + * + * Example:
+ *  { // <-- 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 CtBlock extends CtStatement, CtStatementList, TemplateParameter { diff --git a/src/main/java/spoon/reflect/code/CtBreak.java b/src/main/java/spoon/reflect/code/CtBreak.java index 902e04e9d63..7ce7f8c3e35 100644 --- a/src/main/java/spoon/reflect/code/CtBreak.java +++ b/src/main/java/spoon/reflect/code/CtBreak.java @@ -17,7 +17,15 @@ package spoon.reflect.code; /** - * This code element defines a break 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 * This type must be assignable from the switch type diff --git a/src/main/java/spoon/reflect/code/CtComment.java b/src/main/java/spoon/reflect/code/CtComment.java index cde8807e645..6ccf0a3caef 100644 --- a/src/main/java/spoon/reflect/code/CtComment.java +++ b/src/main/java/spoon/reflect/code/CtComment.java @@ -19,6 +19,11 @@ /** * This code element defines a comment * + * Example: + * + * 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 extends CtExpression { diff --git a/src/main/java/spoon/reflect/code/CtConstructorCall.java b/src/main/java/spoon/reflect/code/CtConstructorCall.java index bbd50341e60..d8f5f2f3031 100644 --- a/src/main/java/spoon/reflect/code/CtConstructorCall.java +++ b/src/main/java/spoon/reflect/code/CtConstructorCall.java @@ -25,6 +25,9 @@ /** * This code element represents a constructor call. * + * Example:
+ *     new Object();
+ * 
* @param * created type */ diff --git a/src/main/java/spoon/reflect/code/CtContinue.java b/src/main/java/spoon/reflect/code/CtContinue.java index ef7e4610adb..44900a1c195 100644 --- a/src/main/java/spoon/reflect/code/CtContinue.java +++ b/src/main/java/spoon/reflect/code/CtContinue.java @@ -17,7 +17,15 @@ package spoon.reflect.code; /** - * This code element defines the 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 * Each executable references are typed by an interface with one method. This generic type diff --git a/src/main/java/spoon/reflect/code/CtFieldRead.java b/src/main/java/spoon/reflect/code/CtFieldRead.java index 059aa70421e..0393593b085 100644 --- a/src/main/java/spoon/reflect/code/CtFieldRead.java +++ b/src/main/java/spoon/reflect/code/CtFieldRead.java @@ -20,7 +20,11 @@ * This code element defines an read access to a field. * * In Java, it is a usage of a field outside an assignment. For example, - * 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 { diff --git a/src/main/java/spoon/reflect/code/CtInvocation.java b/src/main/java/spoon/reflect/code/CtInvocation.java index e7eea523c35..a0f3ad257fd 100644 --- a/src/main/java/spoon/reflect/code/CtInvocation.java +++ b/src/main/java/spoon/reflect/code/CtInvocation.java @@ -25,6 +25,13 @@ /** * This code element defines a concrete invocation. * + * Example: + *
+ *     // invocation of method println
+ *     // the target is "System.out"
+ *     System.out.println("foo");
+ * 
+ * * @param * Return type of this invocation */ diff --git a/src/main/java/spoon/reflect/code/CtLambda.java b/src/main/java/spoon/reflect/code/CtLambda.java index 5c7f6f75e8f..20105481467 100644 --- a/src/main/java/spoon/reflect/code/CtLambda.java +++ b/src/main/java/spoon/reflect/code/CtLambda.java @@ -23,6 +23,13 @@ * can have two sorts of body : an simple expression or a block of * statements. The usage of this concept in this class is: * + *
+ *     java.util.List l = new java.util.ArrayList();
+ *     l.stream().map(
+ *       x -> { return x.toString(); } // a lambda
+ *     );
+ * 
+ * *