Skip to content

Commit

Permalink
doc: Fix issues related to javadoc in java 8
Browse files Browse the repository at this point in the history
* Javadoc JDK8: start fixing issues #1104

* Fix last javadoc errors for JDK8 #1104

* Fix failing tests in CtComment by decoding html entities in snippets. Add necessary dependency to do that properly. #1104

* Fix the scope of the new dependency
  • Loading branch information
surli authored and tdurieux committed Jan 11, 2017
1 parent 21657c6 commit 9c5af38
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 39 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/spoon/SpoonModelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtArrayRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <pre>
* int[] array = new int[10];
* System.out.println(
* array[0] // <-- array read
* array[0] // &lt;-- array read
* );
* </pre>
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtAssignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Example:
* <pre>
* int x;
* x = 4; // <-- an assignment
* x = 4; // &lt;-- an assignment
* </pre>
* @param <T>
* type of assigned expression
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* statements enclosed in curly brackets.
*
* Example: <pre>
* { // <-- block start
* { // &lt;-- block start
* System.out.println("foo");
* }
* </pre>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/spoon/reflect/code/CtBreak.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* This code element defines a break statement.
* Example:
* <pre>
* for(int i=0; i<10; i++) {
* if (i>3) {
* break; // <-- break statement
* for(int i=0; i&lt;10; i++) {
* if (i&gt;3) {
* break; // &lt;-- break statement
* }
* }
* </pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Example: <pre>
* int x = 0;
* switch(x) {
* case 1: // <-- case statement
* case 1: // &lt;-- case statement
* System.out.println("foo");
* }</pre>
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtConditional.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Example:
* <pre>
* System.out.println(
* 1==0 ? "foo" : "bar" // <-- ternary conditional
* 1==0 ? "foo" : "bar" // &lt;-- ternary conditional
* );
* </pre>
*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/spoon/reflect/code/CtContinue.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* This code element defines the continue statement.
* Example:
* <pre>
* for(int i=0; i<10; i++) {
* if (i>3) {
* continue; // <-- continue statement
* for(int i=0; i&lt;10; i++) {
* if (i&gt;3) {
* continue; // &lt;-- continue statement
* }
* }
* </pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtDo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* int x = 0;
* do {
* x=x+1;
* } while (x<10);
* } while (x&lt;10);
* </pre>
*
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtFor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Example:
* <pre>
* // a for statement
* for(int i=0; i<10; i++) {
* for(int i=0; i&lt;10; i++) {
* System.out.println("foo");
* }
* </pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtForEach.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Example:
* <pre>
* java.util.List l = new java.util.ArrayList();
* for(Object o : l) { // <-- foreach loop
* for(Object o : l) { // &lt;-- foreach loop
* System.out.println(o);
* }
* </pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* <pre>
* java.util.List l = new java.util.ArrayList();
* l.stream().map(
* x -> { return x.toString(); } // a lambda
* x -&gt; { return x.toString(); } // a lambda
* );
* </pre>
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtNewClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* <pre>
* // an anonymous class creation
* Runnable r = new Runnable() {
* @Override
* &#64;Override
* public void run() {
* System.out.println("foo");
* }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtOperatorAssignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Example:
* <pre>
* int x = 0;
* x *= 3; // <-- a CtOperatorAssignment
* x *= 3; // &lt;-- a CtOperatorAssignment
* </pre>
*
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/spoon/reflect/code/CtReturn.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
* Example:
* <pre>
* Runnable r = new Runnable() {
* @Override
* &#64;Override
* public void run() {
* return; // <-- CtReturn statement
* return; // &lt;-- CtReturn statement
* }
* };
* </pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtSuperAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(); // &lt;-- access to super
* }
* };
* </pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtSwitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* Example: <pre>
* int x = 0;
* switch(x) { // <-- switch statement
* switch(x) { // &lt;-- switch statement
* case 1:
* System.out.println("foo");
* }</pre>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtThisAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* class Foo {
* int value = 42;
* int foo() {
* return this.value; // <-- access to this
* return this.value; // &lt;-- access to this
* }
* };
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtUnaryOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* For example :
* <pre>
* int x=3;
* --x; // <-- unary --
* --x; // &lt;-- unary --
* </pre>
*
* @param <T>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/code/CtVariableRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <pre>
* String variable = "";
* System.out.println(
* variable // <-- a variable read
* variable // &lt;-- a variable read
* );
* </pre>
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/spoon/reflect/declaration/CtAnnotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
*
* <pre>
* // statement annotated by annotation @SuppressWarnings
* @SuppressWarnings("unchecked")
* java.util.List<?> x = new java.util.ArrayList<>()
* &#64;SuppressWarnings("unchecked")
* java.util.List&lt;?&gt; x = new java.util.ArrayList&lt;&gt;()
* </pre>
* @param <A>
* type of represented annotation
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/spoon/reflect/factory/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public interface Factory {
<R> CtStatementList createStatementList(CtBlock<R> block);

/**
* @see CodeFactory#createCtBlock(T)
* @see CodeFactory#createCtBlock(CtStatement)
*/
<T extends CtStatement> CtBlock<?> createCtBlock(T element);

Expand Down Expand Up @@ -206,7 +206,7 @@ public interface Factory {
<T> CtInvocation<T> createInvocation(CtExpression<?> target, CtExecutableReference<T> executable, CtExpression<?>... arguments);

/**
* @see CodeFactory#createLiteral(T)
* @see CodeFactory#createLiteral(Object)
*/
<T> CtLiteral<T> createLiteral(T value);

Expand All @@ -216,7 +216,7 @@ public interface Factory {
<T> CtLocalVariable<T> createLocalVariable(CtTypeReference<T> type, String name, CtExpression<T> defaultExpression);

/**
* @see CodeFactory#createLiteralArray(T[])
* @see CodeFactory#createLiteralArray(Object[])
*/
@SuppressWarnings(value = "unchecked")
<T> CtNewArray<T[]> createLiteralArray(T[] value);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/spoon/reflect/visitor/chain/CtFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;T> the type of the input to the function
* @param &lt;R> the type of the result of the function
* @param <T> the type of the input to the function
* @param <R> the type of the result of the function
*/
public interface CtFunction<T, R> {
R apply(T input);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/spoon/reflect/visitor/chain/CtQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*
* The main methods are:
* <ul>
* <li> {@link #map(CtFunction))} - uses a lambda expression to return any model elements that are directly accessible from an input element.
* <li> {@link #filterChildren(Filter))} - uses {@link Filter} instances to filter children of an element
* <li> {@link CtQueryable#map(CtFunction)} - uses a lambda expression to return any model elements that are directly accessible from an input element.
* <li> {@link CtQueryable#filterChildren(Filter)} - uses {@link Filter} instances to filter children of an element
* <li> {@link #list()} - to evaluate the query and return a list of elements produced by this query.
* </ul>
* The query can be used several times.<br>
Expand All @@ -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 &lt;O> the type of the element produced by this query
* @param <O> the type of the element produced by this query
*/
public interface CtQuery<O> extends CtQueryable {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/visitor/chain/CtQueryable.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface CtQueryable {

/**
* Query elements based on a function, the behavior depends on the return type of the function.
* <table>
* <table summary="">
* <tr><td><b>Return type of `function`</b><td><b>Behavior</b>
* <tr><td>{@link Boolean}<td>Select elements if thereturned value of `function` is true (as for {@link Filter}).
* <tr><td>? extends {@link Object}<td>Send the returned value of `function` to the next step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @param <T>
* 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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" -&gt; "1")
* This visitor implements a simple partial evaluator for the program
* compile-time metamodel.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/spoon/test/comment/CommentTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -626,6 +627,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();
Expand Down

0 comments on commit 9c5af38

Please sign in to comment.