Skip to content

Commit

Permalink
fix(scanner): add missing scan properties based on a new powerful spe…
Browse files Browse the repository at this point in the history
…cification
  • Loading branch information
monperrus committed Nov 12, 2016
1 parent ee2ca24 commit 752f0d0
Show file tree
Hide file tree
Showing 54 changed files with 631 additions and 82 deletions.
7 changes: 7 additions & 0 deletions src/main/java/spoon/reflect/code/CtCatchVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import spoon.reflect.declaration.CtMultiTypedElement;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.support.DerivedProperty;
import spoon.support.UnsettableProperty;

/**
* This code element defines an exception variable in a catch.
Expand All @@ -33,8 +35,13 @@ public interface CtCatchVariable<T> extends CtVariable<T>, CtMultiTypedElement,
*
* @see spoon.reflect.declaration.CtNamedElement#getReference()
*/
@DerivedProperty
CtCatchVariableReference<T> getReference();

@Override
CtCatchVariable<T> clone();

@Override
@UnsettableProperty
<C extends CtVariable<T>> C setDefaultExpression(CtExpression<T> assignedExpression);
}
2 changes: 2 additions & 0 deletions src/main/java/spoon/reflect/code/CtConstructorCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import spoon.reflect.reference.CtActualTypeContainer;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;

import java.util.List;

Expand All @@ -38,6 +39,7 @@ public interface CtConstructorCall<T> extends CtTargetedExpression<T, CtExpressi
* @see CtExecutableReference#getActualTypeArguments()
*/
@Override
@DerivedProperty
List<CtTypeReference<?>> getActualTypeArguments();

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/code/CtInvocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import spoon.reflect.reference.CtActualTypeContainer;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;

import java.util.List;

Expand All @@ -42,6 +43,7 @@ public interface CtInvocation<T> extends CtAbstractInvocation<T>, CtStatement, C
* @see CtExecutableReference#getActualTypeArguments()
*/
@Override
@DerivedProperty
List<CtTypeReference<?>> getActualTypeArguments();

/**
Expand All @@ -66,6 +68,7 @@ public interface CtInvocation<T> extends CtAbstractInvocation<T>, CtStatement, C
* the actual type bound to this particular invocation.
*/
@Override
@DerivedProperty
CtTypeReference<T> getType();

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/spoon/reflect/code/CtLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
package spoon.reflect.code;

import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.UnsettableProperty;

import java.util.Set;

/**
* This code element represents the creation of a lambda. A lambda
Expand Down Expand Up @@ -63,4 +67,8 @@ public interface CtLambda<T> extends CtExpression<T>, CtExecutable<T> {

@Override
CtLambda<T> clone();

@Override
@UnsettableProperty
<T1 extends CtExecutable<T>> T1 setThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes);
}
9 changes: 9 additions & 0 deletions src/main/java/spoon/reflect/code/CtLocalVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import spoon.reflect.declaration.CtVariable;
import spoon.reflect.reference.CtLocalVariableReference;
import spoon.support.DerivedProperty;

/**
* This code element defines a local variable definition (within an executable
Expand All @@ -39,8 +40,16 @@ public interface CtLocalVariable<T> extends CtStatement, CtVariable<T>, CtRHSRec
*
* @see spoon.reflect.declaration.CtNamedElement#getReference()
*/
@DerivedProperty
CtLocalVariableReference<T> getReference();

/**
* Useful proxy to {@link #getDefaultExpression()}.
*/
@Override
@DerivedProperty
CtExpression<T> getAssignment();

@Override
CtLocalVariable<T> clone();
}
2 changes: 2 additions & 0 deletions src/main/java/spoon/reflect/code/CtNewClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import spoon.reflect.reference.CtActualTypeContainer;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;

import java.util.List;

Expand All @@ -46,6 +47,7 @@ public interface CtNewClass<T> extends CtConstructorCall<T> {
* @see CtExecutableReference#getActualTypeArguments()
*/
@Override
@DerivedProperty
List<CtTypeReference<?>> getActualTypeArguments();

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/spoon/reflect/code/CtRHSReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package spoon.reflect.code;

import spoon.reflect.declaration.CtField;
import spoon.support.DerivedProperty;

/**
* Represents the right hand side of an assignment
Expand All @@ -27,6 +28,7 @@ public interface CtRHSReceiver<A> {
/**
* Returns the right-hand side of the "=" operator.
*/
@DerivedProperty
CtExpression<A> getAssignment();

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/spoon/reflect/code/CtTypeAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package spoon.reflect.code;

import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;

/**
* This code element represents a type reference usable as an expression.
Expand Down Expand Up @@ -68,6 +69,7 @@ public interface CtTypeAccess<A> extends CtExpression<Void> {
* @see #getAccessedType() to get the accessed type.
*/
@Override
@DerivedProperty
CtTypeReference<Void> getType();

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtAnnotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import spoon.reflect.code.CtLiteral;
import spoon.reflect.code.CtNewArray;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;
import spoon.support.UnsettableProperty;

import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -102,6 +105,7 @@ public interface CtAnnotation<A extends Annotation> extends CtExpression<A>, CtS
*
* @return annotated {@link spoon.reflect.declaration.CtElement}
*/
@DerivedProperty // the annotation is contained by the element not the other way around
CtElement getAnnotatedElement();

/**
Expand Down Expand Up @@ -138,4 +142,8 @@ public interface CtAnnotation<A extends Annotation> extends CtExpression<A>, CtS

@Override
CtAnnotation<A> clone();

@Override
@UnsettableProperty
<C extends CtExpression<A>> C setTypeCasts(List<CtTypeReference<?>> types);
}
22 changes: 22 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtAnnotationMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
*/
package spoon.reflect.declaration;

import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtExpression;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.UnsettableProperty;

import java.util.List;
import java.util.Set;

/**
* This element defines an annotation method declared in an annotation type.
Expand All @@ -34,4 +40,20 @@ public interface CtAnnotationMethod<T> extends CtMethod<T> {

@Override
CtAnnotationMethod<T> clone();

@Override
@UnsettableProperty
<B extends T, T1 extends CtExecutable<T>> T1 setBody(CtBlock<B> body);

@Override
@UnsettableProperty
<T1 extends CtExecutable<T>> T1 setThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes);

@Override
@UnsettableProperty
<T extends CtFormalTypeDeclarer> T setFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters);

@Override
@UnsettableProperty
<T1 extends CtExecutable<T>> T1 setParameters(List<CtParameter<?>> parameters);
}
19 changes: 19 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtAnnotationType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
*/
package spoon.reflect.declaration;

import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;
import spoon.support.UnsettableProperty;

import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Set;

/**
Expand All @@ -27,6 +32,7 @@ public interface CtAnnotationType<T extends Annotation> extends CtType<T> {
/**
* Gets the methods of this annotation type which are necessarily {@link CtAnnotationMethod}.
*/
@DerivedProperty
Set<CtAnnotationMethod<?>> getAnnotationMethods();

/**
Expand All @@ -45,4 +51,17 @@ public interface CtAnnotationType<T extends Annotation> extends CtType<T> {

@Override
CtAnnotationType<T> clone();

@Override
@UnsettableProperty
<T extends CtFormalTypeDeclarer> T setFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters);

@Override
@UnsettableProperty
<C extends CtType<T>> C setSuperInterfaces(Set<CtTypeReference<?>> interfaces);

@Override
@UnsettableProperty
<C extends CtType<T>> C setSuperclass(CtTypeReference<?> superClass);

}
14 changes: 14 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtAnonymousExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
*/
package spoon.reflect.declaration;

import spoon.reflect.reference.CtTypeReference;
import spoon.support.UnsettableProperty;

import java.util.List;
import java.util.Set;

/**
* This element defines an anonymous executable block declaration in a class.
*
Expand All @@ -24,4 +30,12 @@
public interface CtAnonymousExecutable extends CtExecutable<Void>, CtTypeMember {
@Override
CtAnonymousExecutable clone();

@Override
@UnsettableProperty
<T extends CtExecutable<Void>> T setThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes);

@Override
@UnsettableProperty
<T extends CtExecutable<Void>> T setParameters(List<CtParameter<?>> parameters);
}
13 changes: 7 additions & 6 deletions src/main/java/spoon/reflect/declaration/CtClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import spoon.reflect.code.CtStatement;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;

import java.util.List;
import java.util.Set;

Expand All @@ -33,15 +35,11 @@
* @author Renaud Pawlak
*/
public interface CtClass<T extends Object> extends CtType<T>, CtStatement {

/**
* Gets the fields defined by this class.
*/
List<CtField<?>> getFields();

/**
* Returns the anonymous blocks of this class.
* Derived from {@link #getTypeMembers()}
*/
@DerivedProperty
List<CtAnonymousExecutable> getAnonymousExecutables();

/**
Expand All @@ -52,7 +50,10 @@ public interface CtClass<T extends Object> extends CtType<T>, CtStatement {
/**
* Returns the constructors of this class. This includes the default
* constructor if this class has no constructors explicitly declared.
*
* Derived from {@link #getTypeMembers()}
*/
@DerivedProperty
Set<CtConstructor<T>> getConstructors();

/**
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/reflect/declaration/CtConstructor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ public interface CtConstructor<T> extends CtExecutable<T>, CtTypeMember, CtForma
*/
String getSimpleName();

/**
* Returns the declaring type of this constructor (always the same as the
* constructor's type).
*/
CtType<T> getDeclaringType();

@Override
CtConstructor<T> clone();
}
3 changes: 3 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import spoon.reflect.visitor.Filter;
import spoon.reflect.visitor.ReferenceFilter;
import spoon.reflect.visitor.Root;
import spoon.support.DerivedProperty;
import spoon.support.visitor.equals.IgnoredByEquals;

import java.lang.annotation.Annotation;
Expand Down Expand Up @@ -161,6 +162,7 @@ <E extends CtElement> List<E> getAnnotatedChildren(
* Calculates and returns the set of all the types referenced by this
* element (and sub-elements in the AST).
*/
@DerivedProperty
Set<CtTypeReference<?>> getReferencedTypes();

/**
Expand Down Expand Up @@ -196,6 +198,7 @@ <E extends CtElement> List<E> getAnnotatedChildren(
* @throws ParentNotInitializedException
* when the parent of this element is not initialized
*/
@DerivedProperty
CtElement getParent() throws ParentNotInitializedException;

/**
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package spoon.reflect.declaration;

import spoon.reflect.reference.CtTypeReference;
import spoon.support.UnsettableProperty;

import java.util.List;

/**
Expand Down Expand Up @@ -69,4 +72,12 @@ public interface CtEnum<T extends Enum<?>> extends CtClass<T> {

@Override
CtEnum<T> clone();

@Override
@UnsettableProperty
<T extends CtFormalTypeDeclarer> T setFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters);

@Override
@UnsettableProperty
<C extends CtType<T>> C setSuperclass(CtTypeReference<?> superClass);
}
2 changes: 2 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import spoon.reflect.code.CtBlock;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.DerivedProperty;

import java.util.List;
import java.util.Set;
Expand All @@ -39,6 +40,7 @@ public interface CtExecutable<R> extends CtNamedElement, CtTypedElement<R> {
*
* @see spoon.reflect.declaration.CtNamedElement#getReference()
*/
@DerivedProperty
CtExecutableReference<R> getReference();

/**
Expand Down
Loading

0 comments on commit 752f0d0

Please sign in to comment.