diff --git a/src/main/java/spoon/reflect/code/CtCodeElement.java b/src/main/java/spoon/reflect/code/CtCodeElement.java index 617359c8de3..4164625ca2c 100644 --- a/src/main/java/spoon/reflect/code/CtCodeElement.java +++ b/src/main/java/spoon/reflect/code/CtCodeElement.java @@ -17,9 +17,10 @@ public interface CtCodeElement extends CtElement { /** * Partially evaluates an element and all its sub-elements. * - * @param - * the returned element - * @return the result of the partial evaluation + * @param the type of the returned element + * @return the result of the partial evaluation. + * The element is always cloned, even if nothing has been evaluated. + * @see spoon.support.reflect.eval.VisitorPartialEvaluator */ R partiallyEvaluate(); diff --git a/src/main/java/spoon/reflect/code/CtIf.java b/src/main/java/spoon/reflect/code/CtIf.java index efd6bb8d513..2c0fde27b86 100644 --- a/src/main/java/spoon/reflect/code/CtIf.java +++ b/src/main/java/spoon/reflect/code/CtIf.java @@ -16,7 +16,7 @@ import static spoon.reflect.path.CtRole.THEN; /** - * This code element represents an if statement. + * This code element represents an {@code if} statement. * Example: *
  *     if (1==0) {
@@ -29,7 +29,7 @@
 public interface CtIf extends CtStatement, TemplateParameter {
 
 	/**
-	 * Gets the boolean expression that represents the if's
+	 * Gets the boolean expression that represents the {@code if}'s
 	 * condition.
 	 */
 	@PropertyGetter(role = CONDITION)
@@ -37,18 +37,49 @@ public interface CtIf extends CtStatement, TemplateParameter {
 
 	/**
 	 * Gets the statement executed when the condition is false.
+	 * 

+ * An {@code else if} like + *

+	 *     if (a) {
+	 *         doA();
+	 *     } else if (b) {
+	 *         doB();
+	 *     } else {
+	 *         doC();
+	 *     }
+	 * 
+ * will be represented as + *
+	 *     if (a) {
+	 *         doA();
+	 *     } else {
+	 *         if (b) {
+	 *             doB();
+	 *         } else {
+	 *             doC();
+	 *         }
+	 *     }
+	 * 
+ * To differentiate between an {@code else} Block with an {@code if} and an {@code else if}, + * {@link CtBlock#isImplicit()} is set to {@code true}. + * + * @return the statement of the {@code else} or {@code null} if no else is specified. */ @PropertyGetter(role = ELSE) S getElseStatement(); /** * Gets the statement executed when the condition is true. + *

+ * This method will return {@code null} for {@code if (condition);}. + * + * @return the statement of the {@code if}, in most cases this is a {@link CtBlock}. */ @PropertyGetter(role = THEN) S getThenStatement(); /** - * Sets the boolean expression that represents the if's + * Sets the boolean expression that represents the {@code if}'s * condition. */ @PropertySetter(role = CONDITION) diff --git a/src/main/java/spoon/reflect/code/CtVariableWrite.java b/src/main/java/spoon/reflect/code/CtVariableWrite.java index 2e700ec6ab5..8a2e15756ff 100644 --- a/src/main/java/spoon/reflect/code/CtVariableWrite.java +++ b/src/main/java/spoon/reflect/code/CtVariableWrite.java @@ -9,9 +9,9 @@ /** * This code element defines a write to a variable. - * - * In Java, it is a usage of a variable inside an assignment. - * + *

+ * A variable-write is an assignment to a variable. + *

* For example: *

  *     String variable = "";
@@ -23,8 +23,9 @@
  * 
* * - * @param - * type of the variable + * @param type of the variable + * @see CtAssignment#getAssigned() + * @see CtArrayWrite */ public interface CtVariableWrite extends CtVariableAccess { @Override diff --git a/src/main/java/spoon/reflect/declaration/CtTypeInformation.java b/src/main/java/spoon/reflect/declaration/CtTypeInformation.java index cd559580e92..7b06b69f355 100644 --- a/src/main/java/spoon/reflect/declaration/CtTypeInformation.java +++ b/src/main/java/spoon/reflect/declaration/CtTypeInformation.java @@ -21,12 +21,11 @@ import static spoon.reflect.path.CtRole.SUPER_TYPE; /** - * Returns information that can be obtained both at compile-time and run-time + * Returns information that can be obtained both at compile-time and run-time. * - * For CtElement, the compile-time information is given - * - * For CtTypeReference, the runtime information is given (using the Reflection API) + * For {@link CtElement}, the compile-time information is given. * + * For {@link CtTypeReference}, the runtime information is given (using the Reflection API) */ public interface CtTypeInformation { /** @@ -49,21 +48,37 @@ public interface CtTypeInformation { Set getModifiers(); /** - * Return {@code true} if the referenced type is a primitive type (int, - * double, boolean...). + * Checks if the referenced type is a primitive type. + *

+ * It is a primitive type, if it is one of the following types: + *

    + *
  • byte
  • + *
  • short
  • + *
  • int
  • + *
  • long
  • + *
  • float
  • + *
  • double
  • + *
  • boolean
  • + *
  • char
  • + *
  • void
  • + *
+ *

+ * For boxed types like {@link Integer} this method returns {@code false}. + * + * @return {@code true} if the referenced type is a primitive type */ boolean isPrimitive(); /** - * Return {@code true} if the referenced type is a anonymous type + * Return {@code true} if the referenced type is an anonymous type */ boolean isAnonymous(); /** - * Return {@code true} if the referenced type is declared in an executable. + * Returns {@code true} if the referenced type is declared in an executable. * e.g. a type declared in a method or a lambda. * - * This corresponds to isLocalClass of java.lang.Class. + * This corresponds to {@code isLocalClass} of {@code java.lang.Class}. * *

 	 *     // Type declared in a method.
@@ -115,18 +130,26 @@ public interface CtTypeInformation {
 	boolean isParameterized();
 
 	/**
-	 * Returns true if the referenced type is a sub-type of the given type.
-	 * Returns true is type is self, it means: typeX.isSubtypeOf(typeX) is true too
+	 * Checks if this type is a subtype of the given type.
+	 *
+	 * @param type the type that might be a parent of this type.
+	 * @return {@code true} if the referenced type is a subtype of the given type, otherwise {@code false}.
+	 *         If this type is the same as the given type ({@code typeX.isSubtypeOf(typeX)}),
+	 *         this method returns {@code true}.
 	 */
 	boolean isSubtypeOf(CtTypeReference type);
 
 	/**
-	 * Returns the class type directly extended by this class.
-	 *
-	 * getSuperClass().getDeclaration()/getTypeDeclaration() returns the corresponding CtType (if in the source folder of Spoon).
+	 * Returns a reference to the type directly extended by this type.
+	 * 

+ * To get the {@link CtType} of the super class, use {@link CtTypeReference#getDeclaration()} + * or {@link CtTypeReference#getTypeDeclaration()} on the {@link CtTypeReference} returned by this method. * - * @return the class type directly extended by this class, or null if there - * is none or if the super class is not in the classpath (in noclasspath mode) + * @return the type explicitly extended by this type, or {@code null} if there + * is none or if the super type is not in the classpath (in noclasspath mode). + * If a class does not explicitly extend another class {@code null} is returned (not {@link Object}). + * For types like enums that implicitly extend a superclass like {@link Enum}, this method returns + * that class. */ @PropertyGetter(role = SUPER_TYPE) CtTypeReference getSuperclass(); @@ -147,14 +170,14 @@ public interface CtTypeInformation { /** * Gets a field from its name. * - * @return null if does not exit + * @return a reference to the field with the name or {@code null} if it does not exist */ CtFieldReference getDeclaredField(String name); /** * Gets a field from this type or any super type or any implemented interface by field name. * - * @return null if does not exit + * @return a reference to the field with the name or {@code null} if it does not exist */ CtFieldReference getDeclaredOrInheritedField(String fieldName); @@ -180,15 +203,23 @@ public interface CtTypeInformation { Collection> getAllExecutables(); /** - * @return the type erasure, which is computed by the java compiler to ensure that no new classes are created for parametrized types so that generics incur no runtime overhead. - * See https://docs.oracle.com/javase/tutorial/java/generics/erasure.html + * This method returns a reference to the erased type. + *

+ * For example, this will return {@code List} for {@code List}, + * or {@code Enum} for the type parameter {@code E} in the enum + * declaration. + * + * @return a reference to the erased type + * @see Type Erasure */ @DerivedProperty CtTypeReference getTypeErasure(); /** - * @return true if this represents an array e.g. Object[] or int[] + * Returns true if this type represents an array like {@code Object[]} or {@code int[]}. + * + * @return true if this type represents an array like {@code Object[]} or {@code int[]} */ boolean isArray(); } diff --git a/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java b/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java index 0c5f9c0b72e..a16f4fa29ee 100644 --- a/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java +++ b/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java @@ -20,6 +20,8 @@ * * * The main methods are documented in CtQuery + *

+ * You might want to use {@link Filter} with {@link CtElement#getElements(Filter)} instead. */ public interface CtQueryable {