diff --git a/pom.xml b/pom.xml index d69c308d3b3..8a323f24a6c 100644 --- a/pom.xml +++ b/pom.xml @@ -241,6 +241,12 @@ commons-io 1.4 + + org.apache.commons + commons-lang3 + 3.5 + test + diff --git a/src/main/java/spoon/SpoonModelBuilder.java b/src/main/java/spoon/SpoonModelBuilder.java index 4b8509e15fa..3ef39d191f5 100644 --- a/src/main/java/spoon/SpoonModelBuilder.java +++ b/src/main/java/spoon/SpoonModelBuilder.java @@ -81,8 +81,8 @@ public interface SpoonModelBuilder { boolean build(JDTBuilder builder); /** The types of compilable elements - * FILES - compiles the java files from the file system, which were registered by {@see SpoonModelBuilder#addInputSource()} and {@see SpoonModelBuilder#addTemplateSource(File)} - * CTTYPES - compiles virtual java files, which are dynamically generated from the all top level classes of the CtModel by {@see DefaultJavaPrettyPrinter} + * FILES - compiles the java files from the file system, which were registered by {@link #addInputSource(File)} and {@link #addTemplateSource(File)} + * CTTYPES - compiles virtual java files, which are dynamically generated from the all top level classes of the CtModel by {@link spoon.reflect.visitor.DefaultJavaPrettyPrinter} */ interface InputType { InputType FILES = FileCompilerConfig.INSTANCE; diff --git a/src/main/java/spoon/reflect/code/CtArrayRead.java b/src/main/java/spoon/reflect/code/CtArrayRead.java index 149785e525d..f8fea043628 100644 --- a/src/main/java/spoon/reflect/code/CtArrayRead.java +++ b/src/main/java/spoon/reflect/code/CtArrayRead.java @@ -23,7 +23,7 @@ *
  *     int[] array = new int[10];
  *     System.out.println(
- *     array[0] // <-- array read
+ *     array[0] // <-- array read
  *     );
  * 
* diff --git a/src/main/java/spoon/reflect/code/CtAssignment.java b/src/main/java/spoon/reflect/code/CtAssignment.java index f1522e22306..879ad090150 100644 --- a/src/main/java/spoon/reflect/code/CtAssignment.java +++ b/src/main/java/spoon/reflect/code/CtAssignment.java @@ -22,7 +22,7 @@ * Example: *
  *     int x;
- *     x = 4; // <-- an assignment
+ *     x = 4; // <-- an assignment
  * 
* @param * type of assigned expression diff --git a/src/main/java/spoon/reflect/code/CtBlock.java b/src/main/java/spoon/reflect/code/CtBlock.java index 7f3686cb6fc..a2e0110b447 100644 --- a/src/main/java/spoon/reflect/code/CtBlock.java +++ b/src/main/java/spoon/reflect/code/CtBlock.java @@ -24,7 +24,7 @@ * statements enclosed in curly brackets. * * Example:
- *  { // <-- block start
+ *  { // <-- block start
  *   System.out.println("foo");
  *  }
  *	
diff --git a/src/main/java/spoon/reflect/code/CtBreak.java b/src/main/java/spoon/reflect/code/CtBreak.java index 7ce7f8c3e35..925b5c72421 100644 --- a/src/main/java/spoon/reflect/code/CtBreak.java +++ b/src/main/java/spoon/reflect/code/CtBreak.java @@ -20,9 +20,9 @@ * This code element defines a break statement. * Example: *
- *     for(int i=0; i<10; i++) {
- *         if (i>3) {
- *				break; // <-- break statement
+ *     for(int i=0; i<10; i++) {
+ *         if (i>3) {
+ *				break; // <-- break statement
  *         }
  *     }
  * 
diff --git a/src/main/java/spoon/reflect/code/CtCase.java b/src/main/java/spoon/reflect/code/CtCase.java index 4fad6e7a561..50d654c4943 100644 --- a/src/main/java/spoon/reflect/code/CtCase.java +++ b/src/main/java/spoon/reflect/code/CtCase.java @@ -22,7 +22,7 @@ * Example:
  * int x = 0;
  * switch(x) {
- *     case 1: // <-- case statement
+ *     case 1: // <-- case statement
  *       System.out.println("foo");
  * }
* diff --git a/src/main/java/spoon/reflect/code/CtConditional.java b/src/main/java/spoon/reflect/code/CtConditional.java index f3484bba0b1..e527ed34b7e 100644 --- a/src/main/java/spoon/reflect/code/CtConditional.java +++ b/src/main/java/spoon/reflect/code/CtConditional.java @@ -22,7 +22,7 @@ * Example: *
  *     System.out.println(
- *        1==0 ? "foo" : "bar" // <-- ternary conditional
+ *        1==0 ? "foo" : "bar" // <-- ternary conditional
  *     );
  * 
*/ diff --git a/src/main/java/spoon/reflect/code/CtContinue.java b/src/main/java/spoon/reflect/code/CtContinue.java index 44900a1c195..b4b559cee21 100644 --- a/src/main/java/spoon/reflect/code/CtContinue.java +++ b/src/main/java/spoon/reflect/code/CtContinue.java @@ -20,9 +20,9 @@ * This code element defines the continue statement. * Example: *
- *     for(int i=0; i<10; i++) {
- *         if (i>3) {
- *				continue; // <-- continue statement
+ *     for(int i=0; i<10; i++) {
+ *         if (i>3) {
+ *				continue; // <-- continue statement
  *         }
  *     }
  * 
diff --git a/src/main/java/spoon/reflect/code/CtDo.java b/src/main/java/spoon/reflect/code/CtDo.java index ca4d7edaadd..88556c7573f 100644 --- a/src/main/java/spoon/reflect/code/CtDo.java +++ b/src/main/java/spoon/reflect/code/CtDo.java @@ -24,7 +24,7 @@ * int x = 0; * do { * x=x+1; - * } while (x<10); + * } while (x<10); * * */ diff --git a/src/main/java/spoon/reflect/code/CtFor.java b/src/main/java/spoon/reflect/code/CtFor.java index daa0711d3b1..227edeea41d 100644 --- a/src/main/java/spoon/reflect/code/CtFor.java +++ b/src/main/java/spoon/reflect/code/CtFor.java @@ -23,7 +23,7 @@ * Example: *
  *     // a for statement
- *     for(int i=0; i<10; i++) {
+ *     for(int i=0; i<10; i++) {
  *     	System.out.println("foo");
  *     }
  * 
diff --git a/src/main/java/spoon/reflect/code/CtForEach.java b/src/main/java/spoon/reflect/code/CtForEach.java index 1c43ba597f3..71083246d5f 100644 --- a/src/main/java/spoon/reflect/code/CtForEach.java +++ b/src/main/java/spoon/reflect/code/CtForEach.java @@ -21,7 +21,7 @@ * Example: *
  *     java.util.List l = new java.util.ArrayList();
- *     for(Object o : l) { // <-- foreach loop
+ *     for(Object o : l) { // <-- foreach loop
  *     	System.out.println(o);
  *     }
  * 
diff --git a/src/main/java/spoon/reflect/code/CtLambda.java b/src/main/java/spoon/reflect/code/CtLambda.java index 9cbebf9f3d3..acc52600212 100644 --- a/src/main/java/spoon/reflect/code/CtLambda.java +++ b/src/main/java/spoon/reflect/code/CtLambda.java @@ -30,7 +30,7 @@ *
  *     java.util.List l = new java.util.ArrayList();
  *     l.stream().map(
- *       x -> { return x.toString(); } // a lambda
+ *       x -> { return x.toString(); } // a lambda
  *     );
  * 
* diff --git a/src/main/java/spoon/reflect/code/CtNewClass.java b/src/main/java/spoon/reflect/code/CtNewClass.java index 63bfcb0fa9e..29dbda07aef 100644 --- a/src/main/java/spoon/reflect/code/CtNewClass.java +++ b/src/main/java/spoon/reflect/code/CtNewClass.java @@ -31,7 +31,7 @@ *
  *    // an anonymous class creation
  *    Runnable r = new Runnable() {
- *     	@Override
+ *     	@Override
  *     	public void run() {
  *     	  System.out.println("foo");
  *     	}
diff --git a/src/main/java/spoon/reflect/code/CtOperatorAssignment.java b/src/main/java/spoon/reflect/code/CtOperatorAssignment.java
index 433e424d37d..0135d7c3c6b 100644
--- a/src/main/java/spoon/reflect/code/CtOperatorAssignment.java
+++ b/src/main/java/spoon/reflect/code/CtOperatorAssignment.java
@@ -22,7 +22,7 @@
  * Example:
  * 
  *     int x = 0;
- *     x *= 3; // <-- a CtOperatorAssignment
+ *     x *= 3; // <-- a CtOperatorAssignment
  * 
* */ diff --git a/src/main/java/spoon/reflect/code/CtReturn.java b/src/main/java/spoon/reflect/code/CtReturn.java index fe1b6cdaea6..7ba1e65cd69 100644 --- a/src/main/java/spoon/reflect/code/CtReturn.java +++ b/src/main/java/spoon/reflect/code/CtReturn.java @@ -24,9 +24,9 @@ * Example: *
  *    Runnable r = new Runnable() {
- *     	@Override
+ *     	@Override
  *     	public void run() {
- *     	  return; // <-- CtReturn statement
+ *     	  return; // <-- CtReturn statement
  *     	}
  *    };
  * 
diff --git a/src/main/java/spoon/reflect/code/CtSuperAccess.java b/src/main/java/spoon/reflect/code/CtSuperAccess.java index a81774177f2..36cb43083a7 100644 --- a/src/main/java/spoon/reflect/code/CtSuperAccess.java +++ b/src/main/java/spoon/reflect/code/CtSuperAccess.java @@ -27,7 +27,7 @@ * class Foo { int foo() { return 42;}}; * class Bar extends Foo { * int foo() { - * return super.foo(); // <-- access to super + * return super.foo(); // <-- access to super * } * }; *
diff --git a/src/main/java/spoon/reflect/code/CtSwitch.java b/src/main/java/spoon/reflect/code/CtSwitch.java index b32842acc50..94e76109302 100644 --- a/src/main/java/spoon/reflect/code/CtSwitch.java +++ b/src/main/java/spoon/reflect/code/CtSwitch.java @@ -23,7 +23,7 @@ * * Example:
  * int x = 0;
- * switch(x) { // <-- switch statement
+ * switch(x) { // <-- switch statement
  *     case 1:
  *       System.out.println("foo");
  * }
diff --git a/src/main/java/spoon/reflect/code/CtThisAccess.java b/src/main/java/spoon/reflect/code/CtThisAccess.java index 34203b86b06..7e2e3bb9652 100644 --- a/src/main/java/spoon/reflect/code/CtThisAccess.java +++ b/src/main/java/spoon/reflect/code/CtThisAccess.java @@ -24,7 +24,7 @@ * class Foo { * int value = 42; * int foo() { - * return this.value; // <-- access to this + * return this.value; // <-- access to this * } * }; diff --git a/src/main/java/spoon/reflect/code/CtUnaryOperator.java b/src/main/java/spoon/reflect/code/CtUnaryOperator.java index 731f4bee66c..79cdebddb94 100644 --- a/src/main/java/spoon/reflect/code/CtUnaryOperator.java +++ b/src/main/java/spoon/reflect/code/CtUnaryOperator.java @@ -21,7 +21,7 @@ * For example : *
  *     int x=3;
- *     --x; // <-- unary --
+ *     --x; // <-- unary --
  * 
* * @param diff --git a/src/main/java/spoon/reflect/code/CtVariableRead.java b/src/main/java/spoon/reflect/code/CtVariableRead.java index ce2e3b3f6fc..f49cbd76d37 100644 --- a/src/main/java/spoon/reflect/code/CtVariableRead.java +++ b/src/main/java/spoon/reflect/code/CtVariableRead.java @@ -23,7 +23,7 @@ *
  *     String variable = "";
  *     System.out.println(
- *       variable // <-- a variable read
+ *       variable // <-- a variable read
  *     );
  * 
* diff --git a/src/main/java/spoon/reflect/declaration/CtAnnotation.java b/src/main/java/spoon/reflect/declaration/CtAnnotation.java index a3817656b6f..31dd9cb0a76 100644 --- a/src/main/java/spoon/reflect/declaration/CtAnnotation.java +++ b/src/main/java/spoon/reflect/declaration/CtAnnotation.java @@ -33,8 +33,8 @@ * *
  *     // statement annotated by annotation @SuppressWarnings
- *     @SuppressWarnings("unchecked")
- *     java.util.List x = new java.util.ArrayList<>()
+ *     @SuppressWarnings("unchecked")
+ *     java.util.List<?> x = new java.util.ArrayList<>()
  * 
* @param * type of represented annotation diff --git a/src/main/java/spoon/reflect/factory/Factory.java b/src/main/java/spoon/reflect/factory/Factory.java index 06305f93ecd..ee78d295402 100644 --- a/src/main/java/spoon/reflect/factory/Factory.java +++ b/src/main/java/spoon/reflect/factory/Factory.java @@ -166,7 +166,7 @@ public interface Factory { CtStatementList createStatementList(CtBlock block); /** - * @see CodeFactory#createCtBlock(T) + * @see CodeFactory#createCtBlock(CtStatement) */ CtBlock createCtBlock(T element); @@ -206,7 +206,7 @@ public interface Factory { CtInvocation createInvocation(CtExpression target, CtExecutableReference executable, CtExpression... arguments); /** - * @see CodeFactory#createLiteral(T) + * @see CodeFactory#createLiteral(Object) */ CtLiteral createLiteral(T value); @@ -216,7 +216,7 @@ public interface Factory { CtLocalVariable createLocalVariable(CtTypeReference type, String name, CtExpression defaultExpression); /** - * @see CodeFactory#createLiteralArray(T[]) + * @see CodeFactory#createLiteralArray(Object[]) */ @SuppressWarnings(value = "unchecked") CtNewArray createLiteralArray(T[] value); diff --git a/src/main/java/spoon/reflect/visitor/chain/CtFunction.java b/src/main/java/spoon/reflect/visitor/chain/CtFunction.java index 9fdc5e2d93e..c807c8d856c 100644 --- a/src/main/java/spoon/reflect/visitor/chain/CtFunction.java +++ b/src/main/java/spoon/reflect/visitor/chain/CtFunction.java @@ -21,8 +21,8 @@ * It is used in the query stack, for example by {@link CtQueryable#map(CtFunction)} * Compatible with Java 8 lambdas, hence enable to write queries with lambdas. * - * @param <T> the type of the input to the function - * @param <R> the type of the result of the function + * @param the type of the input to the function + * @param the type of the result of the function */ public interface CtFunction { R apply(T input); diff --git a/src/main/java/spoon/reflect/visitor/chain/CtQuery.java b/src/main/java/spoon/reflect/visitor/chain/CtQuery.java index 3eb6d6ff092..fa98e07fc90 100644 --- a/src/main/java/spoon/reflect/visitor/chain/CtQuery.java +++ b/src/main/java/spoon/reflect/visitor/chain/CtQuery.java @@ -29,8 +29,8 @@ * * The main methods are: *
    - *
  • {@link #map(CtFunction))} - uses a lambda expression to return any model elements that are directly accessible from an input element. - *
  • {@link #filterChildren(Filter))} - uses {@link Filter} instances to filter children of an element + *
  • {@link CtQueryable#map(CtFunction)} - uses a lambda expression to return any model elements that are directly accessible from an input element. + *
  • {@link CtQueryable#filterChildren(Filter)} - uses {@link Filter} instances to filter children of an element *
  • {@link #list()} - to evaluate the query and return a list of elements produced by this query. *
* The query can be used several times.
@@ -39,7 +39,7 @@ * However, reusing a {@link CtQuery} instance makes sense when the same query has to be evaluated * several times in a loop. * - * @param <O> the type of the element produced by this query + * @param the type of the element produced by this query */ public interface CtQuery extends CtQueryable { diff --git a/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java b/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java index aa0b17332f3..8108a68b0ad 100644 --- a/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java +++ b/src/main/java/spoon/reflect/visitor/chain/CtQueryable.java @@ -29,7 +29,7 @@ public interface CtQueryable { /** * Query elements based on a function, the behavior depends on the return type of the function. - * + *
*
Return type of `function`Behavior *
{@link Boolean}Select elements if thereturned value of `function` is true (as for {@link Filter}). *
? extends {@link Object}Send the returned value of `function` to the next step diff --git a/src/main/java/spoon/reflect/visitor/filter/AbstractReferenceFilter.java b/src/main/java/spoon/reflect/visitor/filter/AbstractReferenceFilter.java index 23677dd7427..3c46623d33a 100644 --- a/src/main/java/spoon/reflect/visitor/filter/AbstractReferenceFilter.java +++ b/src/main/java/spoon/reflect/visitor/filter/AbstractReferenceFilter.java @@ -25,7 +25,7 @@ * * @param * the type of the reference to be matched - * @see spoon.reflect.visitor.ReferenceFilter#matches(CtReference) + * @see spoon.reflect.visitor.Filter * * @deprecated use {@link AbstractFilter} instead. */ diff --git a/src/main/java/spoon/support/reflect/eval/VisitorPartialEvaluator.java b/src/main/java/spoon/support/reflect/eval/VisitorPartialEvaluator.java index 8b884322ead..7215954c67e 100644 --- a/src/main/java/spoon/support/reflect/eval/VisitorPartialEvaluator.java +++ b/src/main/java/spoon/support/reflect/eval/VisitorPartialEvaluator.java @@ -58,7 +58,7 @@ /** * - * Simplifies an AST by performing all operations that are statically known and changes the AST accordingly (eg "0+1" -> "1") + * Simplifies an AST by performing all operations that are statically known and changes the AST accordingly (eg "0+1" -> "1") * This visitor implements a simple partial evaluator for the program * compile-time metamodel. */ diff --git a/src/test/java/spoon/test/comment/CommentTest.java b/src/test/java/spoon/test/comment/CommentTest.java index c4b19712cd3..1ae0becb803 100644 --- a/src/test/java/spoon/test/comment/CommentTest.java +++ b/src/test/java/spoon/test/comment/CommentTest.java @@ -1,6 +1,7 @@ package spoon.test.comment; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringEscapeUtils; import org.junit.Test; import spoon.Launcher; import spoon.reflect.code.CtComment; @@ -606,6 +607,7 @@ public boolean matches(CtElement element) { m.find(); do { String snippet = m.group(1); + snippet = StringEscapeUtils.unescapeHtml4(snippet); // it must compile CtElement el = launcher.getFactory().Code().createCodeSnippetStatement(snippet).compile();